#!/bin/sh

if test -r /etc/debian-edu/config ; then
    . /etc/debian-edu/config
fi

# Only Main-Server got Nagios running
if echo "$PROFILE" | grep -q Main-Server ; then
    :
else
    exit 0
fi

if [ -x /usr/sbin/nagios3 ] ; then
    echo "success: $0: Found /usr/sbin/nagios3 binary."
else
    echo "error: $0: Missing /usr/sbin/nagios3."
fi

if [ -x /usr/sbin/nagios3stats ] ; then
    for field in NUMSVCCRIT NUMSVCWARN NUMSVCUNKN; do
	count="$(nagios3stats -m -d$field)"
	if [ 0 = "$count" ] ; then
	    echo "success: $0: Nagios count $field is zero."
	else
	    echo "error: $0: Nagios count $field is not zero but $count."
	fi
    done
else
    echo "error: $0: Missing /usr/sbin/nagios3stats."
fi
