mirror of
https://github.com/NohamR/prometheus-qbittorrent-exporter.git
synced 2025-05-23 16:49:29 +00:00
total dl/up
This commit is contained in:
parent
c10515dc08
commit
62952917be
@ -79,7 +79,7 @@
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 3,
|
||||
"w": 2,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
@ -96,9 +96,10 @@
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
@ -162,8 +163,8 @@
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 3,
|
||||
"x": 3,
|
||||
"w": 2,
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
"id": 3,
|
||||
@ -179,9 +180,10 @@
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "qbittorrent_connected - qbittorrent_firewalled",
|
||||
@ -239,7 +241,7 @@
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 3,
|
||||
"x": 6,
|
||||
"x": 4,
|
||||
"y": 0
|
||||
},
|
||||
"id": 13,
|
||||
@ -255,9 +257,10 @@
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "qbittorrent_dht_nodes",
|
||||
@ -294,11 +297,11 @@
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 3,
|
||||
"x": 9,
|
||||
"w": 2,
|
||||
"x": 7,
|
||||
"y": 0
|
||||
},
|
||||
"id": 5,
|
||||
"id": 18,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
@ -311,9 +314,10 @@
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
@ -321,14 +325,14 @@
|
||||
"uid": "${data_source}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "sum by (app) (qbittorrent_dl_info_data_total)",
|
||||
"expr": "sum by (app) (qbittorrent_alltime_dl_total)",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": " ",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Data downloaded",
|
||||
"title": "Total downloaded",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
@ -354,8 +358,8 @@
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 3,
|
||||
"x": 12,
|
||||
"w": 2,
|
||||
"x": 9,
|
||||
"y": 0
|
||||
},
|
||||
"id": 6,
|
||||
@ -371,9 +375,132 @@
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${data_source}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "sum by (app) (qbittorrent_alltime_ul_total)",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": " ",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Total uploaded",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${data_source}"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 2,
|
||||
"x": 11,
|
||||
"y": 0
|
||||
},
|
||||
"id": 5,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"last"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${data_source}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "sum by (app) (qbittorrent_dl_info_data_total)",
|
||||
"instant": false,
|
||||
"interval": "",
|
||||
"legendFormat": " ",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Session downloaded",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${data_source}"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 4,
|
||||
"w": 2,
|
||||
"x": 13,
|
||||
"y": 0
|
||||
},
|
||||
"id": 19,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"last"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
@ -388,7 +515,7 @@
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Data uploaded",
|
||||
"title": "Session uploaded",
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
@ -431,9 +558,10 @@
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
@ -487,6 +615,8 @@
|
||||
},
|
||||
"id": 16,
|
||||
"options": {
|
||||
"minVizHeight": 75,
|
||||
"minVizWidth": 75,
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
@ -498,7 +628,7 @@
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "rate(qbittorrent_dl_info_data_total[2m])",
|
||||
@ -547,6 +677,8 @@
|
||||
},
|
||||
"id": 17,
|
||||
"options": {
|
||||
"minVizHeight": 75,
|
||||
"minVizWidth": 75,
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
@ -558,7 +690,7 @@
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "rate(qbittorrent_up_info_data_total[2m])",
|
||||
@ -607,7 +739,7 @@
|
||||
"alertThreshold": true
|
||||
},
|
||||
"percentage": false,
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
@ -697,7 +829,7 @@
|
||||
"alertThreshold": true
|
||||
},
|
||||
"percentage": false,
|
||||
"pluginVersion": "9.4.3",
|
||||
"pluginVersion": "10.2.2",
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
@ -807,7 +939,6 @@
|
||||
"refresh": "10s",
|
||||
"revision": 1,
|
||||
"schemaVersion": 38,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": [
|
||||
@ -844,9 +975,9 @@
|
||||
},
|
||||
{
|
||||
"current": {
|
||||
"selected": true,
|
||||
"selected": false,
|
||||
"text": "Prometheus",
|
||||
"value": "Prometheus"
|
||||
"value": "d4352f38-27bf-4c16-9fae-00e9ced664a1"
|
||||
},
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
@ -869,8 +1000,8 @@
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "Qbittorrent",
|
||||
"uid": "eKyTETFMk",
|
||||
"title": "Qb",
|
||||
"uid": "eKyTETFMj",
|
||||
"version": 1,
|
||||
"weekStart": ""
|
||||
}
|
||||
}
|
@ -85,20 +85,22 @@ class QbittorrentMetricsCollector:
|
||||
"""
|
||||
Returns metrics about the state of the qbittorrent server.
|
||||
"""
|
||||
response: dict[str, Any] = {}
|
||||
maindata: dict[str, Any] = {}
|
||||
version: str = ""
|
||||
|
||||
# Fetch data from API
|
||||
try:
|
||||
response = self.client.transfer.info
|
||||
maindata = self.client.sync_maindata()
|
||||
version = self.client.app.version
|
||||
except Exception as e:
|
||||
logger.error(f"Couldn't get server info: {e}")
|
||||
|
||||
server_state = maindata.get('server_state', {})
|
||||
|
||||
return [
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_up",
|
||||
value=bool(response),
|
||||
value=bool(server_state),
|
||||
labels={"version": version},
|
||||
help_text=(
|
||||
"Whether the qBittorrent server is answering requests from this"
|
||||
@ -107,7 +109,7 @@ class QbittorrentMetricsCollector:
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_connected",
|
||||
value=response.get("connection_status", "") == "connected",
|
||||
value=server_state.get("connection_status", "") == "connected",
|
||||
labels={}, # no labels in the example
|
||||
help_text=(
|
||||
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||
@ -116,7 +118,7 @@ class QbittorrentMetricsCollector:
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_firewalled",
|
||||
value=response.get("connection_status", "") == "firewalled",
|
||||
value=server_state.get("connection_status", "") == "firewalled",
|
||||
labels={}, # no labels in the example
|
||||
help_text=(
|
||||
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||
@ -125,24 +127,38 @@ class QbittorrentMetricsCollector:
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_dht_nodes",
|
||||
value=response.get("dht_nodes", 0),
|
||||
value=server_state.get("dht_nodes", 0),
|
||||
labels={}, # no labels in the example
|
||||
help_text="Number of DHT nodes connected to.",
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_dl_info_data",
|
||||
value=response.get("dl_info_data", 0),
|
||||
value=server_state.get("dl_info_data", 0),
|
||||
labels={}, # no labels in the example
|
||||
help_text="Data downloaded since the server started, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_up_info_data",
|
||||
value=response.get("up_info_data", 0),
|
||||
value=server_state.get("up_info_data", 0),
|
||||
labels={}, # no labels in the example
|
||||
help_text="Data uploaded since the server started, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_alltime_dl",
|
||||
value=server_state.get("alltime_dl", 0),
|
||||
labels={}, # no labels in the example
|
||||
help_text="Total data downloaded, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
Metric(
|
||||
name=f"{self.config['metrics_prefix']}_alltime_ul",
|
||||
value=server_state.get("alltime_ul", 0),
|
||||
labels={}, # no labels in the example
|
||||
help_text="Total data uploaded, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
]
|
||||
|
||||
def _fetch_categories(self) -> dict:
|
||||
|
@ -270,6 +270,20 @@ class TestQbittorrentMetricsCollector(unittest.TestCase):
|
||||
help_text="Data uploaded since the server started, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_alltime_dl",
|
||||
value=0,
|
||||
labels={}, # no labels in the example
|
||||
help_text="Total data downloaded, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_alltime_ul",
|
||||
value=0,
|
||||
labels={}, # no labels in the example
|
||||
help_text="Total data uploaded, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
]
|
||||
|
||||
metrics = self.collector._get_qbittorrent_status_metrics()
|
||||
|
Loading…
x
Reference in New Issue
Block a user