HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //lib/check_mk_agent/need_sudo/check_raid_hp
#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.0 $' | sed -e 's/[^0-9.]//g'`
HPACUCLI=/usr/sbin/hpacucli

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4

check=`sudo -u root $HPACUCLI controller slot=0 ld all show`

raid_ok=`echo $check|grep -i ok|wc -l`
raid_warning=`echo $check|grep -i rebuild|wc -l`
raid_critical_1=`echo $check|grep -i failed|wc -l`
raid_critical_2=`echo $check|grep -i recovery|wc -l`

err_check=`expr $raid_ok + $raid_warning + $raid_critical_1 + $raid_critical_2`

if [ $err_check -eq "0" ]; then
        checkm=`echo $check|sed -e '/^$/ d'`
        echo "$PROGNAME Error. $checkm"
        exit 2
fi

if [ $raid_ok -ge "1" ]; then
        exit_status=$STATE_OK
elif [ $raid_warning -ge "1" ]; then
        exit_status=$STATE_WARNING
elif [ $raid_critical_1 -ge "1" ]; then
        exit_status=$STATE_CRITICAL
elif [ $raid_critical_2 -ge "1" ]; then
        exit_status=$STATE_CRITICAL
fi

if [ $exit_status -eq "0" ]; then
        msg_ok=`echo $check|grep -i ok`
        echo "RAID OK - ($msg_ok)"
        exit $exit_status
elif [ $exit_status -eq "1" ]; then
        msg_warning=`echo $check|grep -i rebuild`
        echo "RAID WARNING - ($msg_warning)"
        exit $exit_status
elif [ $exit_status -eq "2" ]; then
        msg_critical1=`echo $check|grep -i failed`
        msg_critical2=`echo $check|grep -i recovery`
        echo "RAID CRITICAL - ($msg_critical1 $msg_critical2)"
        exit $exit_status
fi