From 6db35a5230578e296d9f493b28e6330e22569c8f Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 4 Sep 2019 22:06:01 +0200 Subject: Integrate also nagios-based monitoring here --- service/check_distcc.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 service/check_distcc.sh (limited to 'service/check_distcc.sh') 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" -- cgit v1.2.3