From 8971a6cdf42702c2b67ebc2d033dc5fe846084bf Mon Sep 17 00:00:00 2001 From: ohrensessel Date: Fri, 7 Jun 2019 08:51:51 +0200 Subject: [PATCH] add code for snmp targets, _bytes --> _bytes_total --- README.md | 6 ++++++ WeatherMapDataSource_prometheus.php | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 419836b..075248e 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ # promPHPWeathermap + +to be put into the `lib/datasources` folder of your weathermap code + +an example on how to use this is given within the datasource code itself + +use this at your own risk, you probably can do this more elegant \ No newline at end of file diff --git a/WeatherMapDataSource_prometheus.php b/WeatherMapDataSource_prometheus.php index 3da1f90..f491787 100644 --- a/WeatherMapDataSource_prometheus.php +++ b/WeatherMapDataSource_prometheus.php @@ -1,3 +1,16 @@ + 3) { + $query_rx = "irate(ifInOctets{instance='$router',$parts[3]='$device'}[10m])"; + $query_tx = "irate(ifOutOctets{instance='$router',$parts[3]='$device'}[10m])"; + } else { + $query_rx = "irate(node_network_receive_bytes_total{instance='$router:9100',device='$device'}[5m])"; + $query_tx = "irate(node_network_transmit_bytes_total{instance='$router:9100',device='$device'}[5m])"; + } $rx_rate = $this->prometheus_query($query_rx) * 8; $tx_rate = $this->prometheus_query($query_tx) * 8; @@ -60,4 +78,4 @@ class WeatherMapDataSource_prometheus extends WeatherMapDataSource { } // vim:ts=4:sw=4: -?> +?> \ No newline at end of file