From 34d9f2475e8f885c157dcd16e49e79efbd59e6c0 Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Sun, 18 Jan 2026 14:44:46 -0800 Subject: [PATCH 1/2] Fix borgmatic-metrics script to use absolute paths The script was failing in LaunchAgent context because it used `mise x -- borg` which isn't available without homebrew in PATH. Changed to use absolute paths for borg and jq (/opt/homebrew/bin/). This fixes the Grafana dashboard showing "DOWN" for Repository Status and missing data points in the time series graphs. Co-Authored-By: Claude Opus 4.5 --- .../templates/borgmatic-metrics.sh.j2 | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ansible/roles/borgmatic_metrics/templates/borgmatic-metrics.sh.j2 b/ansible/roles/borgmatic_metrics/templates/borgmatic-metrics.sh.j2 index 99ce1ca..856cbe9 100644 --- a/ansible/roles/borgmatic_metrics/templates/borgmatic-metrics.sh.j2 +++ b/ansible/roles/borgmatic_metrics/templates/borgmatic-metrics.sh.j2 @@ -9,8 +9,9 @@ BORG_REPO="{{ borgmatic_metrics_repo }}" OUTPUT_FILE="{{ borgmatic_metrics_dir }}/borgmatic.prom" TEMP_FILE="${OUTPUT_FILE}.tmp" -# Check if borg is available via mise -BORG_CMD="mise x -- borg" +# Use absolute paths for LaunchAgent compatibility +BORG_CMD="/opt/homebrew/bin/borg" +JQ_CMD="/opt/homebrew/bin/jq" # Get repository info repo_json=$($BORG_CMD info --json "$BORG_REPO" 2>/dev/null) || { @@ -32,18 +33,18 @@ archives_json=$($BORG_CMD list --json "$BORG_REPO" 2>/dev/null) || { } # Extract repository stats -total_size=$(echo "$repo_json" | jq -r '.cache.stats.total_size') -total_csize=$(echo "$repo_json" | jq -r '.cache.stats.total_csize') -unique_size=$(echo "$repo_json" | jq -r '.cache.stats.unique_size') -unique_csize=$(echo "$repo_json" | jq -r '.cache.stats.unique_csize') -total_chunks=$(echo "$repo_json" | jq -r '.cache.stats.total_chunks') -unique_chunks=$(echo "$repo_json" | jq -r '.cache.stats.total_unique_chunks') +total_size=$(echo "$repo_json" | $JQ_CMD -r '.cache.stats.total_size') +total_csize=$(echo "$repo_json" | $JQ_CMD -r '.cache.stats.total_csize') +unique_size=$(echo "$repo_json" | $JQ_CMD -r '.cache.stats.unique_size') +unique_csize=$(echo "$repo_json" | $JQ_CMD -r '.cache.stats.unique_csize') +total_chunks=$(echo "$repo_json" | $JQ_CMD -r '.cache.stats.total_chunks') +unique_chunks=$(echo "$repo_json" | $JQ_CMD -r '.cache.stats.total_unique_chunks') # Count archives -archive_count=$(echo "$archives_json" | jq -r '.archives | length') +archive_count=$(echo "$archives_json" | $JQ_CMD -r '.archives | length') # Get last archive info -last_archive_name=$(echo "$archives_json" | jq -r '.archives[-1].name // empty') +last_archive_name=$(echo "$archives_json" | $JQ_CMD -r '.archives[-1].name // empty') if [ -n "$last_archive_name" ]; then # Get detailed info for the last archive @@ -53,13 +54,13 @@ if [ -n "$last_archive_name" ]; then } if [ -n "$last_archive_json" ]; then - last_original_size=$(echo "$last_archive_json" | jq -r '.archives[0].stats.original_size') - last_compressed_size=$(echo "$last_archive_json" | jq -r '.archives[0].stats.compressed_size') - last_deduplicated_size=$(echo "$last_archive_json" | jq -r '.archives[0].stats.deduplicated_size') - last_nfiles=$(echo "$last_archive_json" | jq -r '.archives[0].stats.nfiles') - last_start=$(echo "$last_archive_json" | jq -r '.archives[0].start') - last_end=$(echo "$last_archive_json" | jq -r '.archives[0].end') - last_duration=$(echo "$last_archive_json" | jq -r '.archives[0].duration') + last_original_size=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].stats.original_size') + last_compressed_size=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].stats.compressed_size') + last_deduplicated_size=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].stats.deduplicated_size') + last_nfiles=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].stats.nfiles') + last_start=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].start') + last_end=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].end') + last_duration=$(echo "$last_archive_json" | $JQ_CMD -r '.archives[0].duration') # Convert timestamp to unix epoch last_timestamp=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${last_start%.*}" "+%s" 2>/dev/null || echo "0") -- 2.50.1 (Apple Git-155) From ea3fc880388e80e6509ff298b90b7836f6cf58e2 Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Sun, 18 Jan 2026 14:49:31 -0800 Subject: [PATCH 2/2] Fix borgmatic dashboard layout - move BSBS to bottom Moved "Backup Size by Source" panel to the bottom row so it doesn't push "Repository Disk Usage Over Time" down. Now the two time series graphs sit side by side as intended. Co-Authored-By: Claude Opus 4.5 --- ansible/roles/grafana/files/dashboards/borgmatic.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/grafana/files/dashboards/borgmatic.json b/ansible/roles/grafana/files/dashboards/borgmatic.json index d2233ed..7308448 100644 --- a/ansible/roles/grafana/files/dashboards/borgmatic.json +++ b/ansible/roles/grafana/files/dashboards/borgmatic.json @@ -496,7 +496,7 @@ }, "overrides": [] }, - "gridPos": { "h": 8, "w": 8, "x": 16, "y": 4 }, + "gridPos": { "h": 8, "w": 12, "x": 0, "y": 24 }, "id": 14, "options": { "displayMode": "basic", -- 2.50.1 (Apple Git-155)