Null Status Information on my bash script

I created a simple bash script to monitor my queue mail. When I run the script in shell, it has an output. But when I configured the command.cfg in Nagios, there is no Status Information. It was just null displaying.

[code]#!/bin/bash

if ! -n $1 ];then
echo "Missing HOSTNAME Argument"
exit 1
fi

if ! -n $2 ];then
echo "Missing WARNING Argument"
exit 1
fi

if ! -n $3 ];then
echo "Missing CRITICAL Argument"
exit 1
fi

QUEUE=sudo /usr/bin/qmqtool -s | grep "local recipients" | awk '{print $5}'

if $QUEUE -eq 0 ];then
echo "No mail queue"
exit 0
fi

if $QUEUE -gt 1 ] && $QUEUE -lt 5 ];then
echo "WARNING: there is $QUEUE"
exit 1
fi

if $QUEUE -gt 5 ];then
echo "CRITICAL: there is $QUEUE. Please check ASAP!!"
exit 2
fi
[/code]

Have you tried to su to the Nagios user and execute the script? My guess is Nagios service account you are using doesn’t have rights to use the sudo command you’re using.