Difference between revisions of "Nagios check fortimail queue"
From Initech Technical Wiki
(Created page with "<pre> #!/bin/bash SAVEIFS=$IFS IFS=$(/bin/echo -en "\n\b") function USAGE { echo echo "####################################################################" echo "# File na...") |
|||
Line 7: | Line 7: | ||
echo | echo | ||
echo "####################################################################" | echo "####################################################################" | ||
− | echo "# File name : | + | echo "# File name : nagios_check_fortimail_queue" |
echo "# Created by : Tim Price - Initech Consulting ( for any questions contact me on tim@initech.nz )" | echo "# Created by : Tim Price - Initech Consulting ( for any questions contact me on tim@initech.nz )" | ||
echo "# Created date : 08/01/2018" | echo "# Created date : 08/01/2018" |
Latest revision as of 22:39, 7 January 2018
#!/bin/bash SAVEIFS=$IFS IFS=$(/bin/echo -en "\n\b") function USAGE { echo echo "####################################################################" echo "# File name : nagios_check_fortimail_queue" echo "# Created by : Tim Price - Initech Consulting ( for any questions contact me on tim@initech.nz )" echo "# Created date : 08/01/2018" echo "# Version : 1.0" echo "# Information : Check FortiMail Queues and message counts in each queue" echo "# Usage : $0 -H host -C community -w warning_count -c critical_count" echo "####################################################################" echo } while getopts ":H:C:w:c:" opt; do case $opt in H) HOST="$OPTARG" ;; C) SNMP_COMMUNITY="$OPTARG" ;; w) WARN="$OPTARG" ;; c) CRIT="$OPTARG" ;; \?) USAGE ;; esac done if [ "$HOST" == "" ] || [ "$SNMP_COMMUNITY" == "" ] || [ "$WARN" == "" ] || [ "$CRIT" == "" ]; then USAGE exit 0 fi EXIT_CODE=0 QUEUES=$(snmpwalk -On -v2c -c $SNMP_COMMUNITY $HOST .1.3.6.1.4.1.12356.105.1.103.2.1.1 | awk '{print $4}') for QUEUE in $QUEUES; do QUEUE_NAME=$(snmpget -On -v2c -c $SNMP_COMMUNITY $HOST .1.3.6.1.4.1.12356.105.1.103.2.1.2.$QUEUE | awk -F\" '{print $2}') QUEUE_COUNT=$(snmpget -On -v2c -c $SNMP_COMMUNITY $HOST .1.3.6.1.4.1.12356.105.1.103.2.1.3.$QUEUE | awk '{print $4}') if [[ $QUEUE_COUNT -ge $CRIT ]]; then echo "CRITICAL - $QUEUE_NAME: $QUEUE_COUNT messages" EXIT_CODE=2 elif [[ $QUEUE_COUNT -ge $WARN ]]; then echo "WARNING - $QUEUE_NAME: $QUEUE_COUNT messages" if [ ${EXIT_CODE} -eq 0 ]; then EXIT_CODE=1 fi else echo "OK - $QUEUE_NAME: $QUEUE_COUNT messages" fi done IFS=$SAVEIFS exit $EXIT_CODE