VaKeR CYBER ARMY
Logo of a company Server : Apache
System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User : vapecompany ( 2719)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /lib64/nagios/plugins/nccustom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/nagios/plugins/nccustom/check_kernelcare.sh
#!/bin/sh

## check Kernel Care updates and if patches were applied
## Copyright (c) 2017, Namecheap.com
## Written by Yuri Muravyov  <y.muravyov@gmail.com>
## Updated by Bogdan Kukharskiy <bogdan.kukharskiy@namecheap.com>

PROGNAME=check_kernel_care
REVISION=0.3
PROGNAME=`basename $0`

CHECK_UPDATES_STR="The latest patch is applied."
CHECK_UPDATES_STR2="This kernel doesn't require any patches."
CHECK_PATCHES_STR="kpatch-state: patch is applied"

print_revision() {
        echo $PROGNAME $REVISION
}

print_usage() {
        echo "Usage: $PROGNAME [options]"
        echo "  e.g. $PROGNAME"
        echo
        echo "Options:"
        echo -e "\t --help | -h          print help"
        echo -e "\t --version | -V       print version"
}

print_help() {
        print_revision $PROGNAME $REVISION
        echo 
        echo "This script checks kernel care state (updates and patches)"
        echo 
        print_usage
        echo 
        exit 3
}


# parse cmd arguments
if [ "$#" -gt 0 ]; then
        while [ "$#" -gt 0 ]; do
                case "$1" in
                        '--help'|'-h')
                                print_help
                                exit 3
                                ;;
                        '--version'|'-V')
                                print_revision $PROGNAME $REVISION
                                exit 3
                                ;;
                        *)
                                echo "Unknown option!"
                                print_usage
                                exit 3
                                ;;
                esac
        done
fi

KCARE_UPDATES_CHECK=`sudo /usr/bin/kcarectl --check 2>&1`;
KCARE_PATCHES_CHECK=`sudo /usr/bin/kcarectl -i | grep kpatch-state 2>&1`;

if [ "$KCARE_UPDATES_CHECK" != "$CHECK_UPDATES_STR" ] && [ "$KCARE_UPDATES_CHECK" != "$CHECK_UPDATES_STR2" ]; then
        echo "CRITICAL: $KCARE_UPDATES_CHECK"
        exit 2
elif [ "$KCARE_PATCHES_CHECK" != "$CHECK_PATCHES_STR" ] && [ ${#KCARE_PATCHES_CHECK} != 0 ]; then
        echo "CRITICAL: $KCARE_PATCHES_CHECK"
        exit 2
fi

echo "OK: $KCARE_UPDATES_CHECK $KCARE_PATCHES_CHECK"
exit 0

VaKeR 2022