23 Commits
1.0.2 ... 1.1.0

Author SHA1 Message Date
Esteban Sánchez
ef12d46431 Create docker image on release 2020-10-24 10:40:20 +02:00
Esteban Sánchez
9a19f46b7e Release 1.1.0 2020-10-24 10:39:49 +02:00
Esteban Sánchez
a53c7ae08b Install from src and not pip package 2020-10-24 10:39:40 +02:00
Esteban Sanchez
17ebcb0834 Setup buildx 2020-10-24 10:30:21 +02:00
Esteban Sanchez
7016e3de2b Set tags from a list 2020-10-24 10:13:39 +02:00
Esteban Sanchez
af51fd5b67 Set labels 2020-10-23 22:07:01 +02:00
Esteban Sanchez
82151b1d82 Setting tag 2020-10-23 22:04:55 +02:00
Esteban Sanchez
b6e3131929 Push to docker hub 2020-10-23 22:04:10 +02:00
Esteban Sanchez
688fcc54cb Testing 2020-10-23 22:02:24 +02:00
Esteban Sanchez
bc79a0dd52 Create pythonpublish.yml 2020-10-23 21:56:46 +02:00
Esteban Sanchez
af732087e8 Fixed version 2020-10-23 21:51:55 +02:00
Esteban Sanchez
15130f1c95 Added action to push to dockerhub 2020-10-23 21:49:29 +02:00
Esteban Sanchez
53dc38f796 Merge pull request #1 from Gabisonfire/master
Added the ability to include uncategorized torrents.
2020-10-22 23:11:35 +02:00
Gab
3bfc3f0673 Removed unused config 2020-10-21 18:58:17 -04:00
Esteban Sánchez
eee65ec84e Allow setting a metrics prefix 2020-10-21 08:05:51 +02:00
Gab
b4aefff06d Changed readme 2020-10-20 11:57:33 -04:00
Gab
baf14d495c Removed now useless logging message 2020-10-20 11:46:50 -04:00
Gab
003297ecfd Removed uncategorized from config 2020-10-20 11:45:48 -04:00
Gab
2497249b8c Fixed indentation 2020-10-20 02:10:39 -04:00
Gab
9e9f4a9ce4 Added scraping for uncategorized torrents 2020-10-20 02:10:04 -04:00
Gab
40d9bb964e Added scraping for uncategorized torrents 2020-10-20 02:05:17 -04:00
Esteban Sánchez
0b3fb04728 Removed unneded code and return earlier 2020-10-01 10:14:56 +02:00
Esteban Sánchez
13a52c40f2 New version 2020-09-29 13:47:32 +02:00
6 changed files with 80 additions and 22 deletions

29
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: Docker
on:
push:
branches: [ master ]
release:
types: [ created ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push docker
uses: docker/build-push-action@v2
with:
push: true
tags: esanchezm/prometheus-qbittorrent-exporter:latest,esanchezm/prometheus-qbittorrent-exporter:$GITHUB_REF

26
.github/workflows/pythonpublish.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Upload Python Package
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.6'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
twine upload dist/*

View File

@@ -5,7 +5,9 @@ RUN apk add --update --no-cache \
python3
# Install package
RUN pip3 install prometheus-qbittorrent-exporter==1.0.1
WORKDIR /code
COPY . .
RUN pip3 install .
ENV QBITTORRENT_HOST=""
ENV QBITTORRENT_PORT=""

View File

@@ -33,22 +33,23 @@ The application reads configuration using environment variables:
| `QBITTORRENT_PASS` | `""` | qbittorrent password |
| `EXPORTER_PORT` | `8000` | Exporter listening port |
| `EXPORTER_LOG_LEVEL` | `INFO` | Log level. One of: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` |
| `METRICS_PREFIX` | `qbittorrent` | Prefix to add to all the metrics |
## Metrics
These are the metrics this program exports:
These are the metrics this program exports, assuming the `METRICS_PREFIX` is `qbittorrent`:
| Metric name | Type | Description |
| --------------------------------------------------- | -------- | ---------------- |
| `qbittorrent_up` | gauge | Whether if the qBittorrent server is answering requests from this exporter. A `version` label with the server version is added |
| `connected` | gauge | Whether if the qBittorrent server is connected to the Bittorrent network. |
| `firewalled` | gauge | Whether if the qBittorrent server is connected to the Bittorrent network but is behind a firewall. |
| `dht_nodes` | gauge | Number of DHT nodes connected to |
| `dl_info_data` | counter | Data downloaded since the server started, in bytes |
| `up_info_data` | counter | Data uploaded since the server started, in bytes |
| `torrents_count` | gauge | Number of torrents for each `category` and `status`. Example: `torrents_count{category="movies",status="downloading"}`|
| `qbittorrent_connected` | gauge | Whether if the qBittorrent server is connected to the Bittorrent network. |
| `qbittorrent_firewalled` | gauge | Whether if the qBittorrent server is connected to the Bittorrent network but is behind a firewall. |
| `qbittorrent_dht_nodes` | gauge | Number of DHT nodes connected to |
| `qbittorrent_dl_info_data` | counter | Data downloaded since the server started, in bytes |
| `qbittorrent_up_info_data` | counter | Data uploaded since the server started, in bytes |
| `qbittorrent_torrents_count` | gauge | Number of torrents for each `category` and `status`. Example: `qbittorrent_torrents_count{category="movies",status="downloading"}`|
## License

View File

@@ -3,6 +3,7 @@ import os
import sys
import signal
import faulthandler
from attrdict import AttrDict
from qbittorrentapi import Client, TorrentStates
from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, CounterMetricFamily, REGISTRY
@@ -77,34 +78,34 @@ class QbittorrentMetricsCollector():
return [
{
"name": "qbittorrent_up",
"name": f"{self.config['metrics_prefix']}_up",
"value": response is not None,
"labels": {"version": version},
"help": "Whether if server is alive or not",
},
{
"name": "connected",
"name": f"{self.config['metrics_prefix']}_connected",
"value": response.get("connection_status", "") == "connected",
"help": "Whether if server is connected or not",
},
{
"name": "firewalled",
"name": f"{self.config['metrics_prefix']}_firewalled",
"value": response.get("connection_status", "") == "firewalled",
"help": "Whether if server is under a firewall or not",
},
{
"name": "dht_nodes",
"name": f"{self.config['metrics_prefix']}_dht_nodes",
"value": response.get("dht_nodes", 0),
"help": "DHT nodes connected to",
},
{
"name": "dl_info_data",
"name": f"{self.config['metrics_prefix']}_dl_info_data",
"value": response.get("dl_info_data", 0),
"help": "Data downloaded this session (bytes)",
"type": "counter"
},
{
"name": "up_info_data",
"name": f"{self.config['metrics_prefix']}_up_info_data",
"value": response.get("up_info_data", 0),
"help": "Data uploaded this session (bytes)",
"type": "counter"
@@ -116,17 +117,15 @@ class QbittorrentMetricsCollector():
categories = self.client.torrent_categories.categories
except Exception as e:
logger.error(f"Couldn't fetch categories: {e}")
categories = None
if not categories:
return []
if not self.torrents:
return []
metrics = []
categories.Uncategorized = AttrDict({'name': 'Uncategorized', 'savePath': ''})
for category in categories:
category_torrents = [t for t in self.torrents if t['category'] == category]
category_torrents = [t for t in self.torrents if t['category'] == category or (category == "Uncategorized" and t['category'] == "")]
for status in self.TORRENT_STATUSES:
status_prop = f"is_{status}"
@@ -134,7 +133,7 @@ class QbittorrentMetricsCollector():
t for t in category_torrents if getattr(TorrentStates, status_prop).fget(TorrentStates(t['state']))
]
metrics.append({
"name": "torrents_count",
"name": f"{self.config['metrics_prefix']}_torrents_count",
"value": len(status_torrents),
"labels": {
"status": status,
@@ -169,7 +168,8 @@ def main():
"username": os.environ.get("QBITTORRENT_USER", ""),
"password": os.environ.get("QBITTORRENT_PASS", ""),
"exporter_port": int(os.environ.get("EXPORTER_PORT", "8000")),
"log_level": os.environ.get("EXPORTER_LOG_LEVEL", "INFO")
"log_level": os.environ.get("EXPORTER_LOG_LEVEL", "INFO"),
"metrics_prefix": os.environ.get("METRICS_PREFIX", "qbittorrent"),
}
# Register signal handler

View File

@@ -6,14 +6,14 @@ with open("README.md", "r") as fh:
setup(
name='prometheus-qbittorrent-exporter',
packages=['qbittorrent_exporter'],
version='1.0.1',
version='1.1.0',
long_description=long_description,
long_description_content_type="text/markdown",
description='Prometheus exporter for qbittorrent',
author='Esteban Sanchez',
author_email='esteban.sanchez@gmail.com',
url='https://github.com/esanchezm/prometheus-qbittorrent-exporter',
download_url='https://github.com/esanchezm/prometheus-qbittorrent-exporter/archive/1.0.1.tar.gz',
download_url='https://github.com/esanchezm/prometheus-qbittorrent-exporter/archive/1.1.0.tar.gz',
keywords=['prometheus', 'qbittorrent'],
classifiers=[],
python_requires='>=3',