Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot get result of Calls using check_asterisk_ami #2

Open
ChenYiHsiang opened this issue Sep 21, 2017 · 5 comments
Open

cannot get result of Calls using check_asterisk_ami #2

ChenYiHsiang opened this issue Sep 21, 2017 · 5 comments

Comments

@ChenYiHsiang
Copy link

Hi,
Nice plug-in for asterisk monitoring,
But I found one issue and I don't know how to fix.

the result I've got below.

[root@localhost libexec]# ./check_asterisk_ami -H XXXXXXXX -q sippeers -u admin -p XXXXXXXX -P 5038 -w 100 -c 20 OK: 20 online, 6 offline SIP peers|online=20 offline=6
[root@localhost libexec]# ./check_asterisk_ami -H XXXXXXXX -q channels -u admin -p XXXXXXXX -P 5038 -w 100 -c 20 OK: 0 Asterisk calls active|channels=0
[root@localhost libexec]# ./check_asterisk_ami -H XXXXXXXX -q calls -u admin -p XXXXXXXX -P 5038 -w 100 -c 20
./check_asterisk_ami: line 166: [: Output:: integer expression expected
./check_asterisk_ami: line 169: [: Output:: integer expression expected
./check_asterisk_ami: line 172: [: Output:: integer expression expected

and the code is :
...
166 if [ $CALLS -lt $WARNINGNUMBER ]; then
167 exitstatus=$STATE_OK
168 MSG="OK: ${CALLS} Asterisk calls active|calls=${CALLS}"
169 elif [ $CALLS -lt $CRITICALNUMBER ]; then
170 exitstatus=$STATE_WARNING
171 MSG="WARNING: ${CALLS} Asterisk calls active|calls=${CALLS}"
172 elif [ $CALLS -ge $CRITICALNUMBER ]; then
173 exitstatus=$STATE_CRITICAL
174 MSG="CRITICAL: ${CALLS} Asterisk calls active|calls=${CALLS}"
175 fi
...

I'm using lastest Nagios Core and CentOS 7
Is there any way to fix?

Sam

@JasonRivers
Copy link
Owner

Hi Sam, Sorry I completely missed this, There's no reason this shouldn't work so I'm possibly doing something silly.
I will take a look and see what is going on.
J

@dinaras
Copy link

dinaras commented Feb 19, 2020

Hello, same problem here
[root@nagios]# /usr/local/nagios/libexec/check_asterisk_ami -H myiphere -u myuser -p mypassword -q calls -w 10 -c 30
/usr/local/nagios/libexec/check_asterisk_ami: line 183: [: Output:: integer expression expected
/usr/local/nagios/libexec/check_asterisk_ami: line 186: [: Output:: integer expression expected
/usr/local/nagios/libexec/check_asterisk_ami: line 189: [: Output:: integer expression expected

Other commands work fine and also this same calls query works on some asterisk servers and on some not
Maybe asterisk has changed, using Asterisk 16

@litinoveweedle
Copy link

Hello,
went into same issue, @dinaras is right, Asterisk16 changed format of AMI output significantly (yes I agree, that it is stupid approach, but anyway):

Response: Success
Message: Command output follows
Output: Channel              Location             State   Application(Data)             
Output: 0 active channels
Output: 0 active calls
Output: 11 calls processed

so current awk expression is not catching correct column. But solution is rather simple, find around line 175 awk command:

awk '/active call/ {print $1}' | tr -d "\r"

and change it into

awk '/active call/ {print $2}' | tr -d "\r"

simple ;-)

@JasonRivers
Copy link
Owner

Wouldn't the print $2 break pre-asterisk 16 ?

Maybe the right thing here is to default to print $2 and have a "-lagacy" flag on the script for the old one.

It's probably safe (hah) to change to $2 now and have that as the default going forwards.

but yes... changing the format of something that people use to monitor their systems .... would be good it if had a real key / value output or api for monitoring! :-)

@litinoveweedle
Copy link

Wouldn't the print $2 break pre-asterisk 16 ?

Maybe the right thing here is to default to print $2 and have a "-lagacy" flag on the script for the old one.

It's probably safe (hah) to change to $2 now and have that as the default going forwards.

You are correct it would break compatibility with asterisk <= 13, but none should use it anyway, it is out of the support. :-), Version 16 is still supported in stable Debian.

but yes... changing the format of something that people use to monitor their systems .... would be good it if had a real key / value output or api for monitoring! :-)

This would be only one of the many wishes I would have. :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants