What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom SSH Sensor w/ Asterisk

Votes:

0

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!!

asterisk prtg ssh

Created on Feb 9, 2015 11:17:29 PM

Last change on Feb 10, 2015 1:03:15 PM by  Torsten Lindner [Paessler Support]



Best Answer

Accepted Answer

Votes:

1

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!

Created on Feb 10, 2015 5:29:15 PM

Last change on Jan 20, 2016 11:30:10 AM by  Luciano Lingnau [Paessler]



5 Replies

Votes:

0

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.

Created on Feb 10, 2015 12:47:48 PM



Votes:

0

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.

Created on Feb 10, 2015 4:13:12 PM by  Arne Seifert [Paessler Support]



Votes:

0

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 

Created on Feb 10, 2015 5:06:08 PM



Accepted Answer

Votes:

1

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!

Created on Feb 10, 2015 5:29:15 PM

Last change on Jan 20, 2016 11:30:10 AM by  Luciano Lingnau [Paessler]



Votes:

0

Thank you for posting the solution to your problem.

Created on Feb 10, 2015 5:58:15 PM by  Arne Seifert [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.