Hello to everyone, i am having some issues implementing Nagios plugin which i downloaded from website. When i go to my dashboard the status of service is Unkown. Current Status:
UNKNOWN
(for 2d 1h 2m 37s)
Status Information: /usr/local/nagios/libexec/check_cpu_usage - Nagios Plugin for checking CPU Usage in percentage
Usage: /usr/local/nagios/libexec/check_cpu_usage -w <warnlevel> -c <critlevel>
= warnlevel and critlevel is warning and critical value for alerts.
EXAMPLE: /usr/lib64/nagios/plugins//usr/local/nagios/libexec/check_cpu_usage -w 80 -c 90
= This will send warning alert when CPU Usage percentage is higher than 80%, and send critical when higher than 90
Here are my config files in localhost.cfg
define service {
use local-service
host_name localhost
service_description CPU Usage
check_command check_cpu_usage
}
in the commands.cfg
define command {
command_name check_cpu_usage
command_line $USER1$/check_cpu_usage -w $ARG1$ -c $ARG2$
}
and the script itself which is located in /usr/local/nagios/libexec
#!/bin/sh
# Version 0.2
#
# ### History ###
# V0.1 Created script from CPU Idle script
# V0.2 Handle dicimal compare and output
if [ "$1" = "-w" ] && [ "$2" -gt "0" ] && [ "$3" = "-c" ] && [ "$4" -gt "0" ] ; then
warn=$2
crit=$4
IDLE=`top -b -n2|grep Cpu|tail -1|cut -d',' -f4|cut -d% -f1`
USAGE=`echo "100 - $IDLE"|bc|sed -r 's/^\./0./g'` ||exit 3
# echo "DEBUG: head: ${USAGE%%.*} tail: ${USAGE##*.} "
# echo "DEBUG: ||$USAGE_RAW|| , ||$USAGE||"
if [ $warn -lt ${USAGE%%.*} ];then
if [ $crit -lt ${USAGE%%.*} ]; then
echo "CRITICAL - CPU Usage = $USAGE %|CPU Usage=$USAGE%;;;;"
exit 2
else
echo "WARNING - CPU Usage = $USAGE %|CPU Usage=$USAGE%;;;;"
exit 1
fi
else
echo "OK - CPU Usage = $USAGE %|CPU Usage=$USAGE%;;;;"
exit 0
fi
else
echo "$0 - Nagios Plugin for checking CPU Usage in percentage "
echo ""
echo "Usage: $0 -w <warnlevel> -c <critlevel>"
echo " = warnlevel and critlevel is warning and critical value for alerts. "
echo ""
echo "EXAMPLE: /usr/lib64/nagios/plugins/$0 -w 80 -c 90 "
echo " = This will send warning alert when CPU Usage percentage is higher than 80%, and send critical when higher than 90%"
echo ""
exit 3
fi
Any help or hint is highly appreciated. Thanks in advance
Nagio CPU plugin
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagio CPU plugin
your command is looking for an $ARG1$ and $ARG2$ but you did not define them in your command
Try this
Try this
Code: Select all
use local-service
host_name localhost
service_description CPU Usage
check_command check_cpu_usage!80!90
}