We created this script to assist with constant monitoring of RTP streams and calls in Asterisk/FreePBX. We typically save it to the root of a FreePBX system, name it "chanmonitor" and run chmod +x /chanmonitor to make it executable. It runs the following commands every two seconds and displays it in a formatted fashion.
To monitor just PJSIP:
#!/bin/bash
while true
do
clear
echo -e "\e[33mCurrent PJSIP Peers / Contacts:\e[39m"
asterisk -rx 'pjsip show contacts'
echo -e "\e[33mCurrent PJSIP Statistics / Active Calls:\e[39m"
asterisk -rx 'pjsip show channelstats'
sleep 2
done
To monitor SIP & PJSIP:
asterisk -rx ‘sip show peers’
asterisk -rx ‘sip show channelstats’
asterisk -rx ‘pjsip show contacts’
asterisk -rx ‘pjsip show channelstats’
#!/bin/bash
while true
do
clear
echo -e "\e[33mCurrent Chan_SIP Peers:\e[39m"
asterisk -rx 'sip show peers'
echo -e "\e[33mCurrent Chan_SIP RTP Statistics / Active Calls:\e[39m"
asterisk -rx 'sip show channelstats'
echo ""
echo -e "\e[33mCurrent PJSIP Peers / Contacts:\e[39m"
asterisk -rx 'pjsip show contacts'
echo -e "\e[33mCurrent PJSIP Statistics / Active Calls:\e[39m"
asterisk -rx 'pjsip show channelstats'
sleep 2
done
It looks like this when you run it.