librenms / librenms-agent

LibreNMS Agent & Scripts
GNU General Public License v2.0
117 stars 188 forks source link

snmp asterisk script: pjsip #375

Open hb9eue opened 3 years ago

hb9eue commented 3 years ago

Hi Team

chan_sip is depreciated. I guess everyone is using pjsip nowadays.

I altered the asterisk script to return the number of pjsip endpoints. But that is not being graphed. Instead I still get the former counters with nan counts. So I guess there is a counterpart to the asterisk snmp extend script. Could you please point me to it?

-Benoit-

SonicJoe commented 2 years ago

I too have the same issue. It looks like there is quite a few files to change on the back end to make this work. If I find some bandwidth, I may try my hand at it, but if you are interested here is the linked changes from when iax2 was added showing all the files that they needed to modify on the server side: https://github.com/librenms/librenms/pull/11078

hb9eue commented 2 years ago

Yes indeed... I once fixed it by deleting all the relevant rrd and had them re-created. But when I updated librenms all was broken again so I finally gave up :-) But I suppose if someone submitted an easy patch containing all what is needed to count pjsip channels etc. that would be fixed easily. Same here, if I find some spare bandwith on my voice project, I might have an deeper look into it.

si458 commented 1 year ago

im wondering if anybody has sorted/updated the asterisk script yet? asterisk 18 with freepbx has fully removed SIP now and only uses PJSIP

si458 commented 3 months ago

if anybody is wondering, i discovered this link in the librenms forum for asterisk and pjsip! https://community.librenms.org/t/asterisk-pjsip-librenms/19029 script works a treat!

edit: code in case forum vanishes, just replace all of asterisk content with below

#!/bin/bash

ASCLI=/usr/sbin/asterisk

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

    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}'

else
   exit 0
fi