summaryrefslogtreecommitdiffstats
path: root/service
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
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')
l---------[-rwxr-xr-x]service/check_adei.sh130
-rwxr-xr-xservice/check_distcc.sh37
l---------service/lib1
l---------service/scripts1
l---------service/security1
l---------service/setup1
6 files changed, 42 insertions, 129 deletions
diff --git a/service/check_adei.sh b/service/check_adei.sh
index 5ef1ebf..d1f9b8f 100755..120000
--- a/service/check_adei.sh
+++ b/service/check_adei.sh
@@ -1,129 +1 @@
-#! /bin/bash
-
-MAX_SOURCE_OFFSET=3600
-MAX_MASTER_OFFSET=300
-MAX_SLAVE_OFFSET=300
-
-function query {
- if [ "$2" == "ecode" ]; then
- url="$1&mysql=master"
- resp=$(curl -f "$url" 2>&1 | grep "returned error")
- else
- if [ "$2" == "slave" ]; then
- url="$1&mysql=slave"
- else
- url="$1&mysql=master"
- fi
-
- resp=$(curl -sf "$url")
- err=$?
- [ $err -eq 0 ] || resp=""
- fi
- echo $resp
-}
-
-function format_time {
- offset=$1
- if [ $offset -ge 86400 ]; then
- echo "$((offset / 86400))d"
- elif [ $offset -ge 3600 ]; then
- echo "$((offset / 3600))h"
- elif [ $offset -ge 60 ]; then
- echo "$((offset / 60))m"
- else
- echo "${offset}s"
- fi
-}
-
-
-cd "$(dirname "$0")"
-id=$1
-
-auth=$(cat ../security/adei.txt | grep -P "^$id" | awk '{ print $2 }')
-[ -n $auth ] && auth="$auth@"
-
-host=$(echo $2 | cut -d '/' -f 1)
-url="http://$auth$2/services"
-
-src=$3
-
-# Check if online
-online=$(../scripts/ping.pl "$host")
-healthy=$online
-
-# Check if healthy and find version
-version=$(query "$url/info.php?target=version&encoding=text")
-if [ -z "$version" ]; then
- err=$(query "$url/info.php?target=version&encoding=text" "ecode")
- echo $err
- healthy=0
-else
- if [[ "$version" =~ "Error:" ]]; then
- echo $version
- healthy=0
- version=""
- else
- version="ADEI $version"
- fi
-fi
-
-# Get current database size
-size=$(query "$url/info.php?target=size&encoding=text")
-[[ "$size" =~ "Error:" ]] && size=""
-[ -n "$size" ] && msg="\${color gray}/ $((size / 1024 / 1024 / 1024)) GB"
-
-# Check pending administrative scripts
-if [ $healthy -ne 0 ]; then
- scripts=$(query "$url/info.php?target=scripts")
- waiting=$(echo $scripts | xmllint --format - | grep "Value" | sed -e "s/^\(.*mtime=\"\([^\"]*\)\".*\)$/\\2\\1/" | awk -v date="$(date +%s)" '{duration=date - $1} duration > 3600 { print duration }' | sort -rn)
- if [ -n "$waiting" ]; then
- num_waiting=$(echo $waiting | tr ' ' '\n' | wc -l)
- long_waiting=$(echo $waiting | cut -d ' ' -f 1)
- if [ $num_waiting -gt 0 ]; then
- healthy=2
- echo "$num_waiting pending scripts, longest for $(format_time $long_waiting)"
- fi
- fi
-fi
-
-
-# Verify offset (for selected database)
-if [ $healthy -ne 0 -a -n "$src" ]; then
- now=$(date +%s)
- sdate=$(query "$url/getdata.php?$src&db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U" slave | cut -d ',' -f 1 | cut -d '.' -f 1)
- mdate=$(query "$url/getdata.php?$src&db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U" | cut -d ',' -f 1 | cut -d '.' -f 1)
-
- if [ -z "$sdate" -o -z "$mdate" ]; then
- echo "Error querying data from '$src'"
- healthy=2
- else
- master_offset=$(($now - $mdate))
- slave_offset=$(($mdate - $sdate))
-
- if [ $master_offset -gt $MAX_SOURCE_OFFSET ]; then
- rdate=$(query "$url/getdata.php?$src&db_mask=0&format=csv&window=-1&rt=1&time_format=U" | cut -d ',' -f 1 | cut -d '.' -f 1)
- cache_offset=$(($rdate - $mdate))
- if [ $cache_offset -gt $MAX_MASTER_OFFSET ]; then
- echo "ADEI cache is off by $(format_time $cache_offset) for '$src'"
- healthy=2
- else
- offset=$(($now - $rdate))
-# echo "Source '$src' is not updated for $(format_time $offset)"
- fi
- fi
-
- if [ $slave_offset -gt $MAX_SLAVE_OFFSET ]; then
- echo "MySQL slave is off by $(format_time $slave_offset) for '$src'"
- healthy=2
- fi
-
- [ -n "$msg" ] && msg="${msg}, "
- [ -z "$msg" ] && msg="\${color gray}/ "
- msg="${msg}cache $(format_time $master_offset)"
- [ $slave_offset -gt 0 ] && msg="$msg & slave $(format_time $slave_offset)"
- msg="$msg off"
- fi
-
-fi
-
-echo "$online $healthy $version $msg"
+../adei/check_adei.sh \ No newline at end of file
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"
diff --git a/service/lib b/service/lib
new file mode 120000
index 0000000..5bf80bf
--- /dev/null
+++ b/service/lib
@@ -0,0 +1 @@
+../lib/ \ No newline at end of file
diff --git a/service/scripts b/service/scripts
new file mode 120000
index 0000000..a339954
--- /dev/null
+++ b/service/scripts
@@ -0,0 +1 @@
+../scripts \ No newline at end of file
diff --git a/service/security b/service/security
new file mode 120000
index 0000000..872fbdf
--- /dev/null
+++ b/service/security
@@ -0,0 +1 @@
+../security \ No newline at end of file
diff --git a/service/setup b/service/setup
new file mode 120000
index 0000000..8376d48
--- /dev/null
+++ b/service/setup
@@ -0,0 +1 @@
+../setup \ No newline at end of file