From 7661b5819dad547cb7dd8320d3e88ea646792515 Mon Sep 17 00:00:00 2001 From: Vitaliy Skrypnyk Date: Fri, 26 Feb 2021 23:54:35 +0200 Subject: [PATCH] Update default configuration, small fixes in dashboard --- README.md | 48 +++++++------- config/metrics.json | 46 +++++++++++++- grafana-dashboard.json | 138 ++++++++++++++++++++++++++--------------- 3 files changed, 157 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 65b4fb5..9d6791e 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,9 @@ # Supporter router -Tested with: Keenetic Ultra (KN-1810) KeeneticOS 3.4.12 +Tested with: Keenetic Ultra (KN-1810) KeeneticOS 3.5.6 -May work on other Keenetic routers - -# Build from sources - -`docker build -t keenetic-grafana-monitoring .` +May works on other Keenetic routers # Preparation @@ -52,7 +48,28 @@ Destination port: 79 * Import Grafana dashboard from [grafana.com](https://grafana.com/grafana/dashboards/12723) -# Run with docker-compose.yml +# Run + +There are two options, you can run collector directly on the router or in Docker on separate host. + +## Run on router + +* Copy repository content to your router `/opt/home/keenetic-grafana-monitoring` +* Install Python `opkg install python3 python3-pip` +* Install dependencies ` pip install -r requirements.txt` +* Create script for autorun `/opt/etc/init.d/S99keeneticgrafana` + +```$bash +#!/bin/sh + +[ "$1" != "start" ] && exit 0 + +nohup python /opt/home/keenetic-grafana-monitoring/keentic_influxdb_exporter.py >/dev/null 2>&1 & +``` + +* Run `/opt/etc/init.d/S99keeneticgrafana start` + +## Run on Docker ``` --- @@ -69,19 +86,6 @@ services: restart: always ``` -# Run on router +# Build Docker image -* Copy repository content to your router `/opt/home/keenetic-grafana-monitoring` -* Install Python `opkg install python3 python3-pip` -* Install dependencies ` pip install -r requirements.txt` -* Create script for autorun `/opt/etc/init.d/S99keeneticgrafana` - -```$bash -#!/bin/sh - -[ "$1" != "start" ] && exit 0 - -nohup python /opt/home/keenetic-grafana-monitoring/keentic_influxdb_exporter.py >/dev/null 2>&1 & -``` - -* Run `/opt/etc/init.d/S99keeneticgrafana start` +`docker build -t keenetic-grafana-monitoring .` diff --git a/config/metrics.json b/config/metrics.json index fdd1c8d..1ff6cd3 100644 --- a/config/metrics.json +++ b/config/metrics.json @@ -111,7 +111,49 @@ "command": "interface stat", "root" : "$", "param" : { - "name" : "GigabitEthernet1" + "name" : "ISP" + }, + "tags" : {}, + "values" : { + "rxbytes": "$.rxbytes", + "txbytes": "$.txbytes", + "rxspeed": "$.rxspeed", + "txspeed": "$.txspeed" + } + }, + { + "command": "interface stat", + "root" : "$", + "param" : { + "name" : "AccessPoint" + }, + "tags" : {}, + "values" : { + "rxbytes": "$.rxbytes", + "txbytes": "$.txbytes", + "rxspeed": "$.rxspeed", + "txspeed": "$.txspeed" + } + }, + { + "command": "interface stat", + "root" : "$", + "param" : { + "name" : "AccessPoint_5G" + }, + "tags" : {}, + "values" : { + "rxbytes": "$.rxbytes", + "txbytes": "$.txbytes", + "rxspeed": "$.rxspeed", + "txspeed": "$.txspeed" + } + }, + { + "command": "interface stat", + "root" : "$", + "param" : { + "name" : "GigabitEthernet0" }, "tags" : {}, "values" : { @@ -136,4 +178,4 @@ } } ] -} \ No newline at end of file +} diff --git a/grafana-dashboard.json b/grafana-dashboard.json index b7c2a43..818aad7 100644 --- a/grafana-dashboard.json +++ b/grafana-dashboard.json @@ -20,7 +20,7 @@ "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "7.0.2" + "version": "7.4.3" }, { "type": "panel", @@ -100,10 +100,13 @@ "calcs": [ "count" ], + "fields": "", "values": false - } + }, + "text": {}, + "textMode": "auto" }, - "pluginVersion": "7.0.2", + "pluginVersion": "7.4.3", "targets": [ { "alias": "Ethernet Clients", @@ -231,10 +234,13 @@ "calcs": [ "last" ], + "fields": "", "values": false - } + }, + "text": {}, + "textMode": "auto" }, - "pluginVersion": "7.0.2", + "pluginVersion": "7.4.3", "targets": [ { "groupBy": [ @@ -348,12 +354,14 @@ "calcs": [ "mean" ], + "fields": "", "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "text": {} }, - "pluginVersion": "7.0.2", + "pluginVersion": "7.4.3", "targets": [ { "alias": "$col", @@ -373,7 +381,7 @@ ], "orderByTime": "ASC", "policy": "default", - "query": "SELECT (mean(\"memtotal\") - mean(\"memfree\")) as \"RAM Usage\" FROM \"system\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT (mean(\"memtotal\") - mean(\"memfree\") - mean(\"membuffers\") - mean(\"memcache\")) as \"RAM Usage\" FROM \"system\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -411,7 +419,7 @@ ], "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"cpuload\") as \"CPU Usage\" FROM \"system\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"cpuload\") as \"CPU Usage\" FROM \"system\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -441,9 +449,7 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": { - "align": null - }, + "custom": {}, "decimals": 0, "mappings": [ { @@ -500,12 +506,14 @@ "calcs": [ "last" ], + "fields": "", "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": false + "showThresholdMarkers": false, + "text": {} }, - "pluginVersion": "7.0.2", + "pluginVersion": "7.4.3", "targets": [ { "alias": "$col", @@ -561,7 +569,8 @@ "decimals": 2, "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -592,9 +601,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -628,7 +638,7 @@ "measurement": "interface stat", "orderByTime": "ASC", "policy": "default", - "query": "SELECT non_negative_difference(mean(\"txbytes\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(none)", + "query": "SELECT non_negative_difference(mean(\"txbytes\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -670,7 +680,7 @@ ], "orderByTime": "ASC", "policy": "default", - "query": "SELECT non_negative_difference(mean(\"rxbytes\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(none)", + "query": "SELECT non_negative_difference(mean(\"rxbytes\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -743,7 +753,8 @@ "decimals": 2, "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -774,9 +785,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -810,7 +822,7 @@ "measurement": "interface stat", "orderByTime": "ASC", "policy": "default", - "query": "SELECT(mean(\"txspeed\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(none)", + "query": "SELECT(mean(\"txspeed\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -852,7 +864,7 @@ ], "orderByTime": "ASC", "policy": "default", - "query": "SELECT(mean(\"rxspeed\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(none)", + "query": "SELECT(mean(\"rxspeed\")) FROM \"interface stat\" WHERE $timeFilter GROUP BY time($__interval), \"name\" fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -925,7 +937,8 @@ "decimals": 2, "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -956,9 +969,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -992,7 +1006,7 @@ "measurement": "ip hotspot", "orderByTime": "ASC", "policy": "default", - "query": "SELECT non_negative_difference(mean(\"rxbytes\")) + non_negative_difference(mean(\"txbytes\")) FROM \"ip hotspot\" WHERE $timeFilter AND \"active\" = 1 GROUP BY time($__interval), \"name\" fill(none)", + "query": "SELECT non_negative_difference(mean(\"rxbytes\")) + non_negative_difference(mean(\"txbytes\")) FROM \"ip hotspot\" WHERE $timeFilter AND \"active\" = 1 GROUP BY time($__interval), \"name\" fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1088,7 +1102,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1115,9 +1130,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -1215,7 +1231,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1229,6 +1246,7 @@ }, "hiddenSeries": false, "id": 5, + "interval": "", "legend": { "alignAsTable": true, "avg": true, @@ -1246,9 +1264,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -1258,7 +1277,7 @@ "steppedLine": false, "targets": [ { - "alias": "$tag_name", + "alias": "$tag_name [$tag_mode]", "groupBy": [ { "params": [ @@ -1282,6 +1301,8 @@ "measurement": "ip hotspot", "orderByTime": "ASC", "policy": "default", + "query": "SELECT mean(\"txrate\") FROM \"ip hotspot\" WHERE $timeFilter AND \"active\" = 1 AND \"mode\" != \"\" GROUP BY time($__interval), \"name\", \"mode\" fill(null)", + "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ @@ -1350,7 +1371,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1364,6 +1386,7 @@ }, "hiddenSeries": false, "id": 2, + "interval": "", "legend": { "alignAsTable": true, "avg": false, @@ -1381,9 +1404,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -1393,7 +1417,7 @@ "steppedLine": false, "targets": [ { - "alias": "$tag_name", + "alias": "$tag_name [$tag_mode]", "groupBy": [ { "params": [ @@ -1417,6 +1441,8 @@ "measurement": "ip hotspot", "orderByTime": "ASC", "policy": "default", + "query": "SELECT mean(\"signal\") FROM \"ip hotspot\" WHERE $timeFilter AND \"active\" = 1 GROUP BY time($__interval), \"name\", \"mode\" fill(null)", + "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ @@ -1485,7 +1511,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1513,9 +1540,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -1535,7 +1563,7 @@ }, { "params": [ - "linear" + "null" ], "type": "fill" } @@ -1613,7 +1641,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1642,9 +1671,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -1672,7 +1702,7 @@ "measurement": "system", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"memtotal\") - mean(\"memfree\") FROM \"system\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"memtotal\") - mean(\"memfree\") FROM \"system\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1742,7 +1772,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1773,9 +1804,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -1878,7 +1910,8 @@ "datasource": "${DS_INFLUXDB_KEENETIC}", "fieldConfig": { "defaults": { - "custom": {} + "custom": {}, + "links": [] }, "overrides": [] }, @@ -1907,9 +1940,10 @@ "linewidth": 1, "nullPointMode": "null", "options": { - "dataLinks": [] + "alertThreshold": true }, "percentage": false, + "pluginVersion": "7.4.3", "pointradius": 2, "points": false, "renderer": "flot", @@ -2015,7 +2049,8 @@ "fieldConfig": { "defaults": { "custom": { - "align": null + "align": null, + "filterable": false }, "decimals": 2, "mappings": [], @@ -2097,7 +2132,7 @@ } ] }, - "pluginVersion": "7.0.2", + "pluginVersion": "7.4.3", "targets": [ { "groupBy": [ @@ -2167,7 +2202,8 @@ "defaults": { "custom": { "align": null, - "displayMode": "color-background" + "displayMode": "color-background", + "filterable": false }, "mappings": [ { @@ -2263,7 +2299,7 @@ } ] }, - "pluginVersion": "7.0.2", + "pluginVersion": "7.4.3", "targets": [ { "groupBy": [ @@ -2323,14 +2359,14 @@ } ], "refresh": false, - "schemaVersion": 25, + "schemaVersion": 27, "style": "dark", "tags": [], "templating": { "list": [] }, "time": { - "from": "now-6h", + "from": "now-24h", "to": "now" }, "timepicker": { @@ -2349,5 +2385,5 @@ "timezone": "", "title": "Keenetic", "uid": "rufORtVGk", - "version": 77 -} \ No newline at end of file + "version": 87 +}