#!/usr/bin/bash # # CNR process monitor plugin for Nagios # Written by Thomas Sluyter (nagios@kilala.nl) # By request of DTV Labs, Liberty Global, the Netherlands # Last Modified: 19-06-2006 # # Usage: ./check_cnr # # Description: # This plugin determines whether the Cisco Network Register (CNR) # software is running properly. It will check the following: # * Are all required processes running? # * Do all the processes give reply to valid requests? # # Limitations: # Currently this plugin will only function correctly on Solaris systems. # # Output: # Script gives off a CRIT when one of the criteria for a running CNR # is not matched. # # Host OS check and warning message if [ `uname` != "SunOS" ] then echo "WARNING:" echo "This script was originally written for use on Solaris." echo "You may run into some problems running it on this host." echo "" echo "Please verify that the script works before using it in a" echo "live environment. You can easily disable this message after" echo "testing the script." echo "" fi # You may have to change this, depending on where you installed your # Nagios plugins PATH="/usr/bin:/usr/sbin:/bin:/sbin" LIBEXEC="/usr/local/nagios/libexec" . $LIBEXEC/utils.sh print_usage() { echo "Usage: $PROGNAME" echo "Usage: $PROGNAME --help" } print_help() { echo "" print_usage echo "" echo "Cisco Network Register (CNR) plugin for Nagios" echo "" echo "This plugin not developped by the Nagios Plugin group." echo "Please do not e-mail them for support on this plugin, since" echo "they won't know what you're talking about :P" echo "" echo "For contact info, read the plugin itself..." } while test -n "$1" do case "$1" in --help) print_help; exit $STATE_OK;; -h) print_help; exit $STATE_OK;; *) print_usage; exit $STATE_UNKNOWN;; esac done check_processes() { PROCESS="0" if [ `ps -ef | grep nwreg | grep aicservagt | grep -v grep | wc -l` -lt 1 ]; then PROCESS=1;fi if [ `ps -ef | grep nwreg | grep aiclockmgr | grep -v grep | wc -l` -lt 1 ]; then PROCESS=1;fi if [ `ps -ef | grep nwreg | grep mcdsvr | grep -v grep | wc -l` -lt 1 ]; then PROCESS=1;fi if [ `ps -ef | grep nwreg | grep dhcp | grep -v grep | wc -l` -lt 1 ]; then PROCESS=1;fi if [ `ps -ef | grep nwreg | grep dns | grep -v grep | wc -l` -lt 1 ]; then PROCESS=1;fi if [ `ps -ef | grep nwreg | grep tftp | grep -v grep | wc -l` -lt 1 ]; then PROCESS=1;fi if [ $PROCESS -eq 1 ]; then echo "CNR NOK - One or more processes not running" exitstatus=$STATE_CRITICAL exit $exitstatus fi } check_dhcp() { DHCP="0" # ADD CHECKS HERE if [ $DHCP -eq 1 ]; then echo "CNR NOK - DHCP not behaving properly." exitstatus=$STATE_CRITICAL exit $exitstatus fi } check_dns() { DNS="0" # ADD CHECKS HERE if [ $PROCESS -eq 1 ]; then echo "CNR NOK - DNS not behaving properly." exitstatus=$STATE_CRITICAL exit $exitstatus fi } check_tftp() { TFTP="0" # ADD CHECKS HERE if [ $PROCESS -eq 1 ]; then echo "CNR NOK - TFTP not behaving properly." exitstatus=$STATE_CRITICAL exit $exitstatus fi } check_processes check_dhcp check_dns check_tftp echo "CNR OK - Everything running like it should" exitstatus=$STATE_OK exit $exitstatus