From 2ba163a879c1e4e9633a86c1304bea6218cb1964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Gu=C3=B0j=C3=B3n=20Sigur=C3=B0sson?= Date: Tue, 14 Dec 2010 16:23:02 +0000 Subject: [PATCH] check_ironport plugin added --- check_bond/trunk/nrpe.d/check_bond.cfg | 3 + check_ironport/trunk/check_ironport | 311 +++++++++++++++++++++++++ check_ironport/trunk/xml.status | 149 ++++++++++++ check_rhcs/trunk/nrpe.d/check_rhcs.cfg | 7 +- check_uptime/trunk/check_uptime.sh | 2 +- 5 files changed, 468 insertions(+), 4 deletions(-) create mode 100644 check_bond/trunk/nrpe.d/check_bond.cfg create mode 100755 check_ironport/trunk/check_ironport create mode 100644 check_ironport/trunk/xml.status diff --git a/check_bond/trunk/nrpe.d/check_bond.cfg b/check_bond/trunk/nrpe.d/check_bond.cfg new file mode 100644 index 0000000..2aa8092 --- /dev/null +++ b/check_bond/trunk/nrpe.d/check_bond.cfg @@ -0,0 +1,3 @@ +command[check_bond]=/usr/lib64/nagios/plugins/check_bond -i '$ARG1$' + +command[check_bond_bond0]=/usr/lib64/nagios/plugins/check_bond -i bond0 diff --git a/check_ironport/trunk/check_ironport b/check_ironport/trunk/check_ironport new file mode 100755 index 0000000..ab1a58a --- /dev/null +++ b/check_ironport/trunk/check_ironport @@ -0,0 +1,311 @@ +#!/bin/sh +# Plugin to check Ironport Appliances +# Desarrollado por Claudio Saavedra (20080120) +# Translated to english by Steven Geerts (20080316) +# Added various extra checks by Steven Geerts (20080830) +# Added performance data in the output of the result so graphs can be generated - Yan Bisson (20090625) + + +# input parameters +HOSTNAME=$1 +USER=$2 +PASSWORD=$3 +ARGS=$4 +PAR_WARN=$5 +PAR_CRIT=$6 + + +#STATUSFILE=/tmp/status.`echo $RANDOM$RANDOM|cut -c1-4` +STATUSFILE=/tmp/xml.status + +# Nagios return codes +STATE_OK=0 +STATE_WARNING=1 +STATE_CRITICAL=2 +STATE_UNKNOWN=3 +STATE_DEPENDENT=4 + +PROGNAME=`basename $0` + +print_usage() { + echo "" + echo "Usage: $PROGNAME " + echo "" + echo "Notes:" + echo " hostname - Can be a hostname or IP address" + echo " parameter - Can be status, cpu, ram, msgxhour, conn_in, conn_out, queue, workqueue," + echo " msgs_in_quarantine, disk_util, queuedisk_usage or resourseconservation" + echo "" + echo "parameters for STATUS are ignored but must be provided. The results for STATUS can be OK or critical." + echo "parameters for RESOURSECONSERVATION should be 1 and 2." +} +# XML Parameter info: +# DONE +# DONE +# DONE +# +# +# +# +# DONE +# DONE +# +# +# DONE +# DONE +# +# DONE +# DONE +# DONE +# +# DONE +# DONE +# DONE +# +# +# + +while test -n "$1"; do + case "$1" in + --help) + print_usage + exit $STATE_OK + ;; + -h) + print_usage + exit $STATE_OK + ;; + esac + shift +done + +# Check arguments for validity +if [ -z ${HOSTNAME} ]; then + echo "Please specify the hostname!" + print_usage + exitstatus=$STATE_UNKNOWN + exit $exitstatus +fi + +if [ $PAR_WARN -ge $PAR_CRIT ]; then + exitstatus=$STATE_UNKNOWN + echo "The WARNING number can not be larger or equal to the CRITICAL number!" + exit $exitstatus +fi + +#wget --http-user=$USER --http-password=$PASSWORD --no-check-certificate --no-proxy https://$HOSTNAME/xml/status --output-document=$STATUSFILE >> /dev/null 2>&1 +#wget --http-user=$USER --http-password=$PASSWORD --no-check-certificate https://$HOSTNAME/xml/status --output-document=$STATUSFILE >> /dev/null 2>&1 + + + +if [ $? -ne 0 ]; then + exitstatus=${STATE_UNKNOWN} + echo "" + echo "Can't collect data from an Ironpor appliance Ironport. Verify hostname, userID and password!" + rm -rf $STATUSFILE + exit $exitstatus +else + exitstatus=${STATE_OK} +fi + +case "$ARGS" in + +# DONE +# DONE + status) + IPORTPAR=`grep "system status" $STATUSFILE | cut -d\" -f 2` + if [ $IPORTPAR = online ]; then + exitstatus=${STATE_OK} + echo "STATUS OK: $IPORTPAR" "| RESULT=1;" + else + exitstatus=${STATE_CRITICAL} + echo "STATUS CRITICAL: $IPORTPAR" "| RESULT=0;" + fi + ;; + + cpu) + IPORTPAR=`grep total_utilization $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "CPU CRITICAL: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "CPU WARNING: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "CPU OK: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + fi + ;; + ram) + IPORTPAR=`grep ram_utilization $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "RAM CRITICAL: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "RAM WARNING: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "RAM OK: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + fi + ;; + msgxhour) + IPORTPAR=`grep -A 3 "rate name=\"inj_msgs" $STATUSFILE | grep last_15_min | cut -d\" -f 2 ` + echo $IPORTPAR $PAR_WARN + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "MAIL RATE CRITICAL: $IPORTPAR msgs/hr" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "MAIL RATE WARNING: $IPORTPAR msgs/hr" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "MAIL RATE OK: $IPORTPAR msgs/hr" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + ;; + conn_in) + IPORTPAR=`grep conn_in $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "Incomming Connections CRITICAL: $IPORTPAR connections" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "Incomming Connections WARNING: $IPORTPAR connections" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "Incomming Connections OK: $IPORTPAR connections" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + + fi + ;; + conn_out) + IPORTPAR=`grep conn_out $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "Outgoing Connections CRITICAL: $IPORTPAR connections" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "Outgoing Connections WARNING: $IPORTPAR connections" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "Outgoing Connections OK: $IPORTPAR connections" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + ;; + + queue) + IPORTPAR1=`grep \"attempted_recips $STATUSFILE | cut -d\" -f 4` + IPORTPAR2=`grep unattempted_recips $STATUSFILE | cut -d\" -f 4` + IPORTPAR=`expr $IPORTPAR1 + $IPORTPAR2` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "QUEUE CRITICAL: $IPORTPAR msgs" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "QUEUE WARNING: $IPORTPAR msgs" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "QUEUE OK: $IPORTPAR msgs" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + ;; + workqueue) + IPORTPAR=`grep msgs_in_work_queue $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "WORKQUEUE CRITICAL: $IPORTPAR msgs" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "WORKQUEUE WARNING: $IPORTPAR msgs" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "WORKQUEUE OK: $IPORTPAR msgs" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + ;; + resourseconservation) + IPORTPAR=`grep resource_conservation $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "RESOURSECONSERVATION CRITICAL: $IPORTPAR" "| RESULT=$IPORTPAR;" + else + exitstatus=${STATE_WARNING} + echo "RESOURSECONSERVATION WARNING: $IPORTPAR" "| RESULT=$IPORTPAR;" + fi + else + exitstatus=${STATE_OK} + echo "RESOURSECONSERVATION OK: $IPORTPAR " "| RESULT=$IPORTPAR;" + fi + ;; + disk_util) + IPORTPAR=`grep disk_utilization $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "Disk Utilization CRITICAL: $IPORTPAR " "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "Disk Utilization WARNING: $IPORTPAR " "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "Disk Utilization OK: $IPORTPAR" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + ;; + msgs_in_quarantine) + IPORTPAR=`grep msgs_in_quarantine $STATUSFILE | cut -d\" -f 4` + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "MSG In Quarantine CRITICAL: $IPORTPAR" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "MSG In Quarantine WARNING: $IPORTPAR" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "MSG In Quarantine OK: $IPORTPAR" "| RESULT=$IPORTPAR;$PAR_WARN;$PAR_CRIT;" + fi + ;; + queuedisk_usage) + IPORTPAR1=`grep kbytes_free $STATUSFILE | cut -d\" -f 4` + IPORTPAR2=`grep kbytes_used $STATUSFILE | cut -d\" -f 4` + IPORTPAR3="$(( $IPORTPAR1 / 100 ))" + IPORTPAR="$(( $IPORTPAR2 / $IPORTPAR3 ))" + if [ $IPORTPAR -ge $PAR_WARN ]; then + if [ $IPORTPAR -ge $PAR_CRIT ]; then + exitstatus=${STATE_CRITICAL} + echo "QueueDisk Usage CRITICAL: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + else + exitstatus=${STATE_WARNING} + echo "QueueDisk Usage WARNING: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + fi + else + exitstatus=${STATE_OK} + echo "QueueDisk Usage OK: $IPORTPAR%" "| RESULT=$IPORTPAR%;$PAR_WARN;$PAR_CRIT;" + fi + ;; + + + + *) + print_usage + exit $STATE_OK +esac + +#rm -rf $STATUSFILE + +exit $exitstatus + + diff --git a/check_ironport/trunk/xml.status b/check_ironport/trunk/xml.status new file mode 100644 index 0000000..3323d29 --- /dev/null +++ b/check_ironport/trunk/xml.status @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/check_rhcs/trunk/nrpe.d/check_rhcs.cfg b/check_rhcs/trunk/nrpe.d/check_rhcs.cfg index de461c0..9bfc156 100644 --- a/check_rhcs/trunk/nrpe.d/check_rhcs.cfg +++ b/check_rhcs/trunk/nrpe.d/check_rhcs.cfg @@ -1,5 +1,5 @@ -command[check_rhcs]=/usr/lib64/nagios/plugins/check_rhcs -H rek-oraheart-p04 -c -command[check_rhcs_service]=/usr/lib64/nagios/plugins/check_rhcs -s '$ARG1$' +command[check_rhcs]=sudo /usr/lib64/nagios/plugins/check_rhcs -H rek-oraheart-p04 -c +command[check_rhcs_service]=sudo /usr/lib64/nagios/plugins/check_rhcs -s '$ARG1$' command[get_rhcs_fencing]=test ! -p /tmp/fence_manual.fifo command[check_rhcs_fencing]=/usr/lib64/nagios/plugins/check_rhcs_manualfencing.sh @@ -12,4 +12,5 @@ command[get_rhcs_cman_group_rgmanager]=/sbin/group_tool ls 1 rgmanager command[check_rhcs_cman_group]=/usr/lib64/nagios/plugins/check_rhcs_cman_group.sh --level '$ARG1$' --group '$ARG2$' command[check_rhcs_cman_group_default]=/usr/lib64/nagios/plugins/check_rhcs_cman_group.sh --level 0 --group default -command[check_rhcs_cman_group]_rgmanager=/usr/lib64/nagios/plugins/check_rhcs_cman_group.sh --level 1 --group rgmanager +command[check_rhcs_cman_group_rgmanager]=/usr/lib64/nagios/plugins/check_rhcs_cman_group.sh --level 1 --group rgmanager + diff --git a/check_uptime/trunk/check_uptime.sh b/check_uptime/trunk/check_uptime.sh index 36adbd4..2dac09e 100644 --- a/check_uptime/trunk/check_uptime.sh +++ b/check_uptime/trunk/check_uptime.sh @@ -54,7 +54,7 @@ done # We we are not checking localhost, lets get remote uptime via NRPE if [ "$HOSTN" != "localhost" ]; then - export PATH=$PATH:/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins + export PATH=$PATH:/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins:/nagios/usr/lib/nagios/plugins CHECK_COMMAND="check_nrpe -H $HOSTN -c get_uptime" fi