I'm trying to write a custom SSH Sensor that shows how many active calls there are in my Asterisk server. This is my script:
#!/bin/bash CALLS=$(asterisk -rx 'sip show channels' | grep ulaw | wc -l) echo "0:$CALLS:OK"
Every time I run it, I get this error: Response not wellformed: "/var/prtg/scripts/activecalls.sh: line 2: asterisk: command not found 0:0:OK " (code: PE132)
Help!!
Article Comments
Dear skyeblue
For additional debugging please activate "Write result to disk" in the sensor settings and check the input the SSH Script Sensor gets. The sensor should get a message like
0:0:OK
or a similar message.
Feb, 2015 - Permalink
Heres the results:
What is "echo PAESSHSTART;"?
[ping@li230-75 ]$ echo PAESSHSTART;/var/prtg/scripts/activecalls.sh ;echo;echo PAESSHEND;exit PAESSHSTART /var/prtg/scripts/activecalls.sh: line 2: asterisk: command not found 0:0:OK
PAESSHEND logout [H[J
Feb, 2015 - Permalink
I figured it out. I was using a non-root user, and only root can execute on the asterisk cli. For reference, I've written a small applet for others to get around this restriction.
int main (int argc, char *argv[]) { argv[0] = "/usr/sbin/asterisk"; argv[1] = "-rx"; argv[2] = "sip show channelstats"; execv(*argv, argv); }
Compile that with GCC:
$ gcc calls.c -o calls |
and then let it run as root:
$ sudo chown root dialplan-reload |
$ sudo chmod u+s dialplan-reload |
I hope this is helpful!
Feb, 2015 - Permalink
Could you please try to format the code of your script as it appears in the script file? I suppose the script doesn't have all the commands in one line.
Feb, 2015 - Permalink