From 0add67540a3d8904b8d7f01faec2f29e383284f9 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Wed, 24 Mar 2021 16:35:49 +0100 Subject: [PATCH] add check_fs_errors --- check_fs_errors | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 check_fs_errors diff --git a/check_fs_errors b/check_fs_errors new file mode 100755 index 0000000..7f96088 --- /dev/null +++ b/check_fs_errors @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# ====================================================================== +# +# Check filesystem errors +# +# +# requirements: +# - sudo permission on /bin/journalctl +# +# ---------------------------------------------------------------------- +# 2021-03-23 v0.0 <axel.hahn@iml.unibe.ch> +# ====================================================================== + + +. `dirname $0`/inc_pluginfunctions + + +# ---------------------------------------------------------------------- +# functions +# ---------------------------------------------------------------------- + +function showHelp(){ +cat <<EOF +______________________________________________________________________ + +CHECK_FS_ERRORS check if kernel logs inconsistency messages + +(c) Institute for Medical Education - Univerity of Bern +Licence: GNU GPL 3 +______________________________________________________________________ + + +SYNTAX: +`basename $0` [-h] + +OPTIONS: + + -h or --help show this help. + +PARAMETERS: + + none + +EXAMPLE: +`basename $0` + +EOF +} +# ---------------------------------------------------------------------- +# MAIN +# ---------------------------------------------------------------------- + +# --- check required tools +# ph.require bc top + + +# --- check param -h +case "$1" in + "--help"|"-h") + showHelp + exit 0 + ;; + *) +esac + + +# ----- MAKE CHECK + +out=$( sudo /bin/journalctl | grep 'kernel: ' | grep -v 'check_fs_errors' | grep -E '(error|fail)' | grep 'inconsistent' ) +test ! -z "$out" && ph.setStatus "critical" + + +# ----- OUTPUT + +ph.status "check if kernel logs inconsistency messages" +echo $out + + +# ----- CLEANUP AND BYE! + +ph.exit + +# ---------------------------------------------------------------------- -- GitLab