FreePBX Asterisk RTP and Call Monitoring Script

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.

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"
    echo "-----------------------"
    asterisk -rx 'sip show peers'
    echo "--------------------------------------------------------------------------------------------------------------------------------------------"
    echo ""
    echo -e "\e[33mCurrent Chan_SIP RTP Statistics / Active Calls:\e[39m"
    echo "-----------------------------------------------"
    asterisk -rx 'sip show channelstats'
    echo "--------------------------------------------------------------------------------------------------------------------------------------------"
    echo ""
    echo -e "\e[33mCurrent PJSIP Peers / Contacts:\e[39m"
    echo "-----------------------------"
    asterisk -rx 'pjsip show contacts'
    echo "--------------------------------------------------------------------------------------------------------------------------------------------"
    echo ""
    echo -e "\e[33mCurrent PJSIP Statistics / Active Calls:\e[39m"
    echo "----------------------------------------"
    asterisk -rx 'pjsip show channelstats'
    echo "--------------------------------------------------------------------------------------------------------------------------------------------"
    sleep 2
done

It looks like this when you run it.