Last active
June 24, 2023 17:58
-
-
Save droM4X/4cbc10994d586a29682b67cc00f2d342 to your computer and use it in GitHub Desktop.
Collectd - Qbittorrent stats + current speeds // Qbittorrent v4.1+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOSTNAME=${COLLECTD_HOSTNAME:-localhost}; | |
INTERVAL=${COLLECTD_INTERVAL:-60}; | |
while sleep "$INTERVAL" | |
do | |
for filter in active all downloading | |
do | |
url="http://localhost:8080/api/v2/torrents/info?filter=$filter" | |
count=$(curl -s $url | jq length) | |
echo "PUTVAL \"$HOSTNAME/exec-qbittorrent/gauge-$filter\" interval=$INTERVAL N:$count" | |
done | |
url="http://localhost:8080/api/v2/torrents/info?filter=active" | |
dlspeed=$(curl -s $url | jq '.[].dlspeed' | awk 'NF{sum+=$1} END {print sum}') | |
upspeed=$(curl -s $url | jq '.[].upspeed' | awk 'NF{sum+=$1} END {print sum}') | |
echo "PUTVAL \"$HOSTNAME/exec-qbittorrent-speeds/gauge-dlspeed\" interval=$INTERVAL N:$dlspeed" | |
echo "PUTVAL \"$HOSTNAME/exec-qbittorrent-speeds/gauge-upspeed\" interval=$INTERVAL N:$upspeed" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment