summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadei/check_adei.sh97
-rwxr-xr-xadei/check_adei_control.sh16
-rwxr-xr-xadei/check_adei_source.sh224
l---------adei/check_adei_status.sh1
l---------adei/lib1
l---------adei/scripts1
l---------adei/security1
l---------adei/setup1
-rw-r--r--init/configure_ipmi.sh18
-rw-r--r--lib/adei/adei.sh287
-rw-r--r--lib/adei/adei_error.sh74
-rw-r--r--lib/adei/adei_print.sh25
-rw-r--r--lib/adei/adei_version.sh51
-rw-r--r--lib/helpers.sh9
-rwxr-xr-xlib/nagios/nagios.sh125
-rw-r--r--lib/remote/README.txt (renamed from remote/lib/README.txt)0
-rw-r--r--lib/remote/print.sh (renamed from remote/lib/print.sh)0
-rw-r--r--lib/remote/report.sh (renamed from remote/lib/report.sh)0
-rw-r--r--lib/remote/run.sh (renamed from remote/lib/run.sh)0
-rw-r--r--lib/remote/status.sh (renamed from remote/lib/status.sh)8
-rwxr-xr-xnagios/check_6
-rwxr-xr-xnagios/check_adei6
l---------nagios/check_adei_control1
l---------nagios/check_adei_source1
l---------nagios/check_adei_status1
-rwxr-xr-xnagios/check_by_ssh12
l---------nagios/check_mysql1
l---------nagios/check_ntp1
l---------nagios/check_ntp_win1
l---------nagios/check_ping1
l---------nagios/lib1
l---------nagios/scripts1
l---------nagios/security1
l---------nagios/setup1
-rw-r--r--netstat.conf18
-rw-r--r--remote/adei.sh10
-rwxr-xr-xremote/check_all.sh2
-rwxr-xr-xremote/check_kit.sh2
-rw-r--r--remote/darksoft.sh2
-rw-r--r--remote/ipeserv.sh2
-rw-r--r--remote/kaas.sh2
l---------remote/lib1
-rwxr-xr-xremote/logs.sh2
-rwxr-xr-xremote/netstat.sh2
-rwxr-xr-xremote/news.sh2
l---------remote/setup1
-rwxr-xr-xremote/todo.sh2
-rwxr-xr-xscripts/run_conky.sh2
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
-rw-r--r--setup/adei.txt6
-rw-r--r--setup/domains.txt2
-rw-r--r--setup/parameters.sh5
-rw-r--r--setup/remote.sh (renamed from remote/lib/parameters.sh)0
-rw-r--r--setup/ssh_ports.txt1
-rw-r--r--setup/ssh_users.txt1
60 files changed, 1055 insertions, 155 deletions
diff --git a/adei/check_adei.sh b/adei/check_adei.sh
new file mode 100755
index 0000000..58ce49c
--- /dev/null
+++ b/adei/check_adei.sh
@@ -0,0 +1,97 @@
+#! /bin/bash
+
+. $(dirname "$0")/lib/adei/adei.sh
+
+adei_init "$@"; code=$?
+
+online=${adei_online}
+healthy=$(( $code == 0 ))
+
+adei_version_check "0.0.10"
+[ $? -eq 0 ] && adei10=1
+
+msg=""
+[ -n "$adei_version" ] && msg+="ADEI $adei_version"
+
+# Get current database size
+[ -n "$adei10" ] && size=$(adei_text_query "info.php?target=size&encoding=text")
+
+[[ "$size" =~ "Error:" ]] && size=""
+[ -n "$size" ] && msg+=" \${color gray}/ $((size / 1024 / 1024 / 1024)) GB"
+
+# Check pending administrative scripts
+if [ -n "$adei10" -a $healthy -ne 0 ]; then
+ scripts=$(adei_xml_query "info.php?target=scripts"); err=$?
+ [ $err -eq 0 ] && waiting="$(echo $scripts | grep "Value" | sed -e "s/^\(.*mtime=\"\([^\"]*\)\".*\)$/\\2\\1/" | awk -v date="$(date +%s)" '{duration=date - $1} duration > 3600 { print duration }' | sort -rn)" #"
+
+ if [ $err -ne 0 ]; then
+ adei_print_error $err "ScriptInfo" "$waiting"
+ healthy=0
+ elif [ -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 [ -n "$adei10" -a $healthy -ne 0 -a -n "$adei_source" ]; then
+ now=$(date +%s)
+ sdate="$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U&mysql=slave")"; err_slave=$?
+ [ $err_slave -eq 0 ] && sdate="$(echo "$sdate" | cut -d ',' -f 1 | cut -d '.' -f 1)"
+ mdate="$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&cache=1&time_format=U&mysql=master")"; err_master=$?
+ [ $err_master -eq 0 ] && mdate="$(echo "$mdate" | cut -d ',' -f 1 | cut -d '.' -f 1)"
+
+ src="$adei_source"
+ if [ $err_slave -ne 0 -o $err_master -ne 0 -o -z "$sdate" -o -z "$mdate" ]; then
+
+ echo -n "Error querying (${err_master:+master} ${err_slave:+slave}) data from cache of '$src': "
+ if [ $err_master -ne 0 ]; then
+ echo "$(adei_print_error $err_master "$mdate")"
+ elif [ $err_slave -ne 0 ]; then
+ echo "$(adei_print_error $err_slave "$sdate")"
+ else
+ echo "Unexpected response from getdata service"
+ fi
+ healthy=0
+ else
+ master_offset=$(($now - $mdate))
+ slave_offset=$(($mdate - $sdate))
+
+ if [ $master_offset -gt $MAX_SOURCE_OFFSET ]; then
+ rdate=$(adei_text_query "getdata.php?db_mask=0&format=csv&window=-1&rt=1&time_format=U&mysql=master"); err=$?
+ if [ $err -eq 0 ]; then
+ rdate="$(echo "$rdate" | 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
+ else
+ echo -n "Error querying data from '$src' primary database: "
+ echo "$(adei_print_error $err_master "$rdate")"
+ healthy=0
+ 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 "$(adei_print_status "$0" $online $healthy) $msg"
diff --git a/adei/check_adei_control.sh b/adei/check_adei_control.sh
new file mode 100755
index 0000000..f6570e1
--- /dev/null
+++ b/adei/check_adei_control.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+. $(dirname "$0")/adei.sh
+
+status=1
+
+
+adei_init "$@"; code=$?
+adei_process_error $code
+
+
+cgroup="${adei_args[0]}"
+resp=$(adei_value_query "control.php?target=get&control_group=$cgroup"); code=$?
+adei_process_error "$code" "$resp" "ADEI/Control"
+
+echo "$status"
diff --git a/adei/check_adei_source.sh b/adei/check_adei_source.sh
new file mode 100755
index 0000000..dcec5bf
--- /dev/null
+++ b/adei/check_adei_source.sh
@@ -0,0 +1,224 @@
+#!/bin/bash
+
+. $(dirname "$0")/adei.sh
+
+
+adei_init "$@"; code=$?
+adei_process_error $code
+
+filter="${adei_args[0]}"
+
+#echo "$adei_url"
+#echo "$adei_source"
+#echo "$filter"
+#exit
+
+status=1
+n_groups=0
+cache_size=0
+cur=`date -u +%s`
+
+group_mode=0
+#groups=`curl -s -m 3 --proxy "" "$adei_url/services/list.php?target=groups&info=1&setup=$2&db_server=$3&db_name=$db_name" | xmllint --format - | grep "Value" | sed -e "s/^.*db_group=\"\([^\"]*\)\".*$/\\1/" | sed -e "s/ /::space::/"`
+groups=$(adei_value_query "list.php?target=groups&info=1" 12); err=$?
+if [ $err -ge 1 -a $err -le 3 ]; then
+ groups=$(adei_value_query "list.php?target=groups" 5); err=$?
+ adei_process_error $err "$groups" "GroupList"
+
+ echo "Data queries are too slow, check database indexes"
+ group_mode=1
+ status=0
+elif [ $err -gt 0 ]; then
+ adei_process_error $err "$groups" "GroupList"
+fi
+
+if [ $group_mode -eq 0 ]; then
+ groups=`echo "$groups" | sed -e "s/ /::space::/g"`
+else
+ groups=`echo "$groups" | sed -e "s/^.*db_group=\"\([^\"]*\)\".*$/\\1/" | sed -e "s/ /::space::/"`
+fi
+
+for group in $groups; do
+ n_groups=$(($n_groups + 1))
+
+ nodata=0
+ if [ $group_mode -eq 0 ]; then
+ group=`echo "$group" | sed -e "s/::space::/ /g"`
+ gid=`echo "$group" | sed -e "s/^.*db_group=\"\([^\"]*\)\".*$/\\1/"`
+ [ "$gid" == "$group" ] && gid=`echo "$group" | sed -e "s/^.*gid=\"\([^\"]*\)\".*$/\\1/"`
+
+ if [ "$gid" == "$group" ]; then
+ echo "Invalid group specification received from ADEI server: $group"
+ status=0
+ continue
+ fi
+ urlgid=`echo $gid | sed -e "s/ /+/g"`
+ last=$group
+ else
+ urlgid=`echo $group | sed -e "s/::space::/+/"`
+ gid=`echo $group | sed -e "s/::space::/ /"`
+ last=$(adei_simple_query "list.php?target=groups&info=1&db_group=$urlgid" 3)
+ if [ $? -ne 0 ]; then
+ echo "Queries to $gid are too slow, check database indexes"
+ status=0
+ nodata=1
+ else
+ error=${last#ERROR: }
+ if [ "$error" != "$last" ]; then
+ echo "$gid: $error"
+ status=0
+ nodata=1
+ fi
+ last=`echo $last | grep "Value"`
+ fi
+
+ fi
+
+ if [ $nodata -eq 0 ]; then
+ echo "$last" | grep "last=" &> /dev/null
+ if [ $? -eq 0 ]; then
+ ts=`echo $last | sed -e "s/^.*last=\"\([^\"]*\)\".*$/\\1/" | cut -d '.' -f 1`
+ if [ -z "$ts" ]; then
+ nodata=1
+# echo "$gid: contains no data"
+# if [ $status -eq 1 ]; then status=2; fi
+ fi
+ else
+ ts=""
+ nodata=1
+# echo "$gid: contains no data"
+# if [ $status -eq 1 ]; then status=2; fi
+ fi
+ else
+ ts=$cur
+ fi
+
+
+ if [ $nodata -eq 0 ]; then
+ since=$((($cur - $ts) / 3600))
+ if [ $since -gt 0 ]; then
+ if [ -n "$filter" ]; then
+ echo "$gid" | grep -P "$filter" &>/dev/null
+ accept=$?
+ else
+ accept=1
+ fi
+
+ if [ $accept -ne 0 ]; then
+ last=`date -u -d "@$ts" "+%F %R:%S"`
+ echo "$gid: Last updated on $last"
+ if [ $status -eq 1 ]; then
+ status=2
+ fi
+# continue
+ fi
+ fi
+ fi
+
+
+ info=$(adei_value_query "info.php?target=cache&db_group=$urlgid"); err=$?
+ [ $err -eq 0 ] && dbsize=`echo $info | sed -e "s/^.*dbsize=\"\([^\"]*\)\".*$/\\1/"`
+
+ if [ $err -ne 0 ]; then
+ echo "$gid: Cache query has failed"
+ status=0
+ elif [ ${#dbsize} -gt 16 ]; then
+ # Otherwise both cache & data are missing. We think it is tolerable
+ if [ $nodata -eq 0 ]; then
+ echo "$gid: Cache is empty"
+ if [ $status -eq 1 ]; then status=2; fi
+ fi
+ continue
+ else
+ cache_size=$(($cache_size + `echo $info | sed -e "s/^.*dbsize=\"\([^\"]*\)\".*$/\\1/"`))
+
+ last_cache=`echo $info | sed -e "s/^.*last=\"\([^\"]*\)\".*$/\\1/"`
+ if [ "$info" == "$last_cache" ]; then
+ # There is data in the source, but cache is empty (but we should detect this earlier)
+ # Otherwise, - no cache, no data (which is OK) or we already reported about troublesome source
+ if [ $nodata -eq 0 ]; then
+ last_cache=0
+ echo "$gid: Cache is empty (but non-zero size is reported)"
+ if [ $status -eq 1 ]; then status=2; fi
+ fi
+ continue
+ else
+ if [ -z "$ts" ]; then
+ echo -n "$gid: contains no data, but cached until "
+ date -u -d "@$last_cache" "+%F %R:%S"
+ if [ $status -eq 1 ]; then status=2; fi
+ continue
+ else
+ since=$((($ts - $last_cache) / 3600))
+ fi
+ fi
+
+ if [ $since -gt 0 ]; then
+ real_width=$(adei_xml_query "list.php?target=items&db_group=$urlgid"); err=$?
+
+ if [ $err -ne 0 ]; then
+ status=0
+ echo "$gid: item list service failed"
+ else
+ real_width=$((`echo "$real_width" | wc -l` - 3))
+ fi
+
+ if [ $real_width -le 0 ]; then
+ echo "$gid: Invalid number of items reported by list sevice ($real_width)"
+ status=0
+ continue
+ fi
+
+ width=`echo $info | grep width=`
+ if [ -z "$width" ]; then
+ echo "$gid: Invalid cache information from ADEI server, width parameter missing"
+ status=0
+ continue
+ fi
+
+ width=`echo $info | sed -e "s/^.*width=\"\([^\"]*\)\".*$/\\1/"`
+ if [ $width -eq 0 ]; then
+ echo "$gid: Invalid cache information from ADEI server, width parameter is zero"
+ status=0
+ continue
+ fi
+
+ found_reason=0
+
+ if [ "$real_width" -ne "$width" ]; then
+ found_reason=1
+ status=0
+ echo "$gid: Channel mistmatch $width (cache) and $real_width (reader)"
+ fi
+
+
+# if [ $nodata -eq 0 ]; then
+# if [ $found_reason -eq 0 ]; then
+# # Using current version, we are not able to handle properly limit & filtering together
+# adei_version_check "0.0.10"
+# if [ $? -eq 0 ]; then
+# last_data=$(adei_simple_query "getdata.php?db_group=$urlgid&window=0,1")
+# if [ $? -ne 0 ]; then
+# found_reason=1
+# status=0
+# echo -n "$gid: No valid data in database, but there is (filtered?) records. Last one from "
+# date -u -d "@$ts" "+%F %R:%S"
+# fi
+# fi
+# fi
+# fi
+
+ if [ $found_reason -eq 0 ]; then
+ status=0
+ echo "$gid: Last $since hours are not cached"
+ fi
+ fi
+ fi
+done
+
+if [ $n_groups -eq 0 ]; then
+ status=0
+fi
+
+cache_size=$(($cache_size / 1073741824))
+echo "$status $n_groups groups, $cache_size GB"
diff --git a/adei/check_adei_status.sh b/adei/check_adei_status.sh
new file mode 120000
index 0000000..9d6920c
--- /dev/null
+++ b/adei/check_adei_status.sh
@@ -0,0 +1 @@
+check_adei.sh \ No newline at end of file
diff --git a/adei/lib b/adei/lib
new file mode 120000
index 0000000..5bf80bf
--- /dev/null
+++ b/adei/lib
@@ -0,0 +1 @@
+../lib/ \ No newline at end of file
diff --git a/adei/scripts b/adei/scripts
new file mode 120000
index 0000000..adb0a1d
--- /dev/null
+++ b/adei/scripts
@@ -0,0 +1 @@
+../scripts/ \ No newline at end of file
diff --git a/adei/security b/adei/security
new file mode 120000
index 0000000..9ab7f9c
--- /dev/null
+++ b/adei/security
@@ -0,0 +1 @@
+../security/ \ No newline at end of file
diff --git a/adei/setup b/adei/setup
new file mode 120000
index 0000000..f4c6f52
--- /dev/null
+++ b/adei/setup
@@ -0,0 +1 @@
+../setup/ \ No newline at end of file
diff --git a/init/configure_ipmi.sh b/init/configure_ipmi.sh
new file mode 100644
index 0000000..b0dc0fa
--- /dev/null
+++ b/init/configure_ipmi.sh
@@ -0,0 +1,18 @@
+function configure_ipmi_user {
+ host="$1"
+ pass="$2"
+ echo "Configuring: $host"
+ /usr/bin/ipmitool -I lanplus -H "$host" -U ADMIN -P "$pass" user set name 3 nagios
+ /usr/bin/ipmitool -I lanplus -H "$host" -U ADMIN -P "$pass" user set password 3 _iosnag_
+ /usr/bin/ipmitool -I lanplus -H "$host" -U ADMIN -P "$pass" user priv 3 4
+ /usr/bin/ipmitool -I lanplus -H "$host" -U ADMIN -P "$pass" user enable 3
+ /usr/bin/ipmitool -I lanplus -H "$host" -U ADMIN -P "$pass" user list 1
+}
+
+#for host in 192.168.26.{152,155,156}; do
+# configure_ipmi_user "$host" 'ipepdv'
+#done
+
+for host in 192.168.26.160; do
+ configure_ipmi_user "$host" '$ipepdv$'
+done
diff --git a/lib/adei/adei.sh b/lib/adei/adei.sh
new file mode 100644
index 0000000..3a0aeb6
--- /dev/null
+++ b/lib/adei/adei.sh
@@ -0,0 +1,287 @@
+cd $(dirname $0)
+
+MAX_SOURCE_OFFSET=3600
+MAX_MASTER_OFFSET=300
+MAX_SLAVE_OFFSET=300
+
+adei_default_timeout=${default_timeout:-120}
+
+. lib/adei/adei_version.sh
+. lib/adei/adei_print.sh
+. lib/adei/adei_error.sh
+. lib/nagios/nagios.sh
+
+shopt -s nocasematch;
+
+# Auth with redirect (-L/--location-trusted) not working. Credentials are lost on hops.
+function adei_query {
+ local resp
+ local timeout=${3:-$adei_default_timeout}
+
+ local err=0
+ if [ "$2" == "ecode" ]; then
+ url="$1&mysql=master"
+# resp=$(curl --proxy "" -f -m "$timeout" "$url" 2>&1 | grep "returned error")
+ resp=$(curl --proxy "" --location-trusted -sf -m "$timeout" -w "%{http_code}" -o /dev/null "$url" 2>&1);
+ [ -z "$resp" -o "$resp" = "000" ] && resp="10" # error code 1
+ elif [ "$2" == "emsg" ]; then
+ url="$1&mysql=master"
+ resp=$(curl --proxy "" --location-trusted -f -m "$timeout" "$url" 2>&1 | grep -o "curl.*")
+ [ -z "$resp" ] && resp="No response from"
+ else
+ if [ "$2" == "slave" ]; then
+ url="$1&mysql=slave"
+ else
+ url="$1&mysql=master"
+ fi
+
+
+ resp=$(curl --proxy "" --location-trusted -sf -m "$timeout" "$url"); err=$?
+ if [ $err -ne 0 ]; then
+ resp=$(adei_query "$1" "ecode" "$timeout")
+ err=$(($(($resp / 10)) + $(($resp % 10))))
+
+ resp=$(adei_query "$1" "emsg" "$timeout")
+
+ [ -n "$debug" ] && echo "$(date) $timeout Failed $url" >> /tmp/adei.log
+ else
+ [ -n "$debug" ] && echo "$(date) $timeout OK $url" >> /tmp/adei.log
+ fi
+ fi
+
+ echo -n $resp
+ return $err
+}
+
+function adei_format_query {
+ local with_auth="${1:-1}"
+ local query="$2"
+ local timeout=${3:-$adei_default_timeout}
+ local source=${4:-"$adei_source"}
+ local url="${5:-$adei_url}"
+
+ auth=""
+ [ $with_auth -gt 0 ] && auth="$adei_auth"
+ if [[ "$query" =~ \? ]]; then
+ echo "http://${auth}${url}/${query}${source}"
+ else
+ echo "http://${auth}${url}/${query}?xxxxx${source}"
+ fi
+}
+
+function adei_simple_query {
+ local req=$(adei_format_query 1 "$@")
+ adei_query "$req" "master" "$timeout"; err=$?
+ return $err
+}
+
+function adei_text_query {
+ local out # Local on the same string breaks error reporting
+ out="$(adei_simple_query "$@")"; local err=$?
+
+ if [ $err -gt 0 -o -z "$out" ]; then
+# echo "Error sending ADEI request: $(adei_format_query 0 "$@")"
+ [ $err -eq 0 ] && local err=1
+ [ -n "$out" ] && echo -n "$out"
+ return $err
+ elif [[ "$out" =~ "Error:" ]]; then
+ echo -n "$out"
+ return 7
+ else
+ echo -n "$out"
+ return 0
+ fi
+}
+
+function adei_xml_query {
+ local out # Local on the same string breaks error reporting
+ out="$(adei_simple_query "$@")"; local err=$?
+
+ if [ $err -ne 0 -o -z "$out" ]; then
+# echo "Error sending ADEI request: $(adei_format_query 0 '$@')"
+ [ $err -eq 0 ] && err=1
+ [ -n "$out" ] && echo "$out"
+ return $err
+ fi
+
+ local xml="$(echo "$out" | xmllint --format - 2>/dev/null)"
+ if [ $err -ne 0 -o -z "$out" ]; then
+ echo "$out"
+ if [[ "$out" =~ "Error:" ]]; then
+ return 7
+ else
+ return 4
+ fi
+ fi
+
+ error=$(echo "$xml" | grep "<Error>")
+ if [ -n "$error" ]; then
+ echo $error | sed -e "s|</\?Error>||g"
+ return 7
+ fi
+
+ echo "$xml"
+ return $err
+}
+
+function adei_value_query {
+ local out # Local on the same string breaks error reporting
+ out="$(adei_xml_query "$@")"; local err=$?
+ [ $err -ne 0 ] && { echo "$out"; return $err; }
+
+ local values
+ values="$(echo "$out" | grep "Value")"; err=$?
+ [ $err -ne 0 ] && return 6
+
+ echo "$values"
+}
+
+
+function adei_get_databases {
+ local out
+ out="$(adei_xml_query "list.php?target=databases" "$@")"
+ [ $err -gt 0 ] && { echo -n "$out"; return $err; }
+ echo "$out" | grep "Value" | sed -e "s/^.*db_name=\"\([^\"]*\)\".*$/\\1/" | sed -e "s/ /::space::/"
+}
+
+function adei_query_version {
+ local version # Local on the same string breaks error reporting
+
+ version="$(adei_text_query "info.php?target=version&encoding=text" "$@")"; local err=$?
+ [ $err -gt 0 ] && { echo "$version"; return $err; }
+
+ adei_version="$version"
+
+ adei_revision=$(echo $adei_version | cut -d '-' -f 1)
+ if [ "$adei_revision" == "$adei_version" ]; then
+ adei_date=""
+ else
+ adei_date=$(echo $adei_version | cut -d '-' -f 2)
+ fi
+}
+
+function adei_resolve_id {
+ fn="$1"
+ id="$2"
+ host="$3"
+ setup="$4"
+
+ local var=$(cat "$fn" | grep "^$id" | awk '{ print $2 }')
+ [ -z "$var" -a -n "$host" ] && var=$(cat "$fn" | grep "^$host" | awk '{ print $2 }')
+ [ -z "$var" -a -n "$setup" ] && var=$(cat "$fn" | grep "^$setup" | awk '{ print $2 }')
+
+ [ -n "$debug" ] && echo "$(date) resolved ($var) from $fn (id=$id, host=$host, setup=$setup) pwd ($(pwd))" >> /tmp/resolv.log
+ echo "$var"
+}
+
+function adei_init_ {
+ local id="$1" && shift # Either URL or [setup]@[host]
+# local url="$1" && shift
+ local server="$1" && shift
+ local database="$1" && [[ ! "$server" =~ \&|= ]] && shift
+ adei_args=( "$@" )
+
+ [ -z "$id" ] && { echo "ADEI ID is not specified" && exit 8 ; }
+
+
+ local url
+ local host
+ local setup
+ if [[ $id =~ http.*:// ]]; then # url
+ url="$id"
+ host="$(echo ${url#http*://} | cut -d '/' -f 1)" # parse port, maybe
+
+ unset $setup
+ elif [[ $id =~ : ]]; then # [setup@]host
+ local seho
+ IFS='@' read -ra seho <<< "$id" && shift
+ host="${seho[1]:-${seho[0]}}" # parse port, for sure
+ setup="${seho[1]:+${seho[0]}}"
+
+ unset $url
+ else # [setup]@[host] or both, no port
+ local seho
+ IFS='@' read -ra seho <<< "$id" && shift # techincally we can try to resolve to decide which is which
+
+ host="${seho[1]:-${seho[0]}}" # This could be mixed up, but it is either not important, or correct, or misconfigured anyway
+ setup="${seho[1]:+${seho[0]}}" # Only error if only setup is provided. But we handle it in resolution code which agnostic and treats them as ids
+
+ url=$(adei_resolve_id "setup/adei.txt" "$id" "$host" "$setup")
+
+ if [ -n "$url" ]; then # Get URL, now we can determine host correctly and ignore the ids.
+ host="$(echo ${url#http*://} | cut -d '/' -f 1)"
+ unset $setup
+ else # only 'setup' is not allowed if URL is not configured, so it should be host (or error in configuration)
+ unset $url # so either we have both (correctly) or only host (correctly)
+ fi
+ fi
+
+ local hopo
+ IFS=':' read -ra hopo <<< "$host" && shift
+ host="${hopo[0]}" # only non fqdn if also url not set
+ port=":${hopo[1]:-80}"
+ [ $port = ":80" ] && port=""
+
+ local fqdn
+ if [ -z "$url" ]; then
+ url=$(adei_resolve_id "setup/adei.txt" "$id" "$host" "$setup")
+ if [ -n "$url" ]; then
+ fqdn="$(echo ${url#http*://} | cut -d '/' -f 1)"
+
+ IFS=':' read -ra hopo <<< "$fqdn" && shift
+ host="${hopo[0]}" # again fqdn
+ port=":${hopo[1]:-80}"
+ [ $port = ":80" ] && port=""
+ else
+ fqdn=$(resolve_fqdn "$host") # this may be not fqdn
+ [ -n "$fqdn" ] && host="$fqdn"
+ url="${host}${port}/adei"
+ fi
+ fi
+
+ # In some case we miss here "setup", but surely then the password is resolved host-based
+ adei_auth=$(adei_resolve_id "security/adei.txt" "$id" "$host" "$setup")
+ [ -n "$adei_auth" ] && adei_auth="$adei_auth@"
+
+ # Now check port
+ adei_online=$(scripts/ping.pl "$host" "$port")
+ [ $adei_online -ne 1 ] && return 2
+
+ # Now build ADEI url
+
+ adei_setup="$setup"
+ adei_host="$host"
+ adei_port="$port"
+ adei_url="${url#http*://}/services"
+
+
+ adei_query_version; local err=$?
+ [ $err -gt 0 ] && return $err
+
+
+ if [[ "$server" =~ \&|= ]]; then
+ adei_source="&$server"
+ else
+ adei_source=""
+ [ -n "$adei_setup" -a "$adei_setup" != "*" ] && adei_source+="&setup=$adei_setup"
+ [ -n "$server" -a "$server" != "-" ] && adei_source+="&db_server=$server"
+
+ if [ "$database" == "#1" ]; then
+ databases="$(adei_get_databases)"; err=$?
+ [ $err -gt 0 ] && { echo "Failed to query ADEI databases: $databases"; return $err; }
+ [ -z "$databases" ] && { echo "No databases reported by ADEI"; return 6; }
+ database=$(echo "$databases" | head -n 1)
+ fi
+
+ [ -n "$database" -a "$database" != "-" ] && adei_source+="&db_name=$database"
+ fi
+
+ return 0
+}
+
+function adei_init {
+ adei_init_ "$@"; local code=$?
+
+ adei_healthy=$(($code == 0))
+ adei_process_error "$code" "" "*" "$(adei_print_status "$0" $adei_online $adei_healthy)"
+}
diff --git a/lib/adei/adei_error.sh b/lib/adei/adei_error.sh
new file mode 100644
index 0000000..9de4795
--- /dev/null
+++ b/lib/adei/adei_error.sh
@@ -0,0 +1,74 @@
+# Error codes: 1 - unknown network, 2 - unreachable, 3 - timeout, 4 - invalid XML/JSON, 5 - parsing error, 6 - set is empty, 7 - service reported error, 8 - parameter error, 9 - unknown, 10-59 - HTTP errors
+# http code (xyz) is converted to error code (xz), e.g. 404 -> 44
+
+function adei_format_http_error {
+ err=$1
+ echo -n "$(($err / 10))0$(($err % 10))"
+}
+
+# Returns 1 if printing text is recommended
+function adei_print_error {
+ local ret=0
+ local code=${1:-0}
+ local text="$2"
+
+ local service="${3#\*}"
+ service="${service:-ADEI}"
+
+ local msg
+ if [ $code -ge 30 -a $code -lt 60 ]; then
+ msg="HTTP Error: $(adei_format_http_error $code)"
+ [ $code -eq 41 ] && msg+=" (Authentication Requested)"
+ [ $code -eq 43 ] && msg+=" (Access Denied)"
+ elif [ $code -ge 20 -a $code -lt 30 ]; then
+ msg="HTTP Status: $(adei_format_http_error $code)"
+ ret=1
+ elif [ $code -eq 1 ]; then
+ msg="Error communicating with $service"
+ ret=1
+ elif [ $code -eq 2 ]; then
+ msg="ADEI host ($adei_host:$adei_port) unreachable"
+ elif [ $code -eq 3 ]; then
+ msg="Timeout waiting for $service"
+ elif [ $code -eq 4 ]; then
+ msg="Non-XML response from $service"
+ ret=1
+ elif [ $code -eq 5 ]; then
+ msg="Error parsing response from $service"
+ ret=1
+ elif [ $code -eq 6 ]; then
+ msg="Empty response from $service"
+ ret=1
+ elif [ $code -eq 7 ]; then
+ rep="$(echo "$text" | head -n 1 | sed 's/Error:\?[[:space:]]\+//i')"
+ if [ ${#rep} -lt 40 ]; then
+ msg="$service Error: $rep"
+ else
+ msg="$service returned a error"
+ ret=1
+ fi
+ elif [ $code -eq 8 ]; then
+ msg="Invalid parameter"
+ else
+ msg="Unknown Error $code while accessing $service"
+ fi
+
+ echo -n "$msg"
+ return $ret
+}
+
+function adei_process_error {
+ local code=${1:-0}; shift
+ local text="$1"; shift
+ local service="$1"; shift
+ local status="${1:-0}"
+
+ if [ $code -ne 0 ]; then
+ local msg # local on the same line break error reporting
+ msg="$(adei_print_error $code "$text" "$service")"
+ [ $? -eq 1 ] && echo "$text"
+ echo "$status $msg"
+ exit
+ fi
+}
+
diff --git a/lib/adei/adei_print.sh b/lib/adei/adei_print.sh
new file mode 100644
index 0000000..aca7735
--- /dev/null
+++ b/lib/adei/adei_print.sh
@@ -0,0 +1,25 @@
+function adei_print_status {
+ cmd="$1"
+ online="$2"
+ healthy="$3"
+
+ if [[ "$cmd" =~ check_adei_ ]]; then
+ echo "$healthy"
+ else
+ echo "$online $healthy"
+ fi
+}
+
+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
+}
+
diff --git a/lib/adei/adei_version.sh b/lib/adei/adei_version.sh
new file mode 100644
index 0000000..b71b1e1
--- /dev/null
+++ b/lib/adei/adei_version.sh
@@ -0,0 +1,51 @@
+vercomp() {
+ if [[ $1 == $2 ]]
+ then
+ return 0
+ fi
+ local IFS=.
+ local i ver1=($1) ver2=($2)
+ # fill empty fields in ver1 with zeros
+ for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
+ do
+ ver1[i]=0
+ done
+ for ((i=0; i<${#ver1[@]}; i++))
+ do
+ if [[ -z ${ver2[i]} ]]
+ then
+ # fill empty fields in ver2 with zeros
+ ver2[i]=0
+ fi
+ if ((10#${ver1[i]} > 10#${ver2[i]}))
+ then
+ return 1
+ fi
+ if ((10#${ver1[i]} < 10#${ver2[i]}))
+ then
+ return 2
+ fi
+ done
+ return 0
+}
+
+adei_version_check() {
+ vercomp $adei_revision $1
+ res=$?
+ if [ $res -eq 1 ]; then
+ return 0
+ elif [ $res -eq 2 ]; then
+ return 1;
+ fi
+
+ if [ -z "$2" -o -z "$adei_date" ]; then
+ return 0
+ fi
+
+ if [ $adei_date -ge $2 ]; then
+ return 0
+ fi
+
+ return 1
+}
+
diff --git a/lib/helpers.sh b/lib/helpers.sh
new file mode 100644
index 0000000..b562eb6
--- /dev/null
+++ b/lib/helpers.sh
@@ -0,0 +1,9 @@
+function in_array() {
+ local hay needle=$1
+ shift
+ for hay; do
+ [[ $hay == $needle ]] && return 0
+ done
+
+ return 1
+}
diff --git a/lib/nagios/nagios.sh b/lib/nagios/nagios.sh
new file mode 100755
index 0000000..40631c1
--- /dev/null
+++ b/lib/nagios/nagios.sh
@@ -0,0 +1,125 @@
+cd $(dirname "$0")
+
+. setup/parameters.sh
+
+function nagios_find_host {
+ echo "$@" | grep -oP '\-H\s*\K[^\s]*'
+}
+
+function find_host_param {
+ local id="$1" && shift
+ local pname="$1" && shift
+ local defval="$1" && shift
+
+ local val=$(cat setup/${pname}.txt | grep -P "^$id" | awk '{ print $2 }')
+ [ -n "$val" ] || val="$defval"
+
+ echo -n "$val"
+}
+
+function nagios_find_host_param {
+ local pname="$1" && shift
+ local defval="$1" && shift
+ local host=$(nagios_find_host "$@")
+
+ find_host_param "$host" "$pname" "$defval"
+}
+
+function resolve_fqdn {
+ local host="$1" && shift
+
+ if [[ ! $host =~ \. ]]; then
+ local domain=$(find_host_param "$host" domains "$default_domain")
+ host+=".$domain"
+ fi
+
+ echo -n $host
+}
+
+function resolve_ip {
+ local host="$1" && shift
+
+ if [[ ! "$host" =~ ^[[:digit:]] ]]; then
+ local fqdn=$(resolve_fqdn "$host")
+ host=$(dig +short "$fqdn" A | head -n 1 | tr -d '\n')
+ if [ $? -ne 0 -o -z "$host" ]; then
+ echo "DNS resolution for host ($fqdn) failed: $(dig +short "$fqdn" A 2>&1)"
+ exit 2
+ fi
+ fi
+
+ echo -n "$host"
+}
+
+function nagios_run {
+ if [[ "$1" =~ ^- ]]; then
+ cmd=${nagios_plugins}/$(basename $0)
+ else
+ cmd=$1 && shift
+ [[ "$cmd" =~ ^/ ]] || cmd="${nagios_plugins}/$cmd"
+ fi
+
+ ARGS=""
+ while [[ $# -gt 0 ]]; do
+ key="$1" && shift
+
+ case "$key" in
+ -H)
+ host="$1" && shift
+ ip=$(resolve_ip "$host")
+ if [ $? -eq 0 -a -n "$ip" ]; then
+ ARGS+=" ${key} $ip"
+ else
+ echo "$ip"
+ exit $?
+ fi
+ ;;
+ *)
+ ARGS+=" $key"
+ esac
+ done
+
+ [ -n "$debug" ] && echo "$(date) $cmd" "$ARGS" >> /tmp/nagios.log
+ eval "$cmd" "$ARGS"
+}
+
+function nagios_parse {
+ cmd="$1"; shift
+
+ output=$($cmd "$@")
+ exit_code=$?
+
+ if [ $exit_code -eq 0 ]; then
+ last_line=$(echo "$output" | tail -1)
+
+ status=$(echo $last_line | cut -d ' ' -f 1)
+ [[ "$status" =~ ^[0-9]$ ]] || status=0
+ echo -n ${last_line#$status}
+ else
+ status=0
+ fi
+
+ if [ $status -ne 1 ]; then
+ echo -n " -- "
+
+ lines=$(echo "$output" | sed '/^[[:space:]]*$/d' | wc -l)
+ if [ $lines -gt 1 ]; then
+ echo "$output" | sed '/^[[:space:]]*$/d' | head -n 1 | tr -d '\n'
+ echo " ... "
+ echo "------------------"
+ echo "$output" | head -n -1
+ else
+ echo "$output" | sed '/^[[:space:]]*$/d' | head -n -1
+ fi
+ else
+ echo
+ fi
+
+ if [ "$status" -eq 0 ]; then
+ exit "2"
+ elif [ "$status" -eq 1 ]; then
+ exit "0"
+ else
+ exit "1"
+ fi
+}
diff --git a/remote/lib/README.txt b/lib/remote/README.txt
index c5998f8..c5998f8 100644
--- a/remote/lib/README.txt
+++ b/lib/remote/README.txt
diff --git a/remote/lib/print.sh b/lib/remote/print.sh
index a0fdcbe..a0fdcbe 100644
--- a/remote/lib/print.sh
+++ b/lib/remote/print.sh
diff --git a/remote/lib/report.sh b/lib/remote/report.sh
index e6766a4..e6766a4 100644
--- a/remote/lib/report.sh
+++ b/lib/remote/report.sh
diff --git a/remote/lib/run.sh b/lib/remote/run.sh
index fdd7311..fdd7311 100644
--- a/remote/lib/run.sh
+++ b/lib/remote/run.sh
diff --git a/remote/lib/status.sh b/lib/remote/status.sh
index 95e7bbb..7bef6c8 100644
--- a/remote/lib/status.sh
+++ b/lib/remote/status.sh
@@ -1,7 +1,7 @@
-. lib/parameters.sh
-. lib/print.sh
-. lib/report.sh
-. lib/run.sh
+. setup/remote.sh
+. lib/remote/print.sh
+. lib/remote/report.sh
+. lib/remote/run.sh
function check_server_traffic {
local result="$1"
diff --git a/nagios/check_ b/nagios/check_
new file mode 100755
index 0000000..839e9c1
--- /dev/null
+++ b/nagios/check_
@@ -0,0 +1,6 @@
+#! /bin/bash
+
+. $(dirname $0)/lib/nagios/nagios.sh
+
+nagios_run "$@"
+
diff --git a/nagios/check_adei b/nagios/check_adei
new file mode 100755
index 0000000..ba0a34f
--- /dev/null
+++ b/nagios/check_adei
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+. $(dirname $0)/lib/nagios/nagios.sh
+
+[ -n "$debug" ] && echo "$(date) adei/$(basename $0).sh" "$@" >> /tmp/nagios.log
+nagios_parse "adei/$(basename $0).sh" "$@"
diff --git a/nagios/check_adei_control b/nagios/check_adei_control
new file mode 120000
index 0000000..c07768e
--- /dev/null
+++ b/nagios/check_adei_control
@@ -0,0 +1 @@
+check_adei \ No newline at end of file
diff --git a/nagios/check_adei_source b/nagios/check_adei_source
new file mode 120000
index 0000000..c07768e
--- /dev/null
+++ b/nagios/check_adei_source
@@ -0,0 +1 @@
+check_adei \ No newline at end of file
diff --git a/nagios/check_adei_status b/nagios/check_adei_status
new file mode 120000
index 0000000..c07768e
--- /dev/null
+++ b/nagios/check_adei_status
@@ -0,0 +1 @@
+check_adei \ No newline at end of file
diff --git a/nagios/check_by_ssh b/nagios/check_by_ssh
new file mode 100755
index 0000000..1a488b2
--- /dev/null
+++ b/nagios/check_by_ssh
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+. $(dirname $0)/lib/nagios/nagios.sh
+
+
+port=$(nagios_find_host_param "ssh_ports" 22 "$@")
+user=$(nagios_find_host_param "ssh_users" root "$@")
+
+local port=$(cat setup/ssh_ports.txt | grep -P "^$host" | awk '{ print $2 }')
+
+#echo "$@" -o " -p $port -l $user UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" >> /tmp/xxx
+nagios_run "$@" -p $port -l $user -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no"
diff --git a/nagios/check_mysql b/nagios/check_mysql
new file mode 120000
index 0000000..74fe9a3
--- /dev/null
+++ b/nagios/check_mysql
@@ -0,0 +1 @@
+check_ \ No newline at end of file
diff --git a/nagios/check_ntp b/nagios/check_ntp
new file mode 120000
index 0000000..74fe9a3
--- /dev/null
+++ b/nagios/check_ntp
@@ -0,0 +1 @@
+check_ \ No newline at end of file
diff --git a/nagios/check_ntp_win b/nagios/check_ntp_win
new file mode 120000
index 0000000..74fe9a3
--- /dev/null
+++ b/nagios/check_ntp_win
@@ -0,0 +1 @@
+check_ \ No newline at end of file
diff --git a/nagios/check_ping b/nagios/check_ping
new file mode 120000
index 0000000..74fe9a3
--- /dev/null
+++ b/nagios/check_ping
@@ -0,0 +1 @@
+check_ \ No newline at end of file
diff --git a/nagios/lib b/nagios/lib
new file mode 120000
index 0000000..5bf80bf
--- /dev/null
+++ b/nagios/lib
@@ -0,0 +1 @@
+../lib/ \ No newline at end of file
diff --git a/nagios/scripts b/nagios/scripts
new file mode 120000
index 0000000..adb0a1d
--- /dev/null
+++ b/nagios/scripts
@@ -0,0 +1 @@
+../scripts/ \ No newline at end of file
diff --git a/nagios/security b/nagios/security
new file mode 120000
index 0000000..9ab7f9c
--- /dev/null
+++ b/nagios/security
@@ -0,0 +1 @@
+../security/ \ No newline at end of file
diff --git a/nagios/setup b/nagios/setup
new file mode 120000
index 0000000..f4c6f52
--- /dev/null
+++ b/nagios/setup
@@ -0,0 +1 @@
+../setup/ \ No newline at end of file
diff --git a/netstat.conf b/netstat.conf
index 54c1b24..96bb9f6 100644
--- a/netstat.conf
+++ b/netstat.conf
@@ -40,7 +40,7 @@ template8 900
#template0 ${if_match ${execi $template8 /etc/conky/scripts/ping.pl \1:3389} > 0}${color green}${else}${color red}${endif}*${color}
#template0 ${lua_parse check_server_status \1 3389 -}
template0 ${lua_parse check_server_status \1 22 -}
-template1 ${lua_parse check_server_status \1 3306 -}
+template1 ${lua_parse check_server_status \1 3632 -}
lua_load /etc/conky/support.lua
@@ -58,14 +58,18 @@ ${color white}ipekatrin2 ${goto 160}${lua_parse check_server_status ipekatrin2.i
${color white}ipekatrin3 ${goto 160}${lua_parse check_server_status ipekatrin3.ipe.kit.edu 22 uptime}
${color yellow}ADEI ${hr}${lua set_width $template2}${lua set_timeout $template3}
-${color white}KaaS ${goto 160}${lua_parse check_service_ adei kaas adei-katrin.kaas.kit.edu/adei 'db_server=fpd&db_name=katrin_rep&db_group=0'}${color white}
-# ${color white}ipekatrinadei ${goto 160}${lua_parse check_service_ adei katrin katrin.kit.edu/adei-katrin-orig 'db_server=fpd&db_name=katrin_rep&db_group=0'}${color white}
-${color white}pcebessadei ${goto 160}${lua_parse check_service_ adei pcebess pcebessadei.competence-e.kit.edu/adei-battery}${color white}
-${color white}ipemkmastadei ${goto 160}${lua_parse check_service_ adei imkmast imkmastadei.ka.fzk.de/adei}${color white}
-# ${color white}itepmtadei ${goto 160}${lua_parse check_service_ adei itepmt itepmtadei.itep.kit.edu/adei}${color white}
-${color white}CRD ${goto 160}${lua_parse check_service_ adei crd adei.crd.yerphi.am/adei}${color white}
+${color white}KaaS ${goto 160}${lua_parse check_service_ adei kaas 'db_server=fpd&db_name=katrin_rep&db_group=0'}${color white}
+${color white}pcebessadei ${goto 160}${lua_parse check_service_ adei pcebess}${color white}
+${color white}ipemkmastadei ${goto 160}${lua_parse check_service_ adei imkmast}${color white}
+${color white}CRD ${goto 160}${lua_parse check_service_ adei crd}${color white}
+
+${color yellow}Build Farm ${hr}${lua set_width $template2}${lua set_timeout $template3}
+#${color white}Compute4 ${goto 160}${template0 192.168.21.1} ${template1 192.168.21.1}${color white}
+${color white}Compute4 ${goto 160}${lua_parse check_service_ distcc ipepdvcompute4}${color white}
+
${lua_parse print_server_errors $template8 conky_netstat}
+
${color yellow}Network Connections ${hr}
${color white}Incomming connections${color gray}:
${execpi $template5 /etc/conky/scripts/netstat-in.sh | grep -v "android-d855cbd1c9f827d" | grep -v "pdv-time-capsule-2.ipe.kit.edu" | awk -e '{ print "${goto 18}", $1, "${goto 720} to", $2 }' }
diff --git a/remote/adei.sh b/remote/adei.sh
index 0b5c42d..c4ba109 100644
--- a/remote/adei.sh
+++ b/remote/adei.sh
@@ -1,12 +1,12 @@
#! /bin/bash
-[ -z $report ] && source lib/status.sh
+[ -z $report ] && source lib/remote/status.sh
function check_adei {
- check "KaaS" "kaas" "check_service adei <host> adei-katrin.kaas.kit.edu/adei 'db_server=fpd&db_name=katrin_rep&db_group=0'"
- check "BESS" "pcebess" "check_service adei <host> pcebessadei.competence-e.kit.edu/adei-battery"
- check "IMK" "imkmast" "check_service adei <host> imkmastadei.ka.fzk.de/adei"
- check "CRD" "crd" "check_service adei <host> adei.crd.yerphi.am/adei"
+ check "KaaS" "kaas" "check_service adei <host> 'db_server=fpd&db_name=katrin_rep&db_group=0'"
+ check "BESS" "pcebess" "check_service adei <host>"
+ check "IMK" "imkmast" "check_service adei <host>"
+ check "CRD" "crd" "check_service adei <host>"
}
diff --git a/remote/check_all.sh b/remote/check_all.sh
index da2b83f..a506c82 100755
--- a/remote/check_all.sh
+++ b/remote/check_all.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-. lib/status.sh
+. lib/remote/status.sh
report="short_report"
diff --git a/remote/check_kit.sh b/remote/check_kit.sh
index 9bdbeae..b50d5ce 100755
--- a/remote/check_kit.sh
+++ b/remote/check_kit.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-. lib/status.sh
+. lib/remote/status.sh
run kaas.sh
run adei.sh
diff --git a/remote/darksoft.sh b/remote/darksoft.sh
index f8f6949..09823fa 100644
--- a/remote/darksoft.sh
+++ b/remote/darksoft.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-[ -z $report ] && source lib/status.sh
+[ -z $report ] && source lib/remote/status.sh
function check_darksoft {
check "DarkSoft" "darksoft.org" "check_server_status <host> vpn/192.168.21.1" "check_server_ traffic <host> 20 50"
diff --git a/remote/ipeserv.sh b/remote/ipeserv.sh
index 9f314a1..a737912 100644
--- a/remote/ipeserv.sh
+++ b/remote/ipeserv.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-[ -z $report ] && source lib/status.sh
+[ -z $report ] && source lib/remote/status.sh
function check_ipe {
check "katrin" "katrin.kit.edu" "check_server_status <host>"
diff --git a/remote/kaas.sh b/remote/kaas.sh
index 5fc1b4a..37d6a5a 100644
--- a/remote/kaas.sh
+++ b/remote/kaas.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-[ -z $report ] && source lib/status.sh
+[ -z $report ] && source lib/remote/status.sh
function check_kaas {
diff --git a/remote/lib b/remote/lib
new file mode 120000
index 0000000..dc598c5
--- /dev/null
+++ b/remote/lib
@@ -0,0 +1 @@
+../lib \ No newline at end of file
diff --git a/remote/logs.sh b/remote/logs.sh
index 91257c0..e619e78 100755
--- a/remote/logs.sh
+++ b/remote/logs.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-. lib/status.sh
+. lib/remote/status.sh
function filter_syslog {
log="$1"
diff --git a/remote/netstat.sh b/remote/netstat.sh
index c6c9561..68ca9db 100755
--- a/remote/netstat.sh
+++ b/remote/netstat.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-. lib/status.sh
+. lib/remote/status.sh
decorate "Incomming:" purple; echo
scripts/netstat-in.sh | grep -v "android-d855cbd1c9f827d" | grep -v "pdv-time-capsule-2.ipe.kit.edu" | column -t
diff --git a/remote/news.sh b/remote/news.sh
index ea24458..844e2ea 100755
--- a/remote/news.sh
+++ b/remote/news.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-. lib/status.sh
+. lib/remote/status.sh
decorate "Security:" purple; echo
rsstail -n 8 -1 -u https://security.gentoo.org/glsa/feed.rss | cut -d ':' -f 2- | cut -c 2- | fmt -t -w $fold
diff --git a/remote/setup b/remote/setup
new file mode 120000
index 0000000..f4c6f52
--- /dev/null
+++ b/remote/setup
@@ -0,0 +1 @@
+../setup/ \ No newline at end of file
diff --git a/remote/todo.sh b/remote/todo.sh
index 863498a..0a6d80d 100755
--- a/remote/todo.sh
+++ b/remote/todo.sh
@@ -1,6 +1,6 @@
#! /bin/bash
-. lib/status.sh
+. lib/remote/status.sh
diff --git a/scripts/run_conky.sh b/scripts/run_conky.sh
index abdea35..7648259 100755
--- a/scripts/run_conky.sh
+++ b/scripts/run_conky.sh
@@ -7,7 +7,7 @@ if [ "$1" != "start" ]; then
fi
if [ "$1" != "stop" ]; then
- python /opt/scripts/unlock.py gui || exit
+ python2 /opt/scripts/unlock.py gui || exit
killall -9 gpg-agent
pass test
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
diff --git a/setup/adei.txt b/setup/adei.txt
new file mode 100644
index 0000000..9c95888
--- /dev/null
+++ b/setup/adei.txt
@@ -0,0 +1,6 @@
+katrin http://adei-katrin.kaas.kit.edu/adei/
+kaas http://adei-katrin.kaas.kit.edu/adei/
+detector http://192.168.110.67/adei/
+crd http://adei.crd.yerphi.am/adei/
+pcebessadei.competence-e.kit.edu http://pcebessadei.competence-e.kit.edu/adei-battery/
+imkmastadei.ka.fzk.de http://imkmastadei.ka.fzk.de/adei/
diff --git a/setup/domains.txt b/setup/domains.txt
new file mode 100644
index 0000000..4c119ab
--- /dev/null
+++ b/setup/domains.txt
@@ -0,0 +1,2 @@
+imkmastadei ka.fzk.de
+pcebessadei competence-e.kit.edu
diff --git a/setup/parameters.sh b/setup/parameters.sh
new file mode 100644
index 0000000..ce5b930
--- /dev/null
+++ b/setup/parameters.sh
@@ -0,0 +1,5 @@
+debug=1
+default_domain="ipe.kit.edu"
+nagios_plugins="/usr/lib/nagios/plugins"
+
+default_timeout=120
diff --git a/remote/lib/parameters.sh b/setup/remote.sh
index c172415..c172415 100644
--- a/remote/lib/parameters.sh
+++ b/setup/remote.sh
diff --git a/setup/ssh_ports.txt b/setup/ssh_ports.txt
new file mode 100644
index 0000000..148bb5b
--- /dev/null
+++ b/setup/ssh_ports.txt
@@ -0,0 +1 @@
+ufosrv1.ka.fzk.de 24
diff --git a/setup/ssh_users.txt b/setup/ssh_users.txt
new file mode 100644
index 0000000..e7f75ea
--- /dev/null
+++ b/setup/ssh_users.txt
@@ -0,0 +1 @@
+ufosrv1.ka.fzk.de csa