CHips L MINI SHELL

CHips L pro

Current Path : /proc/self/root/opt/zabbix_scripts/
Upload File :
Current File : //proc/self/root/opt/zabbix_scripts/os.kernelCarePatch.sh

#!/bin/sh

#####################################################################
# Version: 20200911.0138 
#
# Plugin to check for outdated kernel using Kernel Care
#
# Documentation
# -----------------------------------------------
# STATUS_MODE Variable
#      i. If set to 0, returns numeric status.
#     ii. If set to 1, returns text status.
#####################################################################


# Variable Declaration
STATUS_MODE=0
osDistAndVer=`cat /etc/redhat-release`


if [ "$STATUS_MODE" == "0" ]
then
    STATUS_OK=0
    STATUS_WARNING=1
    STATUS_CRITICAL=2
elif [ "$STATUS_MODE" == "1" ]
then
    STATUS_KERNVER="OK: Kernel is on the latest version"
    STATUS_OK="OK: Kernelcare patch is applied"
    STATUS_WARNING="WARNING: Kernelcare patch is not applied"
    STATUS_CRITICAL="CRITICAL: Kernel is outdated and kernelcare not installed"
fi


# KernelCare does not support OpenVZ 7 / Virtuozzo 7 since version 7 of those
# distributions use ReadyKernel.  If found, exit script with "OK" status.
if [[ $osDistAndVer =~ "Virtuozzo Linux release 7" ]]
then
    echo $STATUS_OK
    exit $STATUS_OK
fi


if [[ -x /usr/bin/kcarectl ]]; then
	/usr/bin/kcarectl --info | grep -q "patch is applied"
	if [ $? == 0 ]; then
                echo $STATUS_OK
		exit $STATUS_OK
	else
                echo $STATUS_WARNING
		exit $STATUS_WARNING
	fi
else
	LOAD_KERNEL=$(uname -r | cut -d'-' -f2 | cut -d'.' -f 1-4)
	AVAIL_KERNEL=$(yum info kernel | grep Release | tail -1 | awk '{print $3}')
	if [ "$LOAD_KERNEL" != "$AVAIL_KERNEL" ]; then
		yum --quiet check-update kernel > /dev/null
		if [ $? == 0 ]; then
                        echo $STATUS_WARNING
			exit $STATUS_WARNING
		else
                        echo $STATUS_CRITICAL
			exit $STATUS_CRITICAL
		fi
	else
		echo $STATUS_KERNVER
		exit $STATUS_OK
	fi
fi

Copyright 2K16 - 2K18 Indonesian Hacker Rulez