Confused about device response

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
w14219
Posts: 33
Joined: Wed Feb 15, 2012 2:04 am

Confused about device response

Post by w14219 »

Can someone tell me why I am not getting back anything else but: Unknown argument: 90,90%


Below are my configuration files and script.
switch.cfg
define service{
use generic-service
hostgroup_name Mikrotik_RG411
service_description tx-ccq
check_command mk_tx_ccq!90,90%!80,80%
}

command.cfg
define command{
command_name mk_tx_ccq
command_line $USER1$/mk_tx_ccq -H $HOSTADDRESS$ -U $ARG3$ -w $ARG1$ -c $ARG2$
}

Script:
###########################################
readccq=`cat /tmp/$host-ccq-status.txt|grep tx-ccq| grep -v overall-tx-ccq`
txccq=${readccq//[^0-9]/}

if [ $txccq -ge $warn ]
then
echo "tx-ccq OK = $txccq"
EXITCODE=0
elif [ $txccq -ge $critical ]
then
echo "tx-ccq WARNING less than 90% = $txccq"
EXITCODE=1
else
echo "tx-ccq CRITICAL less than 80% = $txccq"
EXITCODE=2
fi
exit ${EXITCODE}

Goal:
I would like to return the needed values to update nagiosgraph and nagios core.

Thank you,
Mike
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Confused about device response

Post by agriffin »

Your command is expanding to:

Code: Select all

mk_tx_ccq -H <some_ip_addr> -U  -w 90,90% -c 80,80%
It looks to me like something should come after '-U' and before '-w', but you never provided a value for $ARG3$ in your service definition. Also, the script you posted is not very comprehensible. It seems like you just posted the end of it, but without context it doesn't really make sense.
w14219
Posts: 33
Joined: Wed Feb 15, 2012 2:04 am

Re: Confused about device response

Post by w14219 »

You are correct. Please allow me to fix that.

Here is the entire script.

#!/bin/bash
###########################################
## Do basic check on arguments passed to the script.
while test -n "$1"; do
case "$1" in
-H)
host="$2"
shift
;;
-U)
account="$2"
shift
;;
-w)
warn="$2"
shift
;;
-c)
critical="$2"
shift
;;
*)
echo "Unknown argument: $1"
exit $STATE_UNKNOWN
;;
esac
shift
done
###########################################
readccq=`cat /tmp/$host-ccq-status.txt|grep tx-ccq| grep -v overall-tx-ccq`
txccq=${readccq//[^0-9]/}

if [ $txccq -ge $warn ]
then
echo "tx-ccq OK = $txccq"
EXITCODE=0
elif [ $txccq -ge $critical ]
then
echo "tx-ccq WARNING less than 90% = $txccq"
EXITCODE=1
else
echo "tx-ccq CRITICAL less than 80% = $txccq"
EXITCODE=2
fi
exit ${EXITCODE}
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Confused about device response

Post by agriffin »

Okay, so $account is getting set to "-w" since you didn't provide an argument to the -U option. It doesn't seem like you use that variable at all in your script, so you should change your command definition to:

Code: Select all

define command{
command_name mk_tx_ccq
command_line $USER1$/mk_tx_ccq -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$
}
w14219
Posts: 33
Joined: Wed Feb 15, 2012 2:04 am

Re: Confused about device response

Post by w14219 »

You nailed the issue with the script. Thank you.

Any idea why nagiosgraph does not pickup on the new data?

Thanks!
Locked