]> code.delx.au - monosys/commitdiff
healthcheck
authorJames Bunton <jamesbunton@delx.net.au>
Sat, 30 May 2020 03:20:37 +0000 (13:20 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Sat, 30 May 2020 03:20:37 +0000 (13:20 +1000)
healthcheck/disk-usage [moved from healthcheck/checkspace with 88% similarity]
healthcheck/packages [new file with mode: 0755]
healthcheck/run-all [new file with mode: 0755]
healthcheck/systemd-units [new file with mode: 0755]

similarity index 88%
rename from healthcheck/checkspace
rename to healthcheck/disk-usage
index 468b74917d79461a10acec635c8007dcdc3a4a2e..a3b7314db011e2d266d3c9c4fcce7cbb9fec3024 100755 (executable)
@@ -26,6 +26,9 @@ def check_path(path):
 
     if warn:
         print("WARNING! %s has only %s remaining" % (path, pp_size(free)))
+        return False
+
+    return True
 
 def read_fstab():
     for line in open("/etc/fstab"):
@@ -38,8 +41,12 @@ def read_fstab():
 def main():
     paths = set(["/"])
     paths.update(read_fstab())
+    ok = True
     for path in paths:
-        check_path(path)
+        ok = ok and check_path(path)
+
+    if not ok:
+        sys.exit(1)
 
 if __name__ == "__main__":
     main()
diff --git a/healthcheck/packages b/healthcheck/packages
new file mode 100755 (executable)
index 0000000..87c6917
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -eu
+
+if [ -z "${CHRONIC_WRAPPED:-}" ]; then
+    export CHRONIC_WRAPPED=1
+    exec chronic -e "$0"
+fi
+
+. /etc/os-release
+
+function is_debian {
+    [ "$ID" = debian ] || [ "${ID_LIKE:-}" = debian ]
+}
+
+function is_arch {
+    [ "$ID" = arch ]
+}
+
+if is_debian; then
+    echo "# aptorphan"
+    aptorphan 1>&2
+
+    echo "# aptitude search ~U"
+    aptitude search ~U 1>&2
+fi
+
+if is_arch; then
+    echo "# pacorphan"
+    pacorphan 1>&2
+
+    echo "# checkupdates"
+    checkupdates 1>&2
+fi
diff --git a/healthcheck/run-all b/healthcheck/run-all
new file mode 100755 (executable)
index 0000000..2d57d51
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -eu
+
+. /etc/os-release
+
+cd "$(dirname "$(readlink -f "$0")")"
+
+for i in ./*; do
+    if [ "$i" != "$(basename "$0")" ]; then
+        if ! "$i"; then
+            echo -e "\n^^ FAILED! $(hostname) $PRETTY_NAME -- $i ^^\n"
+            exit 1
+        fi
+    fi
+done
diff --git a/healthcheck/systemd-units b/healthcheck/systemd-units
new file mode 100755 (executable)
index 0000000..5eea874
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if systemctl is-failed -q '*'; then
+    echo -e "# systemctl --failed"
+    systemctl --failed
+    exit 1
+else
+    exit 0
+fi