Nagios/checks/solaris zones

=Solaris Zones check=

this is to be run on Solaris Global zones (Solaris 10 servers which have zones on them)

Im not quite happy with the check but it will do for now.

Nagios service def
/opt/nagios/etc/global/services

define service{ use                            generic-service service_description            solaris_zones check_command                  check_nrpe!check_solaris_zones hostgroup_name                 solaris-global-zone }
 * 1) cat solaris_zones.cfg

NRPE Command defanition
Add this to the client in the commands folder '/opt/nagios/nrpe/nrpe-commands"

command[check_solaris_zones]=/opt/nagios/plugins/libexec/check_solaris_zones
 * 1) cat > solaris_zones.cfg

check_solaris_zones script
# # # MFS=${IFS} exit_code=0 exit_text="" errors_checker{ IFS="" if [ ${exit_text} ] then exit_text=${exit_text}" $1" else exit_text="$1" fi        if [ $2 -gt ${exit_code} ] then exit_code=$2 fi 	IFS=$MFS }
 * 1) !/bin/sh
 * 1) By Aldo Fabi 01-09-2006
 * 2) LTP: 04-10-2006
 * 1) Nagios zones Checker
 * 1) Begin vars
 * 1) End vars

STATUS=`/usr/sbin/zoneadm list -ip |grep -v "^0:global"` for ZONE in `echo ${STATUS}` do 	ZID=`echo ${ZONE} | cut -d":" -f1` ZNAME=`echo ${ZONE} | cut -d":" -f2` ZSTATE=`echo ${ZONE} | cut -d":" -f3` if [ $ZSTATE = 'running' ] then errors_checker "OK: zone $ZNAME is in running state" 0 else errors_checker "CRITICAL: Zone $ZNAME is in $ZSTATE state" 2 fi done echo ${exit_text} exit ${exit_code}