#icinga #icinga
#vim /etc/nagios/nrpe.cfg
allowed_hosts=198.50.155.195, 127.0.0.1
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_mailq]=/usr/lib/nagios/plugins/check_mailq -w 300 -c 500
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
root@vps:/usr/lib/nagios/plugins# ls -l /usr/lib/nagios/plugins/check_mailq
-rwxr-xr-x 1 root root 916 Aug 15 16:34 /usr/lib/nagios/plugins/check_mailq*
#cat /usr/lib64/nagios/plugins/check_mailq
#!/bin/bash
#
# 19-07-2010
# Author: Cherwin Nooitmeer <cherwin@gmail.com>
#
# exit codes
e_ok=0
e_warning=1
e_critical=2
e_unknown=3
# regular expression that matches queue IDs (e.g. D71EF7AC80F8)
queue_id='^[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]'
usage="Invalid command line usage"
if [ -z $1 ]; then
echo $usage
exit $e_unknown
fi
while getopts ":w:c:" options
do
case $options in
w ) warning=$OPTARG ;;
c ) critical=$OPTARG ;;
* ) echo $usage
exit $e_unknown ;;
esac
done
# determine queue size
qsize=$(mailq | egrep -c $queue_id)
if [ -z $qsize ]
then
exit $e_unknown
fi
if [ $qsize -ge $critical ]; then
retval=$e_critical
elif [ $qsize -ge $warning ]; then
retval=$e_warning
elif [ $qsize -lt $warning ]; then
retval=$e_ok
fi
echo "$qsize mail(s) in queue | mail_queue=$qsize"
exit $retval
===========@ In ICINGA server -===============
#no need to add nrpe user in sudoer file
# /usr/local/icinga/libexec/check_nrpe -H 5.9.240.227 -c check_mailq
358 mail(s) in queue | mail_queue=358
#vim /etc/nagios/nrpe.cfg
allowed_hosts=198.50.155.195, 127.0.0.1
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_mailq]=/usr/lib/nagios/plugins/check_mailq -w 300 -c 500
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
root@vps:/usr/lib/nagios/plugins# ls -l /usr/lib/nagios/plugins/check_mailq
-rwxr-xr-x 1 root root 916 Aug 15 16:34 /usr/lib/nagios/plugins/check_mailq*
#cat /usr/lib64/nagios/plugins/check_mailq
#!/bin/bash
#
# 19-07-2010
# Author: Cherwin Nooitmeer <cherwin@gmail.com>
#
# exit codes
e_ok=0
e_warning=1
e_critical=2
e_unknown=3
# regular expression that matches queue IDs (e.g. D71EF7AC80F8)
queue_id='^[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]'
usage="Invalid command line usage"
if [ -z $1 ]; then
echo $usage
exit $e_unknown
fi
while getopts ":w:c:" options
do
case $options in
w ) warning=$OPTARG ;;
c ) critical=$OPTARG ;;
* ) echo $usage
exit $e_unknown ;;
esac
done
# determine queue size
qsize=$(mailq | egrep -c $queue_id)
if [ -z $qsize ]
then
exit $e_unknown
fi
if [ $qsize -ge $critical ]; then
retval=$e_critical
elif [ $qsize -ge $warning ]; then
retval=$e_warning
elif [ $qsize -lt $warning ]; then
retval=$e_ok
fi
echo "$qsize mail(s) in queue | mail_queue=$qsize"
exit $retval
===========@ In ICINGA server -===============
#no need to add nrpe user in sudoer file
# /usr/local/icinga/libexec/check_nrpe -H 5.9.240.227 -c check_mailq
358 mail(s) in queue | mail_queue=358
No comments:
Post a Comment