New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Custom SSH Sensor w/ Asterisk

Votes:

0

Your Vote:

Up

Down

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 by  skyeblue (60) 1 1

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



Best Answer

Accepted Answer

Votes:

1

Your Vote:

Up

Down

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 by  skyeblue (60) 1 1

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



5 Replies

Votes:

0

Your Vote:

Up

Down

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 by  ages (977) 5 1



Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

Heres the results:

What is "echo PAESSHSTART;"?

[[email protected] ]$ 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 by  skyeblue (60) 1 1



Accepted Answer

Votes:

1

Your Vote:

Up

Down

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 by  skyeblue (60) 1 1

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



Votes:

0

Your Vote:

Up

Down

Thank you for posting the solution to your problem.

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



Please log in or register to enter your reply.


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.