#!/bin/bash # SYNOPSIS # check_pbsmom [] [] ... # # DESCRIPTION # This NAGIOS plugin checks whether: 1) pbs_mom is running and # 2) the host is listening on the given port(s). If no port # number is specified TCP ports 15002 and 15003 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="15002 15003" else list="$*" fi if [ `ps -C pbs_mom | wc -l` -lt 2 ]; then echo "PBS_MOM 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 "PBS_MOM CRITICAL: Host is NOT listening on TCP port $port!" exit $CRITICAL fi done echo "PBS_MOM OK: Daemon is running. Host is listening." exit $OK fi