#!/bin/bash # SYNOPSIS # check_pbssched [] [] ... # # DESCRIPTION # This NAGIOS plugin checks whether: 1) maui is running and # 2) the host is listening on the given port(s). If no port # number is specified TCP ports 15001 and 42559 are checked. # # AUTHOR # Wayne.Mallett@jcu.edu.au OK=0 WARN=1 CRITICAL=2 PATH="/bin:/sbin:/usr/bin:/usr/sbin" # Default listening ports are TCP 15004 and 42559. if [ $# -lt 1 ] ; then list="15004 42559" else list="$*" fi if [ `ps -C maui | wc -l` -lt 2 ]; then echo "MAUI CRITICAL: Daemon is NOT running!" exit $CRITICAL else for port in $list ; do if [ `netstat -ln | grep -E "tcp.*:$port" | wc -l` -lt 1 ]; then echo "MAUI CRITICAL: Host is NOT listening on TCP port $port!" exit $CRITICAL fi done echo "MAUI OK: Daemon is running. Host is listening." exit $OK fi