mirror of
https://github.com/NohamR/prometheus-qbittorrent-exporter.git
synced 2026-01-09 07:38:18 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75db331c55 | ||
|
|
d5c7cbc4a9 | ||
|
|
234a4cfffa | ||
|
|
4ad22a60da | ||
|
|
6c87b8eff9 | ||
|
|
e2a8508cae | ||
|
|
a6a4129daf | ||
|
|
723872bc15 | ||
|
|
cb78dd1fb7 | ||
|
|
8e08565d6e | ||
|
|
56a2792c2e |
59
.github/workflows/docker.yml
vendored
59
.github/workflows/docker.yml
vendored
@@ -11,52 +11,63 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Extract branch name
|
||||
shell: bash
|
||||
run: |
|
||||
tag=${GITHUB_REF#refs/tags/}
|
||||
tag=${tag#refs/heads/}
|
||||
if echo $tag | grep -q -E "[0-9]+\.[0-9]+\.[0-9]+"; then
|
||||
tag="v$tag"
|
||||
fi
|
||||
echo "##[set-output name=tag;]$tag"
|
||||
id: extract_branch
|
||||
- name: Docker hub meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
flavor: |
|
||||
latest=true
|
||||
tags: |
|
||||
type=semver,pattern=v{{version}}
|
||||
type=ref,event=branch
|
||||
type=sha
|
||||
images: ${{ github.actor }}/prometheus-qbittorrent-exporter
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push docker to DockerHub
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64,linux/386
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: GHCR Docker meta
|
||||
id: metaghcr
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
flavor: |
|
||||
latest=true
|
||||
tags: |
|
||||
${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest
|
||||
${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }}
|
||||
type=semver,pattern=v{{version}}
|
||||
type=ref,event=branch
|
||||
type=sha
|
||||
images: ghcr.io/${{ github.actor }}/prometheus-qbittorrent-exporter
|
||||
|
||||
- name: Login to Github Container Registry
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.GHCR_PERSONAL_TOKEN }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push docker to Github Container Registry
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64,linux/386
|
||||
tags: |
|
||||
ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest
|
||||
ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }}
|
||||
tags: ${{ steps.metaghcr.outputs.tags }}
|
||||
labels: ${{ steps.metaghcr.outputs.labels }}
|
||||
|
||||
2
.github/workflows/pythonpublish.yml
vendored
2
.github/workflows/pythonpublish.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.6'
|
||||
python-version: '3.11'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
A prometheus exporter for qBitorrent. Get metrics from a server and offers them in a prometheus format.
|
||||
|
||||
     [](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
||||
      [](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
||||
|
||||
## How to use it
|
||||
|
||||
|
||||
@@ -217,3 +217,60 @@ class TestQbittorrentMetricsCollector(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
metric.help_text, "Number of torrents in status under category "
|
||||
)
|
||||
|
||||
def test_get_qbittorrent_status_metrics(self):
|
||||
self.collector.client.transfer.info = {"connection_status": "connected"}
|
||||
self.collector.client.app.version = "1.2.3"
|
||||
|
||||
expected_metrics = [
|
||||
Metric(
|
||||
name="qbittorrent_up",
|
||||
value=True,
|
||||
labels={"version": "1.2.3"},
|
||||
help_text=(
|
||||
"Whether the qBittorrent server is answering requests from this"
|
||||
" exporter. A `version` label with the server version is added."
|
||||
),
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_connected",
|
||||
value=True,
|
||||
labels={},
|
||||
help_text=(
|
||||
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||
" network."
|
||||
),
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_firewalled",
|
||||
value=False,
|
||||
labels={},
|
||||
help_text=(
|
||||
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||
" network but is behind a firewall."
|
||||
),
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_dht_nodes",
|
||||
value=0,
|
||||
labels={},
|
||||
help_text="Number of DHT nodes connected to.",
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_dl_info_data",
|
||||
value=0,
|
||||
labels={},
|
||||
help_text="Data downloaded since the server started, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
Metric(
|
||||
name="qbittorrent_up_info_data",
|
||||
value=0,
|
||||
labels={},
|
||||
help_text="Data uploaded since the server started, in bytes.",
|
||||
metric_type=MetricType.COUNTER,
|
||||
),
|
||||
]
|
||||
|
||||
metrics = self.collector._get_qbittorrent_status_metrics()
|
||||
self.assertEqual(metrics, expected_metrics)
|
||||
|
||||
Reference in New Issue
Block a user