]> git.r.bdr.sh - rbdr/r.bdr.sh/commitdiff
Add monitorcito
authorRuben Beltran del Rio <redacted>
Thu, 26 Dec 2024 15:41:33 +0000 (16:41 +0100)
committerRuben Beltran del Rio <redacted>
Thu, 26 Dec 2024 15:41:33 +0000 (16:41 +0100)
swiftbar/monitorcito.1m.sh [new file with mode: 0755]
swiftbar_scripts.gmi

diff --git a/swiftbar/monitorcito.1m.sh b/swiftbar/monitorcito.1m.sh
new file mode 100755 (executable)
index 0000000..ff083f9
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# This plugin lists your monitorcito entries, with an overview if they're ok or
+# not.
+#
+#  <xbar.title>Monitorcito Status</xbar.title>
+#  <xbar.version>v1.0.0</xbar.version>
+#  <xbar.author>Rubén Beltrán del Río</xbar.author>
+#  <xbar.desc>Shows the status of your running services via monitorcito.</xbar.desc>
+#  <xbar.dependencies>curl,jq</xbar.dependencies>
+#  <xbar.abouturl>https://r.bdr.sh/swiftbar_scripts.html</xbar.abouturl>
+#  <xbar.var>string(VAR_MONITORCITO_URL): Your monitorcito API URL.</xbar.var>
+#  <swiftbar.hideRunInTerminal>true</swiftbar.hideRunInTerminal>
+#  <swiftbar.environment>VAR_MONITORCITO_URL=no</swiftbar.environment>
+
+###############################################################################
+# The Variables
+###############################################################################
+VAR_MONITORCITO_URL=${VAR_MONITORCITO_URL:-'https://monitor.srv.bdr.sh/api'}
+
+###############################################################################
+# The Code
+###############################################################################
+
+curl \
+  -H 'Content-Type: application/json' \
+  $VAR_MONITORCITO_URL 2>/dev/null | \
+  jq -r '(if (. | to_entries | map(.value) | all) then ":circle:" else ":xmark:" end), "---",
+    (to_entries | .[] | "\(.key) \(if .value then ":circle:" else ":xmark:" end)" + " | refresh=true")'
index 826e6fa2060a2418065937d6c41fd59d912c75dd..f07d7d96ad157b6a9fde846c75e78aa83354d3cf 100644 (file)
@@ -19,3 +19,12 @@ can also control how many builds to show by changing the VAR_BUILD_COUNT
 variable (defaults to 5)
 
 => ./swiftbar/sourcehut-builds.1m.sh ⧇ source
+
+## Monitorcito Bar
+
+View your monitorcito[2] tracked services at a glance.   is shown if everything
+is OK, and ╳ if at least one service is failing. Clicking on an item refreshes
+the status.
+
+=> https://git.sr.ht/~rbdr/monitorcito [1] Monitorcito
+=> ./swiftbar/monitorcito.1m.sh ⧇ source