From 6e369c3656af1400c905b17ad34e7150be3cb31d Mon Sep 17 00:00:00 2001 From: Lucas Serverhost Date: Sat, 24 Oct 2026 15:09:36 +0200 Subject: [PATCH] add qbittorrent to node_exporter --- .../node-exporter-pubip-docker-states.sh | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docker_compose/node-exporter-pubip-docker-states.sh b/docker_compose/node-exporter-pubip-docker-states.sh index e09c413..8adc9c7 100755 --- a/docker_compose/node-exporter-pubip-docker-states.sh +++ b/docker_compose/node-exporter-pubip-docker-states.sh @@ -20,10 +20,24 @@ fi done echo docker_container_number $DOCKER_CONTAINER_NUM + + docker ps -a --format '{{.Names}}' | grep -E '^qbittorrent' | while read -r qbit_host; do + IP_JSON=$(docker exec "$qbit_host" curl -fsSL http://ip-api.com/json) || continue + + IP=$(jq -r '.query' <<<"$IP_JSON") + COUNTRY=$(jq -r '.country' <<<"$IP_JSON") + CITY=$(jq -r '.city' <<<"$IP_JSON") + ISP=$(jq -r '.isp' <<<"$IP_JSON" | sed 's/"/\\"/g') + COUNTRYCODE=$(jq -r '.countryCode' <<<"$IP_JSON") + LAT=$(jq -r '.lat' <<<"$IP_JSON") + LON=$(jq -r '.lon' <<<"$IP_JSON") + + echo "public_ip_info{ip=\"$IP\",country=\"$COUNTRY\",city=\"$CITY\",isp=\"$ISP\",countrycode=\"$COUNTRYCODE\",lat=\"$LAT\",lon=\"$LON\",exported_host=\"$qbit_host\"} 1" + done + # Public IP information IP_JSON=$(curl -fsSL http://ip-api.com/json) - IP=$(jq -r '.query' <<< "$IP_JSON") COUNTRY=$(jq -r '.country' <<< "$IP_JSON") CITY=$(jq -r '.city' <<< "$IP_JSON") @@ -31,8 +45,8 @@ fi COUNTRYCODE=$(jq -r '.countryCode' <<< "$IP_JSON") LAT=$(jq -r '.lat' <<< "$IP_JSON") LON=$(jq -r '.lon' <<< "$IP_JSON") - - echo "public_ip_info{ip=\"$IP\",country=\"$COUNTRY\",city=\"$CITY\",isp=\"$ISP\",countrycode=\"$COUNTRYCODE\",lat=\"$LAT\",lon=\"$LON\"} 1" + + echo "public_ip_info{ip=\"$IP\",country=\"$COUNTRY\",city=\"$CITY\",isp=\"$ISP\",countrycode=\"$COUNTRYCODE\",lat=\"$LAT\",lon=\"$LON\",exported_host=\"$(hostname)\"} 1" echo "custom_metrics_last_update_timestamp_seconds $(date +%s)" } > "$OUT.$$"