#!/bin/bash # Script: check_nna_flow_devices.sh # Purpose: Check number of running NetFlow or sFlow devices compared to the number configured devices on Nagios Network Analyzer server # Author: Jorgen van der Meulen (Conclusion Xforce) # Version: see print_version function # Change log: 0.1 - Initial creation # 0.2 - added type parameter # 0.3 - changed calculation of warning/critical thresholds (X-1 = warning, X-2 = critical) # 0.4 - improved explanation # 0.5 - changed status output, "device(s)" should be applicable to singular and plural device counts # # Requirements: Admin -> System Config \ System Settings -> Allow HTML Tags in Host/Service Status (checked) # Installation: This script should be placed on a Nagios Network Analyzer server, made executable and configured as an active or passive check. # Nagios client NCPA needs no configuration, just put it underneath directory /usr/local/ncpa/plugin/ # Nagios client NRPE needs some configuration, please read paragraph Customizing Your Configuration https://assets.nagios.com/downloads/nagioscore/docs/nrpe/NRPE.pdf #declare states STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 function print_version () { cat <NNA Sources Page and look for stopped devices" fi echo "${NAGRES}: ${FLOW_PROCESSES_DIVIDEDBYTWO} active ${flow_type} device(s) [total configured ${flow_type} devices: ${FLOW_SOURCES}] |${flow_type}DevsActive=$FLOW_PROCESSES_DIVIDEDBYTWO;$WARN;$CRIT;;" echo "Additional info: found ${FLOW_PROCESSES} process(es) on $(hostname) matching pattern ${PATTERN}, each configured device has two processes. ${REMEDIATE_HINT}" exit $NAGSTAT } # case "$1" in --help|-h) print_help exit $STATE_OK ;; --version|-V) print_version exit $STATE_OK ;; --type|-t) if [ "$#" != 2 ] ; then print_usage exit $STATE_UNKNOWN fi main_program $1 $2 ;; *) print_usage exit $STATE_UNKNOWN ;; esac