From: James Bunton Date: Sat, 30 May 2020 03:20:37 +0000 (+1000) Subject: healthcheck X-Git-Url: https://code.delx.au/monosys/commitdiff_plain/3670c0ad421b86a297a56b737a0b8f455e87b49d healthcheck --- diff --git a/healthcheck/checkspace b/healthcheck/disk-usage similarity index 88% rename from healthcheck/checkspace rename to healthcheck/disk-usage index 468b749..a3b7314 100755 --- a/healthcheck/checkspace +++ b/healthcheck/disk-usage @@ -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 index 0000000..87c6917 --- /dev/null +++ b/healthcheck/packages @@ -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 index 0000000..2d57d51 --- /dev/null +++ b/healthcheck/run-all @@ -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 index 0000000..5eea874 --- /dev/null +++ b/healthcheck/systemd-units @@ -0,0 +1,9 @@ +#!/bin/bash + +if systemctl is-failed -q '*'; then + echo -e "# systemctl --failed" + systemctl --failed + exit 1 +else + exit 0 +fi