diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-11-30 14:02:39 +0100 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-11-30 14:02:39 +0100 |
| commit | 03c515fa55657dafa41a6a0fe7bf806bd7521e87 (patch) | |
| tree | 8072c7e70c041ca174077564eae75d38e6ac4391 /overlays | |
| parent | cb5fb02e309f23c9bb0cfec41a1e6f5d4251a974 (diff) | |
| download | nixos-03c515fa55657dafa41a6a0fe7bf806bd7521e87.tar nixos-03c515fa55657dafa41a6a0fe7bf806bd7521e87.tar.gz nixos-03c515fa55657dafa41a6a0fe7bf806bd7521e87.tar.bz2 nixos-03c515fa55657dafa41a6a0fe7bf806bd7521e87.tar.xz nixos-03c515fa55657dafa41a6a0fe7bf806bd7521e87.zip | |
...
Diffstat (limited to 'overlays')
| -rw-r--r-- | overlays/zte-prometheus-exporter/zte-prometheus-exporter.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/overlays/zte-prometheus-exporter/zte-prometheus-exporter.py b/overlays/zte-prometheus-exporter/zte-prometheus-exporter.py index bc8326ff..1d150eda 100644 --- a/overlays/zte-prometheus-exporter/zte-prometheus-exporter.py +++ b/overlays/zte-prometheus-exporter/zte-prometheus-exporter.py | |||
| @@ -127,6 +127,16 @@ class ZTEMetrics: | |||
| 127 | def prometheus(self): | 127 | def prometheus(self): |
| 128 | metrics = '' | 128 | metrics = '' |
| 129 | 129 | ||
| 130 | metrics += _format_prom_metrics('info', 'gauge', [({ | ||
| 131 | "version_date": self.attrs['DEVINFO']['IGD']['VerDate'], | ||
| 132 | "software_version": self.attrs['DEVINFO']['IGD']['SoftwareVer'], | ||
| 133 | "model_name": self.attrs['DEVINFO']['IGD']['ModelName'], | ||
| 134 | "model_firmware_version": self.attrs['DEVINFO']['IGD']['ModelFirmwareVer'], | ||
| 135 | "hardware_version": self.attrs['DEVINFO']['IGD']['HardwareVer'], | ||
| 136 | "serial_number": self.attrs['DEVINFO']['IGD']['SerialNumber'], | ||
| 137 | "boot_version": self.attrs['DEVINFO']['IGD']['BootVer'], | ||
| 138 | }, 1)], 'Metadata about a given ZTE device') | ||
| 139 | |||
| 130 | uptime_seconds = timeparse(self.attrs['SYSTEMYIME']['IGD']['systemTime']) | 140 | uptime_seconds = timeparse(self.attrs['SYSTEMYIME']['IGD']['systemTime']) |
| 131 | metrics += _format_prom_metrics('uptime_seconds', 'gauge', [({}, uptime_seconds)], 'Seconds device has been running') | 141 | metrics += _format_prom_metrics('uptime_seconds', 'gauge', [({}, uptime_seconds)], 'Seconds device has been running') |
| 132 | 142 | ||
| @@ -163,13 +173,16 @@ class ZTEMetrics: | |||
| 163 | link_metrics['current_rate_kbps']['metrics'] += [({"direction": "up", "link": link_number}, int(self.attrs['DSLINTERFACE'][link]['Upstream_current_rate']))] | 173 | link_metrics['current_rate_kbps']['metrics'] += [({"direction": "up", "link": link_number}, int(self.attrs['DSLINTERFACE'][link]['Upstream_current_rate']))] |
| 164 | link_metrics['current_rate_kbps']['metrics'] += [({"direction": "down", "link": link_number}, int(self.attrs['DSLINTERFACE'][link]['Downstream_current_rate']))] | 174 | link_metrics['current_rate_kbps']['metrics'] += [({"direction": "down", "link": link_number}, int(self.attrs['DSLINTERFACE'][link]['Downstream_current_rate']))] |
| 165 | 175 | ||
| 166 | if 'dsl_uptime_seconds' not in link_metrics: | 176 | if 'uptime_seconds' not in link_metrics: |
| 167 | link_metrics['uptime_seconds'] = {'type': 'gauge', 'metrics': []} | 177 | link_metrics['uptime_seconds'] = {'type': 'gauge', 'metrics': []} |
| 168 | link_metrics['uptime_seconds']['metrics'] += [({"link": link_number}, int(self.attrs['DSLINTERFACE'][link]['Showtime_start']) if link_is_up else 0)] | 178 | link_metrics['uptime_seconds']['metrics'] += [({"link": link_number}, int(self.attrs['DSLINTERFACE'][link]['Showtime_start']) if link_is_up else 0)] |
| 169 | 179 | ||
| 170 | if 'status' not in link_metrics: | 180 | if 'status' not in link_metrics: |
| 171 | link_metrics['status'] = {'type': 'gauge', 'metrics': []} | 181 | link_metrics['status'] = {'type': 'gauge', 'metrics': []} |
| 172 | link_metrics['status']['metrics'] += [({"link": link_number, "status": self.attrs['DSLINTERFACE'][link]['Status']}, 1)] | 182 | up_status, *status = self.attrs['DSLINTERFACE'][link]['Status'].split(',') |
| 183 | down_status = up_status if not status else status[0] | ||
| 184 | link_metrics['status']['metrics'] += [({"link": link_number, "direction": "up", "status": up_status}, 1)] | ||
| 185 | link_metrics['status']['metrics'] += [({"link": link_number, "direction": "down", "status": down_status}, 1)] | ||
| 173 | if link_metrics: | 186 | if link_metrics: |
| 174 | for metric_name in link_metrics: | 187 | for metric_name in link_metrics: |
| 175 | metrics += _format_prom_metrics(f'dsl_{metric_name}', link_metrics[metric_name]['type'], link_metrics[metric_name]['metrics']) | 188 | metrics += _format_prom_metrics(f'dsl_{metric_name}', link_metrics[metric_name]['type'], link_metrics[metric_name]['metrics']) |
