summaryrefslogtreecommitdiffstats
path: root/service/check_distcc.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-09-04 22:06:01 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-09-04 22:06:01 +0200
commit6db35a5230578e296d9f493b28e6330e22569c8f (patch)
tree86ccb8725d2ae1a779459e2d8c01087c07a37e58 /service/check_distcc.sh
parent78f3f37d3d8b213887fa6d47e32c5f9f05c0e299 (diff)
downloadconky-6db35a5230578e296d9f493b28e6330e22569c8f.tar.gz
conky-6db35a5230578e296d9f493b28e6330e22569c8f.tar.bz2
conky-6db35a5230578e296d9f493b28e6330e22569c8f.tar.xz
conky-6db35a5230578e296d9f493b28e6330e22569c8f.zip
Integrate also nagios-based monitoring here
Diffstat (limited to 'service/check_distcc.sh')
-rwxr-xr-xservice/check_distcc.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/service/check_distcc.sh b/service/check_distcc.sh
new file mode 100755
index 0000000..1862b52
--- /dev/null
+++ b/service/check_distcc.sh
@@ -0,0 +1,37 @@
+#! /bin/bash
+
+cd "$(dirname "$0")"
+. opts.sh
+
+name=distccd
+
+[ -z "$host" ] && { echo "Host should be specified"; exit 1; }
+
+online=$(../scripts/ping.pl "$host")
+healthy=$(../scripts/ping.pl "$host" 3364)
+
+function qssh {
+ ssh "root@$host" "$@"
+}
+
+
+if [ $online -eq 1 ]; then
+ id=$(qssh docker ps -f "'name=$name'" --format "'{{ .ID }}'" 2>/dev/null)
+ status=$(qssh docker ps -f "'name=$name'" --format "'{{ .Status }}'" 2>/dev/null)
+ [ $? -ne 0 ] && status=""
+fi
+
+
+if [ -n "$id" -a $healthy -eq 1 ]; then
+ stat=$(qssh docker stats --no-stream $id | sed '1d' | awk '{ print $2 " " $3 " " $4 }')
+fi
+
+if [ -n "$status" -o -n "$stat" ]; then
+ msg="DistCC: "
+ [ -n "$stat" ] && msg+=" $stat"
+ [ -n "$status" ] && msg+=" $status"
+else
+ msg=""
+fi
+
+echo "$online $healthy $msg"