#!/usr/bin/env bash # ====================================================================== # # Check filesystem errors # # # requirements: # - sudo permission on /bin/journalctl # # ---------------------------------------------------------------------- # 2021-03-23 v1.0 <axel.hahn@iml.unibe.ch> # 2021-03-30 v1.1 <axel.hahn@iml.unibe.ch> max age of detected errors: since yesterday (commented) # ====================================================================== . `dirname $0`/inc_pluginfunctions # ---------------------------------------------------------------------- # functions # ---------------------------------------------------------------------- function showHelp(){ cat <<EOF ______________________________________________________________________ CHECK_FS_ERRORS check if kernel logs inconsistency messages (c) Institute for Medical Education - University 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 # sincedate=$( date +%Y-%m-%d --date 'yesterday' ) # out=$( sudo /bin/journalctl --since $sincedate | grep 'kernel: ' | grep -v 'check_fs_errors' | grep -E '(error|fail)' | grep 'inconsistent' ) 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 # ----------------------------------------------------------------------