Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
:
icinga
:
production
>
nagios-plugins-nis
> check_nis_1.1
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File check_nis_1.1 of Package nagios-plugins-nis
#!/bin/sh ############################################### # # Nagios script to check NIS status on a host # # See usage for command line switches # # Created: 2006-07-04 (i.yates@uea.ac.uk) # Updated: 2007-07-30 (i.yates@uea.ac.uk) - Added user lookup and error checking # ############################################### . /usr/lib/nagios/plugins/utils.sh VERSION="1.1" AWK=/bin/awk SED=/bin/sed GREP=/bin/grep YPPOLL=/usr/sbin/yppoll YPCAT=/usr/bin/ypcat FLAG_VERBOSE=FALSE NIS_HOST="" NIS_DOMAIN="" NIS_USER_TEST="" RESULT="" EXIT_STATUS=$STATE_OK ############################################### # ## FUNCTIONS # ## Print usage usage() { echo " check_nis $VERSION - Nagios NIS check script" echo "" echo " Usage: check_nis -H <hostname> -d <nis domain> [ -u <username> ] [ -v ] [ -h ]" echo "" echo " -H Name of host running the NIS service you wish to check" echo " -d NIS domain" echo " -u Username to query NIS with" echo " -v Verbose output" echo " -h Show this page" echo "" } ## Process command line options doopts() { if ( `test 0 -lt $#` ) then while getopts H:d:u:vh myarg "$@" do case $myarg in h|\?) usage exit;; H) NIS_HOST=$OPTARG;; d) NIS_DOMAIN=$OPTARG;; u) NIS_USER_TEST=$OPTARG;; v) FLAG_VERBOSE=TRUE;; *) # Default usage exit;; esac done else usage exit fi } # Write output and return result theend() { echo $RESULT exit $EXIT_STATUS } # ## END FUNCTIONS # ############################################# # ## MAIN # # Handle command line options doopts $@ # Do the do OUTPUT=`$YPPOLL -h $NIS_HOST -d $NIS_DOMAIN passwd.byname 2> /dev/null | $GREP 'is supported'` if test "$OUTPUT" != "" ; then if test -n "$NIS_USER_TEST" ; then ## If we're checking user lookup OUTPUT=`$YPCAT -h $NIS_HOST -d $NIS_DOMAIN passwd | grep $NIS_USER_TEST` if test -n "$OUTPUT" ; then OUTPUT=`echo "$OUTPUT" | grep "RPC"` if test "$OUTPUT" != "" ; then RESULT="NIS CRITICAL - domain $NIS_DOMAIN, user \"$NIS_USER_TEST\" lookup failed" EXIT_STATUS=$STATE_CRITICAL else RESULT="NIS OK - domain $NIS_DOMAIN, user \"$NIS_USER_TEST\" lookup succeeded" EXIT_STATUS=$STATE_OK fi else RESULT="NIS CRITICAL - domain $NIS_DOMAIN, user \"$NIS_USER_TEST\" lookup failed" EXIT_STATUS=$STATE_CRITICAL fi else RESULT="NIS OK - domain $NIS_DOMAIN" EXIT_STATUS=$STATE_OK fi else RESULT="NIS CRITICAL - domain $NIS_DOMAIN not answering" EXIT_STATUS=$STATE_CRITICAL fi # Quit and return information and exit status theend