diff --git a/.claude/settings.local.json b/.claude/settings.local.json index bf43197..607114e 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -2,7 +2,9 @@ "permissions": { "allow": [ "Bash(mcquack --help:*)", - "Bash(tea help:*)" + "Bash(tea help:*)", + "Bash(git add:*)", + "Bash(git commit:*)" ] } } diff --git a/ansible/playbooks/indri.yml b/ansible/playbooks/indri.yml index 8e750c2..d6cf954 100644 --- a/ansible/playbooks/indri.yml +++ b/ansible/playbooks/indri.yml @@ -2,12 +2,16 @@ - name: Configure indri hosts: indri roles: + - role: node_exporter + tags: node_exporter - role: prometheus tags: prometheus - role: grafana tags: grafana - role: transmission tags: transmission + - role: transmission_metrics + tags: transmission_metrics - role: kiwix tags: kiwix - role: borgmatic diff --git a/ansible/roles/grafana/files/dashboards/transmission.json b/ansible/roles/grafana/files/dashboards/transmission.json new file mode 100644 index 0000000..7d1b28c --- /dev/null +++ b/ansible/roles/grafana/files/dashboards/transmission.json @@ -0,0 +1,592 @@ +{ + "annotations": { + "list": [] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "red", "value": null}, + {"color": "green", "value": 1} + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": {"h": 4, "w": 4, "x": 0, "y": 0}, + "id": 1, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_up", + "refId": "A" + } + ], + "title": "Transmission Status", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "green", "value": null} + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": {"h": 4, "w": 4, "x": 4, "y": 0}, + "id": 2, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_torrents_total", + "refId": "A" + } + ], + "title": "Total Torrents", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "blue", "value": null} + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": {"h": 4, "w": 4, "x": 8, "y": 0}, + "id": 3, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_torrents_active", + "refId": "A" + } + ], + "title": "Active Torrents", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "orange", "value": null} + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": {"h": 4, "w": 4, "x": 12, "y": 0}, + "id": 4, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_torrents_paused", + "refId": "A" + } + ], + "title": "Paused Torrents", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "green", "value": null} + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": {"h": 4, "w": 4, "x": 16, "y": 0}, + "id": 5, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_downloaded_bytes_total", + "refId": "A" + } + ], + "title": "Total Downloaded", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "purple", "value": null} + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": {"h": 4, "w": 4, "x": 20, "y": 0}, + "id": 6, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_uploaded_bytes_total", + "refId": "A" + } + ], + "title": "Total Uploaded", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "green", "value": null} + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": {"id": "byName", "options": "Download"}, + "properties": [ + {"id": "color", "value": {"fixedColor": "green", "mode": "fixed"}} + ] + }, + { + "matcher": {"id": "byName", "options": "Upload"}, + "properties": [ + {"id": "color", "value": {"fixedColor": "blue", "mode": "fixed"}} + ] + } + ] + }, + "gridPos": {"h": 8, "w": 12, "x": 0, "y": 4}, + "id": 7, + "options": { + "legend": { + "calcs": ["mean", "max"], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_download_speed_bytes", + "legendFormat": "Download", + "refId": "A" + }, + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_upload_speed_bytes", + "legendFormat": "Upload", + "refId": "B" + } + ], + "title": "Transfer Speed", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "green", "value": null} + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": {"h": 8, "w": 12, "x": 12, "y": 4}, + "id": 8, + "options": { + "legend": { + "calcs": ["mean", "max"], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_torrents_total", + "legendFormat": "Total", + "refId": "A" + }, + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_torrents_active", + "legendFormat": "Active", + "refId": "B" + }, + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "transmission_torrents_paused", + "legendFormat": "Paused", + "refId": "C" + } + ], + "title": "Torrent Count", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + {"color": "green", "value": null} + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": {"id": "byName", "options": "Download Rate"}, + "properties": [ + {"id": "color", "value": {"fixedColor": "green", "mode": "fixed"}} + ] + }, + { + "matcher": {"id": "byName", "options": "Upload Rate"}, + "properties": [ + {"id": "color", "value": {"fixedColor": "blue", "mode": "fixed"}} + ] + } + ] + }, + "gridPos": {"h": 8, "w": 24, "x": 0, "y": 12}, + "id": 9, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "right", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "10.0.0", + "targets": [ + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "rate(transmission_downloaded_bytes_total[5m])", + "legendFormat": "Download Rate", + "refId": "A" + }, + { + "datasource": {"type": "prometheus", "uid": "prometheus"}, + "expr": "rate(transmission_uploaded_bytes_total[5m])", + "legendFormat": "Upload Rate", + "refId": "B" + } + ], + "title": "Cumulative Transfer Rate (5m avg)", + "type": "timeseries" + } + ], + "refresh": "30s", + "schemaVersion": 38, + "tags": ["transmission", "bittorrent"], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Transmission", + "uid": "transmission", + "version": 1, + "weekStart": "" +} diff --git a/ansible/roles/grafana/tasks/main.yml b/ansible/roles/grafana/tasks/main.yml index 78c726a..7887487 100644 --- a/ansible/roles/grafana/tasks/main.yml +++ b/ansible/roles/grafana/tasks/main.yml @@ -28,6 +28,20 @@ mode: '0644' notify: restart grafana +- name: Deploy grafana dashboards provider config + ansible.builtin.template: + src: dashboards.yaml.j2 + dest: /opt/homebrew/etc/grafana/provisioning/dashboards/default.yaml + mode: '0644' + notify: restart grafana + +- name: Deploy grafana dashboard JSON files + ansible.builtin.copy: + src: "dashboards/" + dest: /opt/homebrew/etc/grafana/provisioning/dashboards/ + mode: '0644' + notify: restart grafana + - name: Ensure grafana service is started ansible.builtin.command: brew services start grafana register: brew_start diff --git a/ansible/roles/grafana/templates/dashboards.yaml.j2 b/ansible/roles/grafana/templates/dashboards.yaml.j2 new file mode 100644 index 0000000..8be0a0d --- /dev/null +++ b/ansible/roles/grafana/templates/dashboards.yaml.j2 @@ -0,0 +1,12 @@ +# {{ ansible_managed }} +apiVersion: 1 + +providers: + - name: 'default' + orgId: 1 + folder: '' + type: file + disableDeletion: false + editable: true + options: + path: /opt/homebrew/etc/grafana/provisioning/dashboards diff --git a/ansible/roles/node_exporter/defaults/main.yml b/ansible/roles/node_exporter/defaults/main.yml new file mode 100644 index 0000000..a8f3e63 --- /dev/null +++ b/ansible/roles/node_exporter/defaults/main.yml @@ -0,0 +1,2 @@ +--- +node_exporter_textfile_dir: /opt/homebrew/var/node_exporter/textfile diff --git a/ansible/roles/node_exporter/handlers/main.yml b/ansible/roles/node_exporter/handlers/main.yml new file mode 100644 index 0000000..d2f9d11 --- /dev/null +++ b/ansible/roles/node_exporter/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart node_exporter + ansible.builtin.command: brew services restart node_exporter + listen: restart node_exporter diff --git a/ansible/roles/node_exporter/tasks/main.yml b/ansible/roles/node_exporter/tasks/main.yml new file mode 100644 index 0000000..dd1bbae --- /dev/null +++ b/ansible/roles/node_exporter/tasks/main.yml @@ -0,0 +1,22 @@ +--- +# Note: node_exporter is installed via homebrew manually. +# This role manages the args file to enable textfile collector. + +- name: Create textfile collector directory + ansible.builtin.file: + path: "{{ node_exporter_textfile_dir }}" + state: directory + mode: '0755' + +- name: Configure node_exporter args + ansible.builtin.template: + src: node_exporter.args.j2 + dest: /opt/homebrew/etc/node_exporter.args + mode: '0644' + notify: restart node_exporter + +- name: Ensure node_exporter service is started + ansible.builtin.command: brew services start node_exporter + register: brew_start + changed_when: "'Successfully started' in brew_start.stdout" + failed_when: false diff --git a/ansible/roles/node_exporter/templates/node_exporter.args.j2 b/ansible/roles/node_exporter/templates/node_exporter.args.j2 new file mode 100644 index 0000000..be763d0 --- /dev/null +++ b/ansible/roles/node_exporter/templates/node_exporter.args.j2 @@ -0,0 +1 @@ +--collector.textfile.directory={{ node_exporter_textfile_dir }} diff --git a/ansible/roles/transmission_metrics/defaults/main.yml b/ansible/roles/transmission_metrics/defaults/main.yml new file mode 100644 index 0000000..189c24d --- /dev/null +++ b/ansible/roles/transmission_metrics/defaults/main.yml @@ -0,0 +1,7 @@ +--- +transmission_rpc_host: 127.0.0.1 +transmission_rpc_port: 9091 +transmission_metrics_dir: /opt/homebrew/var/node_exporter/textfile +transmission_metrics_script: /opt/homebrew/bin/transmission-metrics +transmission_metrics_interval: 60 # seconds between metric collection +transmission_log_dir: /opt/homebrew/var/log diff --git a/ansible/roles/transmission_metrics/handlers/main.yml b/ansible/roles/transmission_metrics/handlers/main.yml new file mode 100644 index 0000000..c95a96d --- /dev/null +++ b/ansible/roles/transmission_metrics/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: reload transmission-metrics + ansible.builtin.shell: | + launchctl unload ~/Library/LaunchAgents/mcquack.eblume.transmission-metrics.plist 2>/dev/null || true + launchctl load ~/Library/LaunchAgents/mcquack.eblume.transmission-metrics.plist diff --git a/ansible/roles/transmission_metrics/meta/main.yml b/ansible/roles/transmission_metrics/meta/main.yml new file mode 100644 index 0000000..56b611e --- /dev/null +++ b/ansible/roles/transmission_metrics/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - role: node_exporter + - role: transmission diff --git a/ansible/roles/transmission_metrics/tasks/main.yml b/ansible/roles/transmission_metrics/tasks/main.yml new file mode 100644 index 0000000..b17f2cd --- /dev/null +++ b/ansible/roles/transmission_metrics/tasks/main.yml @@ -0,0 +1,20 @@ +--- +- name: Deploy transmission metrics collection script + ansible.builtin.template: + src: transmission-metrics.sh.j2 + dest: "{{ transmission_metrics_script }}" + mode: '0755' + notify: reload transmission-metrics + +- name: Deploy transmission-metrics LaunchAgent plist + ansible.builtin.template: + src: transmission-metrics.plist.j2 + dest: ~/Library/LaunchAgents/mcquack.eblume.transmission-metrics.plist + mode: '0644' + notify: reload transmission-metrics + +- name: Ensure transmission-metrics LaunchAgent is loaded + ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.transmission-metrics.plist + register: launchctl_load + changed_when: launchctl_load.rc == 0 + failed_when: false diff --git a/ansible/roles/transmission_metrics/templates/transmission-metrics.plist.j2 b/ansible/roles/transmission_metrics/templates/transmission-metrics.plist.j2 new file mode 100644 index 0000000..3761007 --- /dev/null +++ b/ansible/roles/transmission_metrics/templates/transmission-metrics.plist.j2 @@ -0,0 +1,26 @@ + + + + + + Label + mcquack.eblume.transmission-metrics + EnvironmentVariables + + PATH + /opt/homebrew/bin:/usr/bin:/bin + + ProgramArguments + + {{ transmission_metrics_script }} + + StartInterval + {{ transmission_metrics_interval }} + RunAtLoad + + StandardErrorPath + {{ transmission_log_dir }}/transmission-metrics.err.log + StandardOutPath + {{ transmission_log_dir }}/transmission-metrics.out.log + + diff --git a/ansible/roles/transmission_metrics/templates/transmission-metrics.sh.j2 b/ansible/roles/transmission_metrics/templates/transmission-metrics.sh.j2 new file mode 100644 index 0000000..9929eb5 --- /dev/null +++ b/ansible/roles/transmission_metrics/templates/transmission-metrics.sh.j2 @@ -0,0 +1,98 @@ +#!/bin/bash +# {{ ansible_managed }} +# Collects transmission-daemon metrics for node_exporter textfile collector + +set -euo pipefail + +RPC_URL="http://{{ transmission_rpc_host }}:{{ transmission_rpc_port }}/transmission/rpc" +OUTPUT_FILE="{{ transmission_metrics_dir }}/transmission.prom" +TEMP_FILE="${OUTPUT_FILE}.tmp" + +# Get session ID (required for transmission RPC) +get_session_id() { + curl -s -I "$RPC_URL" 2>/dev/null | grep -i 'X-Transmission-Session-Id' | awk '{print $2}' | tr -d '\r' +} + +# Make RPC request +rpc_request() { + local method="$1" + local session_id + session_id=$(get_session_id) + + if [ -z "$session_id" ]; then + echo "Failed to get session ID" >&2 + return 1 + fi + + curl -s "$RPC_URL" \ + -H "X-Transmission-Session-Id: $session_id" \ + -H "Content-Type: application/json" \ + -d "{\"method\": \"$method\"}" +} + +# Get session stats +session_stats=$(rpc_request "session-stats") + +if [ -z "$session_stats" ] || ! echo "$session_stats" | grep -q '"result":"success"'; then + echo "Failed to get session stats" >&2 + exit 1 +fi + +# Extract values using grep/sed (avoiding jq dependency) +extract_json_int() { + echo "$1" | grep -o "\"$2\":[0-9]*" | head -1 | sed "s/\"$2\"://" +} + +# Session stats +download_speed=$(extract_json_int "$session_stats" "downloadSpeed") +upload_speed=$(extract_json_int "$session_stats" "uploadSpeed") +torrents_active=$(extract_json_int "$session_stats" "activeTorrentCount") +torrents_paused=$(extract_json_int "$session_stats" "pausedTorrentCount") +torrents_total=$(extract_json_int "$session_stats" "torrentCount") + +# Cumulative stats +downloaded_bytes=$(echo "$session_stats" | grep -o '"cumulative-stats":{[^}]*}' | grep -o '"downloadedBytes":[0-9]*' | sed 's/"downloadedBytes"://') +uploaded_bytes=$(echo "$session_stats" | grep -o '"cumulative-stats":{[^}]*}' | grep -o '"uploadedBytes":[0-9]*' | sed 's/"uploadedBytes"://') +seconds_active=$(echo "$session_stats" | grep -o '"cumulative-stats":{[^}]*}' | grep -o '"secondsActive":[0-9]*' | sed 's/"secondsActive"://') + +# Write metrics +cat > "$TEMP_FILE" << EOF +# HELP transmission_download_speed_bytes Current download speed in bytes per second +# TYPE transmission_download_speed_bytes gauge +transmission_download_speed_bytes ${download_speed:-0} + +# HELP transmission_upload_speed_bytes Current upload speed in bytes per second +# TYPE transmission_upload_speed_bytes gauge +transmission_upload_speed_bytes ${upload_speed:-0} + +# HELP transmission_torrents_active Number of active torrents +# TYPE transmission_torrents_active gauge +transmission_torrents_active ${torrents_active:-0} + +# HELP transmission_torrents_paused Number of paused torrents +# TYPE transmission_torrents_paused gauge +transmission_torrents_paused ${torrents_paused:-0} + +# HELP transmission_torrents_total Total number of torrents +# TYPE transmission_torrents_total gauge +transmission_torrents_total ${torrents_total:-0} + +# HELP transmission_downloaded_bytes_total Total bytes downloaded (cumulative) +# TYPE transmission_downloaded_bytes_total counter +transmission_downloaded_bytes_total ${downloaded_bytes:-0} + +# HELP transmission_uploaded_bytes_total Total bytes uploaded (cumulative) +# TYPE transmission_uploaded_bytes_total counter +transmission_uploaded_bytes_total ${uploaded_bytes:-0} + +# HELP transmission_seconds_active_total Total seconds transmission has been active +# TYPE transmission_seconds_active_total counter +transmission_seconds_active_total ${seconds_active:-0} + +# HELP transmission_up Transmission daemon is up and responding +# TYPE transmission_up gauge +transmission_up 1 +EOF + +# Atomic move +mv "$TEMP_FILE" "$OUTPUT_FILE"