Asterisk PJSIP & LibreNMS

Asterisk PJSIP monitoring is closed to new replies, but thought to share an updated script to /etc/snmp/asterisk for the search engines.

  • Returns number of total number of peers, number available, and unavailable
  • Works with existing “Asterisk - SIP Peers”, this just retrofits PJSIP data to LibreNMS Asterisk app SIP format


if [ -f $ASCLI ];
    $ASCLI -rx "core show uptime" > /dev/null
    if [ $? -ne 0 ]; then
        # Asterisk not running, silently exit.
        exit 0

    echo "<<<asterisk>>>"
    $ASCLI -rx "core show channels" | awk '/active calls/ { print "Calls=" $1 } /active channels/ { print "Channels=" $1}'
    $ASCLI -rx "pjsip show endpoints" | awk '/Objects found:/ { print "SipPeers=" $3 }'
    $ASCLI -rx 'pjsip show endpoints' | grep "Avail" | wc -l | (read foo; echo SipMonOnline=$foo; )
    $ASCLI -rx 'pjsip show endpoints' | grep "Unavailable" | wc -l | (read foo; echo SipMonOffline=$foo; )
    echo "SipUnMonOnline=0"
    echo "SipUnMonOffline=0"
    $ASCLI -rx 'iax2 show peers' | awk '/iax2 peers/ { gsub("\\[",""); gsub("\\]",""); print "Iax2Peers=" $1 "\nIax2Online=" $4 "\nIax2Offline=" $6 "\nIax2Unmonitored=" $8}'

   exit 0
1 Like

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