Showing 2 changed files with 12 additions and 7 deletions
+7 -2
supervision
... ...
@@ -49,8 +49,9 @@ function _load () {
49 49
 
50 50
 
51 51
 function _do_tests () {
52
+    local t=
52 53
     for t in $(declare -f | sed -rn '/^[[:alpha:]]/s/^([[:alnum:]_]+)\s*\(\)\s*$/\1/p'); do
53
-        msg=
54
+        local msg=
54 55
         if grep -q "^${t}$" $supervision_disabled; then
55 56
             echo supervision by $t disabled
56 57
         else
... ...
@@ -70,10 +71,13 @@ function _do_tests () {
70 71
 
71 72
 function _do_manage_errors () {
72 73
     source $supervision_status
74
+    local msg=
75
+    local t=
76
+    local errors=
77
+    local notification=0
73 78
 
74 79
     if test ${#err[@]} -gt 0; then
75 80
         errors="Supervision $HOSTNAME (${loaded[@]}):%0a"
76
-        notification=0
77 81
         for ((i=0; i<${#err[@]}; i++)); do
78 82
             t=${err[i]}
79 83
             msg=${err[++i]}
... ...
@@ -88,6 +92,7 @@ function _do_manage_errors () {
88 92
                 let notification++
89 93
             fi
90 94
         done
95
+        errors=$(tr -d '\n' <<< $errors)
91 96
         if test "$SHLVL" -eq 1; then
92 97
             if test $notification -gt 0; then
93 98
                 $(dirname "$0")/smsapi "$errors"
+5 -5
supervision.d/common-tests
... ...
@@ -18,8 +18,8 @@ function sys_state () {
18 18
     local failed_units=
19 19
     eval $(systemctl show | egrep '^(SystemState|NFailedUnits)=')
20 20
     if test $SystemState != "running" -o $NFailedUnits -ne 0; then
21
-        msg="$SystemState mode ($NFailedUnits units failed):%0a"
22
-        msg+=$(systemctl --failed --no-legend | awk '
21
+        echo "$SystemState mode ($NFailedUnits units failed):"
22
+        echo "$(systemctl --failed --no-legend | awk '
23 23
             {
24 24
                 split($1, units, ".")
25 25
                 failed[units[2]][units[1]]=1
... ...
@@ -27,13 +27,13 @@ function sys_state () {
27 27
             }
28 28
             END {
29 29
                 for (ut in failed) { 
30
-                    printf("%s%%0a", ut)
30
+                    print ut
31 31
                     for (un in failed[ut]) {
32 32
                         last = --numfailed[ut] == 0 ? 1 : 0
33
-                        printf("%s %s%s", last ? "└─" : "├─", un, last ? "" : "%0a")
33
+                        print last ? "└─" : "├─", un
34 34
                     }
35 35
                 }
36
-            }')
36
+            }')"
37 37
     fi
38 38
 }
39 39