diff --git a/grafana.json b/grafana.json index 2a57ac9..2c78bb5 100644 --- a/grafana.json +++ b/grafana.json @@ -44,7 +44,7 @@ }, "gridPos": { "h": 5, - "w": 6, + "w": 5, "x": 0, "y": 0 }, @@ -54,6 +54,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "auto", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -65,7 +66,7 @@ "textMode": "auto", "wideLayout": true }, - "pluginVersion": "11.0.0", + "pluginVersion": "11.2.0", "targets": [ { "datasource": { @@ -81,6 +82,7 @@ } ], "title": "Received this month", + "transparent": true, "type": "stat" }, { @@ -106,8 +108,8 @@ }, "gridPos": { "h": 5, - "w": 6, - "x": 6, + "w": 5, + "x": 5, "y": 0 }, "id": 8, @@ -116,6 +118,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "auto", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -127,7 +130,7 @@ "textMode": "auto", "wideLayout": true }, - "pluginVersion": "11.0.0", + "pluginVersion": "11.2.0", "targets": [ { "datasource": { @@ -143,6 +146,7 @@ } ], "title": "Sent this month", + "transparent": true, "type": "stat" }, { @@ -152,177 +156,38 @@ }, "fieldConfig": { "defaults": { + "color": { + "mode": "thresholds" + }, + "fieldMinMax": true, "mappings": [], "thresholds": { - "mode": "absolute", + "mode": "percentage", "steps": [ { "color": "green", "value": null }, { - "color": "red", + "color": "#EAB839", "value": 80 + }, + { + "color": "dark-red", + "value": 90 } ] }, - "unit": "dB" + "unit": "binBps" }, "overrides": [] }, "gridPos": { "h": 10, "w": 4, - "x": 12, + "x": 10, "y": 0 }, - "id": 4, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "11.0.0", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "ddh48acw4qku8a" - }, - "editorMode": "code", - "expr": "zte_snr", - "instant": false, - "legendFormat": "{{band}}", - "range": true, - "refId": "A" - } - ], - "title": "SNR", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "ddh48acw4qku8a" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "fieldMinMax": true, - "mappings": [], - "thresholds": { - "mode": "percentage", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "#EAB839", - "value": 80 - }, - { - "color": "dark-red", - "value": 90 - } - ] - }, - "unit": "binBps" - }, - "overrides": [] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 0, - "y": 5 - }, - "id": 3, - "options": { - "minVizHeight": 75, - "minVizWidth": 75, - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true, - "sizing": "auto" - }, - "pluginVersion": "11.0.0", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "ddh48acw4qku8a" - }, - "editorMode": "code", - "expr": "zte_bandwidth_rx", - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Receive", - "type": "gauge" - }, - { - "datasource": { - "type": "prometheus", - "uid": "ddh48acw4qku8a" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "fieldMinMax": true, - "mappings": [], - "thresholds": { - "mode": "percentage", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "#EAB839", - "value": 80 - }, - { - "color": "dark-red", - "value": 90 - } - ] - }, - "unit": "binBps" - }, - "overrides": [] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 6, - "y": 5 - }, "id": 6, "options": { "minVizHeight": 75, @@ -339,7 +204,7 @@ "showThresholdMarkers": true, "sizing": "auto" }, - "pluginVersion": "11.0.0", + "pluginVersion": "11.2.0", "targets": [ { "datasource": { @@ -355,8 +220,227 @@ } ], "title": "Transmit", + "transparent": true, "type": "gauge" }, + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "fieldMinMax": true, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 80 + }, + { + "color": "dark-red", + "value": 90 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 4, + "x": 14, + "y": 0 + }, + "id": 3, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.2.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "editorMode": "code", + "expr": "zte_bandwidth_rx", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Receive", + "transparent": true, + "type": "gauge" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 5, + "x": 0, + "y": 5 + }, + "id": 10, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "/^firmware$/", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.2.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "editorMode": "code", + "expr": "zte_modem_info", + "format": "table", + "instant": true, + "legendFormat": "{{firmware}}", + "range": true, + "refId": "A" + } + ], + "title": "Firmware", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 5, + "x": 5, + "y": 5 + }, + "id": 11, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "/^ip_addr$/", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.2.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "editorMode": "code", + "expr": "zte_modem_info", + "format": "table", + "instant": true, + "legendFormat": "{{ip}}", + "range": true, + "refId": "A" + } + ], + "title": "WAN IP", + "transparent": true, + "type": "stat" + }, { "datasource": { "type": "prometheus", @@ -374,6 +458,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", @@ -423,11 +508,17 @@ "x": 0, "y": 10 }, - "id": 2, + "id": 9, + "interval": "120s", "options": { "legend": { - "calcs": [], - "displayMode": "list", + "calcs": [ + "last", + "min", + "max", + "mean" + ], + "displayMode": "table", "placement": "bottom", "showLegend": true }, @@ -444,14 +535,15 @@ "uid": "ddh48acw4qku8a" }, "editorMode": "code", - "expr": "zte_rsrp", + "expr": "zte_snr", "instant": false, "legendFormat": "{{band}}", "range": true, "refId": "A" } ], - "title": "RSRP", + "title": "SNR", + "transparent": true, "type": "timeseries" }, { @@ -471,6 +563,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", @@ -516,16 +609,126 @@ }, "gridPos": { "h": 8, - "w": 7, + "w": 9, "x": 9, "y": 10 }, - "id": 5, - "interval": "30s", + "id": 2, + "interval": "120s", "options": { "legend": { - "calcs": [], - "displayMode": "list", + "calcs": [ + "last", + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "editorMode": "code", + "expr": "zte_rsrp", + "instant": false, + "legendFormat": "{{band}}", + "range": true, + "refId": "A" + } + ], + "title": "RSRP", + "transparent": true, + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "dB" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 18 + }, + "id": 5, + "interval": "120s", + "options": { + "legend": { + "calcs": [ + "last", + "min", + "max", + "mean" + ], + "displayMode": "table", "placement": "bottom", "showLegend": true }, @@ -550,6 +753,113 @@ } ], "title": "RSRQ", + "transparent": true, + "type": "timeseries" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "dB" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 9, + "y": 18 + }, + "id": 12, + "interval": "120s", + "options": { + "legend": { + "calcs": [ + "last", + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "ddh48acw4qku8a" + }, + "editorMode": "code", + "expr": "zte_rssi", + "instant": false, + "legendFormat": "{{band}}", + "range": true, + "refId": "A" + } + ], + "title": "RSSI", + "transparent": true, "type": "timeseries" }, { @@ -569,6 +879,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 19, "gradientMode": "none", @@ -616,17 +927,22 @@ "overrides": [] }, "gridPos": { - "h": 8, - "w": 16, + "h": 10, + "w": 19, "x": 0, - "y": 18 + "y": 26 }, "id": 1, - "interval": "30s", + "interval": "120s", "options": { "legend": { - "calcs": [], - "displayMode": "list", + "calcs": [ + "last", + "min", + "max", + "mean" + ], + "displayMode": "table", "placement": "bottom", "showLegend": true }, @@ -665,6 +981,7 @@ } ], "title": "Bandwidth in use", + "transparent": true, "type": "timeseries" } ], @@ -675,14 +992,13 @@ "list": [] }, "time": { - "from": "now-6h", + "from": "now-15m", "to": "now" }, - "timeRangeUpdatedDuringEditOrView": false, "timepicker": {}, "timezone": "browser", "title": "ZTE 5G", "uid": "bdmvny6iizbpcc", - "version": 10, + "version": 27, "weekStart": "" -} +} \ No newline at end of file diff --git a/zte_exporter.py b/zte_exporter.py index ea05502..eb404ef 100644 --- a/zte_exporter.py +++ b/zte_exporter.py @@ -83,7 +83,7 @@ class zteRouter: def zteinfo(self): ip = self.ip cookie = self.getCookie(username=self.username, password=self.password, LD=self.get_LD(), login=self.login) - cmd_url = f"{self.protocol}://{self.ip}/goform/goform_get_cmd_process?multi_data=1&isTest=false&cmd=wa_inner_version%2Clte_rssi%2CZ5g_rssi%2Clte_rsrp%2CZ5g_rsrp%2Clte_rsrq%2CZ5g_rsrq%2Clte_snr%2CZ5g_SINR%2Csignalbar%2Ccell_id%2Cnr5g_action_band%2Ccell_id%2Cnetwork_provider%2Cmonthly_tx_bytes%2Cmonthly_rx_bytes%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cwan_ipaddr%2Cwan_apn" + cmd_url = f"{self.protocol}://{self.ip}/goform/goform_get_cmd_process?multi_data=1&isTest=false&cmd=wa_inner_version%2Clte_rssi%2CZ5g_rssi%2Clte_rsrp%2CZ5g_rsrp%2Clte_rsrq%2CZ5g_rsrq%2Clte_snr%2CZ5g_SINR%2Csignalbar%2Ccell_id%2Cnr5g_action_band%2Ccell_id%2Cnetwork_provider%2Cmonthly_tx_bytes%2Cmonthly_rx_bytes%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cwan_ipaddr%2Cwan_apn%2Clte_multi_ca_scell_sig_info%2Cnr_multi_ca_scell_info%2Cnr5g_action_band" cookie_pass = cookie headers = { @@ -94,6 +94,11 @@ class zteRouter: response = s.get(cmd_url, headers=headers, verify=False) return response.text + + def iterateCellInfo(self, str, type): + for f in str: + print (f) + zteInstance = zteRouter(args.ip, args.username, args.password, args.login) serverPort = args.port @@ -114,23 +119,56 @@ class serveInfos(BaseHTTPRequestHandler): self.wfile.write(bytes("%s\",cell_id=\"" % gatheredJson["wan_apn"], "utf-8")) self.wfile.write(bytes("%s\"} 1\n\n" % gatheredJson["cell_id"], "utf-8")) - self.wfile.write(bytes("# HELP zte_rsrq Reference Signal Received Quality\n# TYPE zte_rsrq gauge\n", "utf-8")) - if gatheredJson["lte_rsrq"]: - self.wfile.write(bytes("zte_rsrq{band=\"lte\"} %s\n" % gatheredJson["lte_rsrq"], "utf-8")) - if gatheredJson["Z5g_rsrq"]: - self.wfile.write(bytes("zte_rsrq{band=\"5g\"} %s\n\n" % gatheredJson["Z5g_rsrq"], "utf-8")) - self.wfile.write(bytes("# HELP zte_rsrp Reference Signal Received Power\n# TYPE zte_rsrp gauge\n", "utf-8")) - if gatheredJson["lte_rsrp"]: - self.wfile.write(bytes("zte_rsrp{band=\"lte\"} %s\n" % gatheredJson["lte_rsrp"], "utf-8")) - if gatheredJson["Z5g_rsrp"]: - self.wfile.write(bytes("zte_rsrp{band=\"5g\"} %s\n\n" % gatheredJson["Z5g_rsrp"], "utf-8")) - self.wfile.write(bytes("# HELP zte_snr Signal-to-Interference-plus-Noise Ratio\n# TYPE zte_snr gauge\n", "utf-8")) - if gatheredJson["lte_snr"]: - self.wfile.write(bytes("zte_snr{band=\"lte\"} %s\n" % gatheredJson["lte_snr"], "utf-8")) - if gatheredJson["Z5g_SINR"]: - self.wfile.write(bytes("zte_snr{band=\"5g\"} %s\n\n" % gatheredJson["Z5g_SINR"], "utf-8")) + self.wfile.write(bytes("# HELP zte_rsrq Reference Signal Received Quality\n# TYPE zte_rsrq gauge\n", "utf-8")) + self.wfile.write(bytes("# HELP zte_rssi Received Signal Strength Indicator\n# TYPE zte_rssi gauge\n", "utf-8")) + + if gatheredJson['nr_multi_ca_scell_info'] and gatheredJson['nr5g_action_band']: + self.wfile.write(bytes("zte_rsrq{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) + self.wfile.write(bytes("%s\n" % gatheredJson["Z5g_rsrq"], "utf-8")) + + self.wfile.write(bytes("zte_rsrp{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) + self.wfile.write(bytes("%s\n" % gatheredJson["Z5g_rsrp"], "utf-8")) + + self.wfile.write(bytes("zte_rssi{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) + self.wfile.write(bytes("%s\n" % gatheredJson["Z5g_rssi"], "utf-8")) + + self.wfile.write(bytes("zte_snr{band=\"%s\"} " % gatheredJson["nr5g_action_band"], "utf-8")) + self.wfile.write(bytes("%s\n\n" % gatheredJson["Z5g_SINR"], "utf-8")) + + for index, item in enumerate(gatheredJson['nr_multi_ca_scell_info'].split(";")): + nrbit = item.split(",") + if not len(nrbit[0]) == 0: + self.wfile.write(bytes("zte_rsrq{band=\"%s\"} " % nrbit[3], "utf-8")) + self.wfile.write(bytes("%s\n" % gatheredJson["Z5g_rsrq"], "utf-8")) + + self.wfile.write(bytes("zte_rsrp{band=\"%s\"} " % nrbit[3], "utf-8")) + self.wfile.write(bytes("%s\n" % nrbit[7], "utf-8")) + + self.wfile.write(bytes("zte_rssi{band=\"%s\"} " % nrbit[3], "utf-8")) + self.wfile.write(bytes("%s\n" % nrbit[10], "utf-8")) + + self.wfile.write(bytes("zte_snr{band=\"%s\"} " % nrbit[3], "utf-8")) + self.wfile.write(bytes("%s\n\n" % nrbit[9], "utf-8")) + + else: + if gatheredJson["lte_rsrq"]: + self.wfile.write(bytes("zte_rsrq{band=\"lte\"} %s\n" % gatheredJson["lte_rsrq"], "utf-8")) + if gatheredJson["Z5g_rsrq"]: + self.wfile.write(bytes("zte_rsrq{band=\"5g\"} %s\n" % gatheredJson["Z5g_rsrq"], "utf-8")) + if gatheredJson["lte_rsrp"]: + self.wfile.write(bytes("zte_rsrp{band=\"lte\"} %s\n" % gatheredJson["lte_rsrp"], "utf-8")) + if gatheredJson["Z5g_rssi"]: + self.wfile.write(bytes("zte_rsrp{band=\"5g\"} %s\n" % gatheredJson["Z5g_rssi"], "utf-8")) + if gatheredJson["lte_rssi"]: + self.wfile.write(bytes("zte_snr{band=\"lte\"} %s\n" % gatheredJson["lte_rssi"], "utf-8")) + if gatheredJson["Z5g_SINR"]: + self.wfile.write(bytes("zte_snr{band=\"5g\"} %s\n" % gatheredJson["Z5g_SINR"], "utf-8")) + if gatheredJson["lte_snr"]: + self.wfile.write(bytes("zte_snr{band=\"lte\"} %s\n" % gatheredJson["lte_snr"], "utf-8")) + if gatheredJson["Z5g_SINR"]: + self.wfile.write(bytes("zte_snr{band=\"5g\"} %s\n\n" % gatheredJson["Z5g_SINR"], "utf-8")) self.wfile.write(bytes("# HELP zte_bandwidth_used_monthly_tx Used bandwidth, transmit (bytes)\n# TYPE zte_bandwidth_used_monthly_tx counter\n", "utf-8")) self.wfile.write(bytes("zte_bandwidth_used_monthly_tx %s\n\n" % gatheredJson["monthly_tx_bytes"], "utf-8"))