Add transmission dashboard to grafana #5

Merged
eblume merged 7 commits from feature/transmission-dashboard into main 2026-01-14 14:19:12 -08:00
20 changed files with 952 additions and 9 deletions

View file

@ -2,7 +2,9 @@
"permissions": {
"allow": [
"Bash(mcquack --help:*)",
"Bash(tea help:*)"
"Bash(tea help:*)",
"Bash(git add:*)",
"Bash(git commit:*)"
]
}
}

View file

@ -86,10 +86,10 @@ After creating a PR, run `open <pr-url>` to open it in the browser (Claude Code'
ansible-galaxy collection install -r ansible/requirements.yml
# Dry-run before committing changes
ansible-playbook ansible/playbooks/indri.yml --check --diff
mise run provision-indri -- --check --diff
# Apply changes
ansible-playbook ansible/playbooks/indri.yml
mise run provision-indri
```
## Service Health Checks

View file

@ -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

View file

@ -9,8 +9,13 @@
mode: '0644'
notify: reload borgmatic
- name: Ensure borgmatic LaunchAgent is loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
register: launchctl_load
changed_when: launchctl_load.rc == 0
- name: Check if borgmatic LaunchAgent is loaded
ansible.builtin.command: launchctl list mcquack.eblume.borgmatic
register: launchctl_check
changed_when: false
failed_when: false
- name: Load borgmatic LaunchAgent if not loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.borgmatic.plist
when: launchctl_check.rc != 0
failed_when: false

View file

@ -0,0 +1,672 @@
{
"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"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "fixed",
"fixedColor": "semi-dark-purple"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 20,
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 2,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{"color": "green", "value": null}
]
},
"unit": "decbytes"
},
"overrides": []
},
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 20},
"id": 10,
"options": {
"legend": {
"calcs": ["lastNotNull", "min", "max"],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.0.0",
"targets": [
{
"datasource": {"type": "prometheus", "uid": "prometheus"},
"expr": "transmission_torrents_size_bytes",
"legendFormat": "Total Torrent Size",
"refId": "A"
}
],
"title": "Total Torrent Size",
"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": ""
}

View file

@ -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

View file

@ -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

View file

@ -178,8 +178,13 @@
mode: '0644'
notify: restart kiwix-serve
- name: Ensure kiwix-serve is loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.kiwix-serve.plist
register: launchctl_load
changed_when: launchctl_load.rc == 0
- name: Check if kiwix-serve LaunchAgent is loaded
ansible.builtin.command: launchctl list mcquack.eblume.kiwix-serve
register: launchctl_check
changed_when: false
failed_when: false
- name: Load kiwix-serve LaunchAgent if not loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.kiwix-serve.plist
when: launchctl_check.rc != 0
failed_when: false

View file

@ -0,0 +1,2 @@
---
node_exporter_textfile_dir: /opt/homebrew/var/node_exporter/textfile

View file

@ -0,0 +1,4 @@
---
- name: restart node_exporter
ansible.builtin.command: brew services restart node_exporter
listen: restart node_exporter

View file

@ -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

View file

@ -0,0 +1 @@
--collector.textfile.directory={{ node_exporter_textfile_dir }}

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,4 @@
---
dependencies:
- role: node_exporter
- role: transmission

View file

@ -0,0 +1,25 @@
---
- 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: Check if transmission-metrics LaunchAgent is loaded
ansible.builtin.command: launchctl list mcquack.eblume.transmission-metrics
register: launchctl_check
changed_when: false
failed_when: false
- name: Load transmission-metrics LaunchAgent if not loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.transmission-metrics.plist
when: launchctl_check.rc != 0
failed_when: false

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- {{ ansible_managed }} -->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>mcquack.eblume.transmission-metrics</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/bin:/usr/bin:/bin</string>
</dict>
<key>ProgramArguments</key>
<array>
<string>{{ transmission_metrics_script }}</string>
</array>
<key>StartInterval</key>
<integer>{{ transmission_metrics_interval }}</integer>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>{{ transmission_log_dir }}/transmission-metrics.err.log</string>
<key>StandardOutPath</key>
<string>{{ transmission_log_dir }}/transmission-metrics.out.log</string>
</dict>
</plist>

View file

@ -0,0 +1,120 @@
#!/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)
# Note: transmission doesn't support HEAD requests, so we make a request and parse
# the 409 response headers. We use sed to stop at the blank line (which has \r) before body.
get_session_id() {
curl -s -i "$RPC_URL" 2>/dev/null | sed '/^\r$/q' | grep -i '^X-Transmission-Session-Id:' | awk '{print $2}' | tr -d '\r'
}
# Make RPC request
rpc_request() {
local method="$1"
local args="${2:-}"
local session_id
session_id=$(get_session_id)
if [ -z "$session_id" ]; then
echo "Failed to get session ID" >&2
return 1
fi
local payload
if [ -n "$args" ]; then
payload="{\"method\": \"$method\", \"arguments\": $args}"
else
payload="{\"method\": \"$method\"}"
fi
curl -s "$RPC_URL" \
-H "X-Transmission-Session-Id: $session_id" \
-H "Content-Type: application/json" \
-d "$payload"
}
# 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"://')
# Get total size of all torrents
torrent_info=$(rpc_request "torrent-get" '{"fields": ["totalSize"]}')
total_size_bytes=0
if echo "$torrent_info" | grep -q '"result":"success"'; then
# Sum all totalSize values
total_size_bytes=$(echo "$torrent_info" | grep -o '"totalSize":[0-9]*' | sed 's/"totalSize"://' | awk '{sum += $1} END {print sum}')
fi
# 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_torrents_size_bytes Total size of all torrents in bytes
# TYPE transmission_torrents_size_bytes gauge
transmission_torrents_size_bytes ${total_size_bytes:-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"

View file

@ -45,7 +45,9 @@ echo ""
echo "Local services (via launchctl/brew services):"
check_service "prometheus" "ssh indri 'brew services list | grep prometheus | grep started'"
check_service "grafana" "ssh indri 'brew services list | grep grafana | grep started'"
check_service "node_exporter" "ssh indri 'brew services list | grep node_exporter | grep started'"
check_service "transmission" "ssh indri 'brew services list | grep transmission | grep started'"
check_service "transmission-metrics" "ssh indri 'launchctl list | grep transmission-metrics | grep -v \"^-\"'"
check_service "kiwix-serve" "ssh indri 'launchctl list | grep kiwix | grep -v \"^-\"'"
check_service "forgejo" "ssh indri 'brew services list | grep forgejo | grep started'"
@ -57,6 +59,8 @@ check_http "Kiwix" "http://indri:5501/"
check_http "Forgejo" "http://indri:3001/"
# Transmission RPC is localhost-only by design, check via SSH
check_service "Transmission RPC" "ssh indri 'curl -sf http://127.0.0.1:9091/transmission/rpc'"
# Check that transmission metrics are being collected
check_service "Transmission metrics" "ssh indri 'test -f /opt/homebrew/var/node_exporter/textfile/transmission.prom'"
echo ""
if [ $FAILED -eq 0 ]; then

9
mise-tasks/provision-indri Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
#MISE description="Run ansible playbook to provision indri"
set -euo pipefail
export MISE_TASK_OUTPUT=interleave
cd ansible
ansible-playbook playbooks/indri.yml "$@"