#!/bin/sh
. /usr/lib64/nagios/plugins/utils.sh

if [ $# -ge 1 ]; then
    CHECKS="$(
	/usr/bin/fs checks -cell "$1" -fast &&
	cd "/afs/$1" &&
	/bin/dash -c '[ "$(pwd -P)" ]' 2>&1
    )"
else
    CHECKS=`/usr/bin/fs checks -all -fast`
fi

STATUS=$?

$ECHO "$CHECKS"

if [ $STATUS -gt 0 ]; then
    if $ECHO "$CHECKS" | grep -i STYX >/dev/null; then
	exit $STATE_CRITICAL;
    else
	exit $STATE_WARNING;
    fi
else
    exit $STATE_OK;
fi
