SNMP Monitor Extension, or Similar

Hi all,

We need to monitor an extension, from the endpoint perspective. We just need to know when it can no longer communicate with the server.

Right now, when that happens, the extension on our phone goes red (on grandstream) and has an x through it (polycom). However, I want to get notified as soon as that happens. I was hoping to use our monitoring software and an SNMP item, but I noticed most endpoints don’t have SNMP.

Is there a way to do this? My first thought is to use a software phone that has SNMP enabled, but thought I’d reach out to the community beforehand to see if that’s the best solution.

Reason is, we are having some serious issues as explained in the link below. Often times, asterisk doesn’t crash for a long time, but there are issues with extensions going offline (even though the server shows said extension as “OK”). Here’s the link to our issue: Consistent Asterisk/FreePBX Crash Issue

I don’t think the MIB contains what you are looking for, I would watch 5038 (AMI) for


Okay dicko, thanks.

So, I imagine this is at the server, and not the extension… Do you think I will get notified of what I’m looking for? My concern is that Asterisk is sometimes still seeing the peers as “OK” even when they’re not. That’s why I wanted to monitor an extension from the outside.

I use the following script that checks the number of extensions online/offline.

fullstring=$(asterisk -rx ‘sip show peers’ | grep offline)
totalPeer=$(echo $fullstring | sed -n -e “s/(sip peers )(.)$//p")
remainder=$(echo $fullstring | sed -n -e "s/^(.
)(Monitored: )//p”)
onlinePeer=$(echo $remainder | sed -n -e “s/(online,)(.*)$//p”)
percent=$(echo “scale=4; ($onlinePeer / $totalPeer)*100” |bc)
percent4=$(echo “($percent+0.5)/1” |bc)
echo $percent4
exit 0

from there i use a snmp extend in snmpd.conf

extend SIPOnline /etc/snmp/

and from there check the MIB to find the number of peers and base off the percentage alarm or notify you.

1 Like

You can monitor from anywhere that you have a user set in /etc/asterisk

add to /etc/asterisk/manager_custom.conf something like

secret = 63dbb3cf2853130d7ad84aa27de89e4c
read = system,call,log,verbose,command,user,originate
write = originate

You can do anything you want including sending a text or email or triggering a call with an AMI originate command using your language of preference, some oldie but goldie examples to be found here

Great, thanks guys.

If you are running this stuff on the freepbx system:

include '/etc/freepbx.conf';
   //Raw Request
   var_dump($astman->send_request("Command", array("Command" => "sip show peers")));
   //or Command
   var_dump($astman->command("sip show peers"));

All of this assumes that Asterisk is noticing the drop (which we should all agree it should) but if it isn’t noting the drops, you can monitor the IP addresses using something like Nagios. It’s a heavy-handed solution, but it will give you a reasonable level of insight into the network.

Right, hence my wanting to monitor the connectivity of an endpoint, from that endpoints perspective…

continously watching for watching the events for

will show all peer status events


These events happen as often as you set the registartion timers to

@juesor I was so inspired by your script that I created a new one that monitors pjsip

The reason is we have a client with a perfectly up to date system but every few days all extensions just loose connectivity with the board and we have no visibility when this happens. The script monitors four things:

  • Extensions in Use
  • Extensions Not In Use
  • Unavailable Extensions
  • Ringing Extensions

Here is the blog I wrote about it: