summaryrefslogtreecommitdiffstats
path: root/service/check_distcc.sh
diff options
context:
space:
mode:
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"