#!/bin/sh


# declarations
# ============

URL="http://admin.gymkirchenfeld.ch/wiki/doku.php?do=check"

# exit codes expected by nagios
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3

# load wiki site
# search for a notification and get the corresponding message
NOTIFICATION="$(wget -qO- --post-data 'u=icinga&p=testING1234' https://admin.gymkirchenfeld.ch/wiki/doku.php?do=check | grep 'class="notify"')"

if [ $? -ne 0 ]
then
	echo "Latest dokuwiki version installed."
	exit ${OK}
else
	MSG="$(echo ${NOTIFICATION} | sed -e 's/^ *<div class="notify">//')"
	echo "Dokuwiki notification: ${MSG}"
	exit ${WARNING}
fi

echo "This point should not be reachable..."
exit ${UNKNOWN}
