feat: expose existing Raspberry Pi metrics for Console history
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "pigway-agent",
|
||||
"name": "PIGWay Raspberry Pi Agent",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"protocol_version": 1,
|
||||
"entrypoint": "worker.py",
|
||||
"runtime": "python3",
|
||||
|
||||
+9
-1
@@ -61,11 +61,19 @@ def collect(device):
|
||||
raise AdapterError('INVALID_RESPONSE')
|
||||
metrics = []
|
||||
units = {'cpu_percent': 'percent', 'memory_percent': 'percent', 'disk_percent': 'percent',
|
||||
'temperature_c': 'celsius', 'cpu_freq_mhz': 'megahertz'}
|
||||
'temperature_c': 'celsius', 'cpu_freq_mhz': 'megahertz',
|
||||
'memory_total_bytes': 'bytes', 'memory_used_bytes': 'bytes',
|
||||
'disk_total_bytes': 'bytes', 'disk_used_bytes': 'bytes'}
|
||||
for key, unit in units.items():
|
||||
number = value['system'].get(key)
|
||||
if isinstance(number, (int, float)) and not isinstance(number, bool):
|
||||
metrics.append({'resource_id': 'host', 'key': key, 'value': number, 'unit': unit})
|
||||
uptime = value.get('uptime_seconds')
|
||||
if isinstance(uptime, (int, float)) and not isinstance(uptime, bool):
|
||||
metrics.append({'resource_id': 'host', 'key': 'uptime_seconds', 'value': uptime, 'unit': 'seconds'})
|
||||
speed = value.get('network', {}).get('link_speed_mbps')
|
||||
if isinstance(speed, (int, float)) and not isinstance(speed, bool):
|
||||
metrics.append({'resource_id': 'host', 'key': 'network_link_speed_mbps', 'value': speed, 'unit': 'megabits_per_second'})
|
||||
return {'schema_version': 1, 'observed_at': value.get('timestamp'),
|
||||
'identity': {'reported_name': value['machine'].get('name'), 'category': 'host',
|
||||
'details': value.get('device', {})},
|
||||
|
||||
Reference in New Issue
Block a user