Showing 1 changed files with 21 additions and 0 deletions
+21
monitoring.d/common-tests
... ...
@@ -37,6 +37,27 @@ function sys_state () {
37 37
     fi
38 38
 }
39 39
 
40
+function needrestart () {
41
+    _turn 24 || return
42
+    echo "$(needrestart -m a -r l -bkl | awk -F': ' '{
43
+        if ($1 == "NEEDRESTART-SVC")
44
+            needrestart[gensub("NEEDRESTART-", "", "1", $1)][gensub(".service", "", "1", $2)]++
45
+        else
46
+            needrestart[gensub("NEEDRESTART-", "", "1", $1)] = $2
47
+        }
48
+        END {
49
+            if (needrestart["KSTA"] > 1) {
50
+                print "kernel:"
51
+                print needrestart["KCUR"] " -> " needrestart["KEXP"]
52
+            }
53
+            if (length(needrestart["SVC"])) {
54
+                print "services:"
55
+                for (svc in needrestart["SVC"])
56
+                    print "- " svc
57
+            }
58
+        }')"
59
+}
60
+
40 61
 function autotest () {
41 62
     local testfile=/dev/shm/monitoring.autotest
42 63
     test -e $testfile && echo "it works" && rm -f $testfile