Trunk monitoring

A voip-info forum user posted an interesting monitor script, it sends an email when one of the trunks goes off-line. Is this functionality built into VitalPBX? If not, does this community have favorite monitor scripts posted somewhere?

The monitor script:
#!/bin/sh
#
# Check for offline or unreachable PJSIP trunks or peers aka extensions
#
rm -f /tmp/checkPeersPJ
/usr/sbin/asterisk -rx 'pjsip list registrations' |grep -E 'Bulkvs-pjsip' | grep -Ev 'Registered' >/tmp/checkPeersPJ
#
if [ -s "/tmp/checkPeersPJ" ]; then
        mail -s 'PJSIP status - verify connectivity' offline_email@gmail.com  </tmp/checkPeersPJ
fi

A Yeastar forum user suggests using Zabbix to remotely run “asterisk -rx ‘pjsip list registrations’”, monitoring the output with Zabbix, perhaps that would be more complete solution.

The script you posted will only monitor outbound registrations. Inbound registrations will not work, so you cannot use this for regular extension.

While watching the PJSIP outbound registrations works, I like using ARI and parsing the JSON response. You can use it Zabbix or any monitoring solution. You can also build a tiny NodeJS app that does that for you.

See asterisk documentation for endpoints with ARI.
https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Endpoints+REST+API

To get all extensions’ and it’s details:

curl -s "http://localhost:8088/ari/endpoints?api_key=$ARIUSER:$ARIPASS"

If you have JQ installed; you can, for example, parse the state of an individual extension/Trunk

curl -s "http://localhost:8088/ari/endpoints/$tech/$ext?api_key=$ARIUSER:$ARIPASS" | jq -r .state

I hope that helps.

2 Likes

Thank you. Is ARI loaded by default now?

It is not. You may post a request under #wish-list

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.