File run_stats of Package monitoring-plugins-nagiostats

#!/bin/bash
#
HOST=$(hostname -s)
CHECKNAME='stats'

while getopts 'H:c:h'  OPTION ; do
    case $OPTION in
		H) HOST="$OPTARG"
		;;
		c) CHECKNAME="$OPTARG"
		;;
		h) echo "Usage: $(basename $0) -H <hostname> -c <service check name>"
		   exit 0
	    ;;
 	esac
done
shift $(( OPTIND - 1 ))

if [ -x /etc/init.d/nagios ]; then
  if /etc/init.d/nagios status >/dev/null ; then
    CMDFILE='/var/run/nagios/nagios.cmd'
    if [ -p /var/run/nagios/nagios.cmd ]; then
        su - nagios  -c "/usr/lib/nagios/plugins/check_nagiostats --EXEC /usr/sbin/nagiostats --passive $HOST $CHECKNAME >> $CMDFILE"
    fi
  fi
fi

if [ -x /etc/init.d/icinga ]; then
  if /etc/init.d/icinga status >/dev/null ; then 
	CMDFILE='/var/run/icinga/icinga.cmd'
    if [ -p $CMDFILE ]; then
        su - icinga  -c "/usr/lib/nagios/plugins/check_nagiostats --EXEC /usr/sbin/icingastats --passive $HOST $CHECKNAME >> $CMDFILE"
    fi
  fi
fi