summaryrefslogtreecommitdiffstats
path: root/service/check_distcc.sh
blob: 1862b5214e72896ac2e3166a32909ac6385c64ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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"