diff options
-rw-r--r-- | lib/remote/print.sh | 26 | ||||
-rw-r--r-- | lib/remote/report.sh | 27 | ||||
-rwxr-xr-x | remote/check_all.sh | 2 | ||||
-rw-r--r-- | remote/darksoft.sh | 2 | ||||
-rw-r--r-- | remote/ipeserv.sh | 2 | ||||
-rw-r--r-- | remote/kaas.sh | 3 | ||||
-rwxr-xr-x | service/check_router.sh | 2 | ||||
-rw-r--r-- | setup/adei.txt | 2 | ||||
-rw-r--r-- | setup/domains.txt | 2 | ||||
-rw-r--r-- | setup/remote.sh | 2 |
10 files changed, 51 insertions, 19 deletions
diff --git a/lib/remote/print.sh b/lib/remote/print.sh index a0fdcbe..ef9c9b8 100644 --- a/lib/remote/print.sh +++ b/lib/remote/print.sh @@ -130,9 +130,33 @@ function print_hline { echo | eol } +acolumn() { + local sep="$1" out="$2" + awk -v FS="$sep" -v SEP="$out" -v OFS='' ' + function strip(s) { gsub(/\x1B\[[0-9;?]*[ -/]*[@-~]/, "", s); return s } + { + rows[NR] = $0 + if (NF > cols) cols = NF + for (i = 1; i <= NF; i++) + if (length(strip($i)) > w[i]) w[i] = length(strip($i)) + } + END { + for (r = 1; r <= NR; r++) { + n = split(rows[r], a, FS) + for (i = 1; i <= n; i++) { + pad = w[i] - length(strip(a[i])) + printf "%s%*s", a[i], (i < n ? pad : 0), "" + if (i < n) printf "%s", SEP + } + print "" + } + }' +} + function print_table { # The problem here is that all escapes for colors are treated as normal visible symbols - sed "s/ ::: /@/g" | column -t -s "@" -o " " | eol +# sed "s/ ::: /@/g" | column -t -s "@" -o "x x" --output-width 0 | eol + sed "s/ ::: /@/g" | acolumn "@" " " | eol } function decorate_table { diff --git a/lib/remote/report.sh b/lib/remote/report.sh index 434c6aa..c4373a3 100644 --- a/lib/remote/report.sh +++ b/lib/remote/report.sh @@ -3,13 +3,22 @@ function simple_report { local filter="${2:-cat}" # Create fd12 (sending empty output), execute checks (writting extra info on fd12), print main info and store extra info into variable, wait for termination of async checks. - { - chmod +w /dev/fd/12 - eval "$generator 12>/dev/fd/12 | $filter" - report=$(cat<&12) - } 12<<EOF -EOF - wait +# { +# chmod +w /dev/fd/12 +# eval "$generator 12>/dev/fd/12 | $filter" +# report=$(cat<&12) +# } 12<<EOF +#EOF +# wait + + fifo=$(mktemp -u) ; mkfifo "$fifo" + eval "$generator 12>$fifo | $filter" & + genpid=$! + + report_text=$(cat "$fifo") + wait "$genpid" + rm -f "$fifo" + } @@ -30,7 +39,7 @@ function standart_report { configure_palete "$palete" simple_report "$generator" "$filter" - print "$report" + print "$report_text" echo finish } @@ -38,7 +47,7 @@ function standart_report { function report { # Eval breaks output for some reason - case $report in + case $report_style in simple_report) simple_report "$@" ;; diff --git a/remote/check_all.sh b/remote/check_all.sh index a506c82..83b8bd8 100755 --- a/remote/check_all.sh +++ b/remote/check_all.sh @@ -2,7 +2,7 @@ . lib/remote/status.sh -report="short_report" +report_style="short_report" run darksoft.sh run ipeserv.sh diff --git a/remote/darksoft.sh b/remote/darksoft.sh index 09823fa..d7949a5 100644 --- a/remote/darksoft.sh +++ b/remote/darksoft.sh @@ -1,6 +1,6 @@ #! /bin/bash -[ -z $report ] && source lib/remote/status.sh +[ -z $report_style ] && 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 a152076..a4ace97 100644 --- a/remote/ipeserv.sh +++ b/remote/ipeserv.sh @@ -1,6 +1,6 @@ #! /bin/bash -[ -z $report ] && source lib/remote/status.sh +[ -z $report_style ] && 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 31f6661..ec042f2 100644 --- a/remote/kaas.sh +++ b/remote/kaas.sh @@ -1,7 +1,6 @@ #! /bin/bash -[ -z $report ] && source lib/remote/status.sh - +[ -z $report_style ] && source lib/remote/status.sh function check_kaas { check "KaaS" "kaas.kit.edu" "check_service kaas <host> 3" diff --git a/service/check_router.sh b/service/check_router.sh index f241f64..f188836 100755 --- a/service/check_router.sh +++ b/service/check_router.sh @@ -49,7 +49,7 @@ done #fi # VPN check -ssh -xa darksoft.org ping -W 2 -c 2 192.168.31.1 &> /dev/null +ssh -xa master.suren.me ping -W 2 -c 2 192.168.31.1 &> /dev/null if [ $? -ne 0 ]; then echo "Can't verify availability of UFO tunnel" [ $healthy -eq 1 ] && healthy=2 diff --git a/setup/adei.txt b/setup/adei.txt index 9c95888..2e2a2d9 100644 --- a/setup/adei.txt +++ b/setup/adei.txt @@ -3,4 +3,4 @@ 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/ +imkmastadei.ka.fzk.de http://imkmastadei.imk-tro.kit.edu/adei/ diff --git a/setup/domains.txt b/setup/domains.txt index 4c119ab..c919d76 100644 --- a/setup/domains.txt +++ b/setup/domains.txt @@ -1,2 +1,2 @@ -imkmastadei ka.fzk.de +imkmastadei imk-tro.kit.edu pcebessadei competence-e.kit.edu diff --git a/setup/remote.sh b/setup/remote.sh index c172415..5470e9c 100644 --- a/setup/remote.sh +++ b/setup/remote.sh @@ -3,7 +3,7 @@ timeout=2 fold=120 palete='blue' parallel=0 -report="standart_report" +report_style="standart_report" # Helpers |