Nagios check fortisandbox queue
From Initech Technical Wiki
#!/bin/bash
#
# File name : check_fortisandbox_queue
#
# Created by : Tim Price - Initech Consulting Limit (tim@initech.co.nz)
# Created date : 05-01-2018
# Version : 1.0
#
# Information : Check the total number of files in the FortiSandbox processing queues
#
# Usage:
# check_fortisandbox_queue [hostname] [snmp_community] [queue_warning_level] [queue_critical_level] [total_queue_warning_level] [total_queue_critical_level]
#
SNMP_HOST=${1}
SNMP_COMM=${2}
WARN_LEVEL=${3}
CRIT_LEVEL=${4}
TOTAL_WARN_LEVEL=${5}
TOTAL_CRIT_LEVEL=${6}
EXIT_CODE=0
## Error if no ARG is given
if [[ $# -lt 6 ]]
then
echo "Error - Not enough arguments: hostname (1), snmp_community (2), queue_warning_level (3) queue_critical_level (4) total_queue_warning_level (5) total_queue_critical_level (6)"
exit 3
else
# Check the queue length of executable files
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.1.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Executables/DLL/VBS/BAT/PS1/JAR/MSI queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Executables/DLL/VBS/BAT/PS1/JAR/MSI queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Executables/DLL/VBS/BAT/PS1/JAR/MSI queue size: ${QUEUE}"
fi
# Check the queue length of PDF files
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.2.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - PDF file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - PDF file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - PDF file queue size: ${QUEUE}"
fi
# Check the queue length of office document files
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.3.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Office document queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Office document queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Office document queue size: ${QUEUE}"
fi
# Check the queue length of shockwave flash animation files
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.4.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Flash file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Flash file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Flash file queue size: ${QUEUE}"
fi
# Check the queue length of web type files
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.5.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Web file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Web file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Web file queue size: ${QUEUE}"
fi
# Check the queue length of android files
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.6.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Android file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Android file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Android file queue size: ${QUEUE}"
fi
# Check the queue length of android files again - There is a duplicate in the MIB for some reason
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.7.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Android(2) file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Android(2) file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Android(2) file queue size: ${QUEUE}"
fi
# Check the queue length of URLs - Commonly from emails
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.8.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - URL job queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - URL job queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - URL job queue size: ${QUEUE}"
fi
# Check the queue length of user defined file extensions
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.9.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - User defined file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - User defined file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - User defined file queue size: ${QUEUE}"
fi
# Check the queue length of non-sandbox files - Not sure what this is for
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.10.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Non sandbox file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Non sandbox file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Non sandbox file queue size: ${QUEUE}"
fi
# Check the queue length of unassigned files - These are files that are yet to be assigned to a queue above
QUEUE=$(snmpget -v2c -c ${SNMP_COMM} ${SNMP_HOST} .1.3.6.1.4.1.12356.118.5.1.11.0 | awk '{print $4}')
TOTAL_QUEUE=$[TOTAL_QUEUE+QUEUE]
if [[ ${QUEUE} -ge ${CRIT_LEVEL} ]]; then
echo "CRITICAL - Unassigned file queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${QUEUE} -ge ${WARN_LEVEL} ]]; then
echo "WARNING - Unassigned file queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Unassigned file queue size: ${QUEUE}"
fi
# Check the sumtotal of all files in all queues
if [[ ${TOTAL_QUEUE} -ge ${TOTAL_CRIT_LEVEL} ]]; then
echo "CRITICAL - Total queue size: ${QUEUE}"
EXIT_CODE=2
elif [[ ${TOTAL_QUEUE} -ge ${TOTAL_WARN_LEVEL} ]]; then
echo "WARNING - Total queue size: ${QUEUE}"
if [ ${EXIT_CODE} -eq 0 ]; then
EXIT_CODE=1
fi
else
echo "OK - Total queue size: ${QUEUE}"
fi
exit $EXIT_CODE
fi