Skip to content
Snippets Groups Projects
Select Git revision
  • c6edcac7a9a944767bf277cef5e218593ad04e5f
  • master default protected
  • simple-task/7248-eol-check-add-node-22
  • 6877_check_iml_deployment
4 results

check_fs_errors

Blame
  • check_fs_errors 1.95 KiB
    #!/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)
    # 2023-07-27  v1.2  <axel.hahn@unibe.ch>      shell fixes; update help page
    # ======================================================================
    
    
    . $( dirname $0 )/inc_pluginfunctions
    
    export self_APPVERSION=1.2
    
    
    # ----------------------------------------------------------------------
    # functions
    # ----------------------------------------------------------------------
    
    function showHelp(){
        local _self; _self=$(basename $0)
        cat <<EOF
    $( ph.showImlHelpHeader )
    
    Check if kernel logs inconsistency messages in the journallog.
    It requires sudo permission on /bin/journalctl
    
    SYNTAX:
    $_self [-h]
    
    OPTIONS:
    
        -h or --help   show this help.
    
    PARAMETERS:
    
        none
    
    EXAMPLE:
    $_self
    
    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
    
    # ----------------------------------------------------------------------