I’ll share a couple of shell scripts that I use from CLI to monitor what’s connected and the key/unkey status or all connected nodes.

The main function is monitor.sh:

 

#! /bin/bash

if [ -e /var/run/asterisk.ctl ]

then

                clear

                echo "Type CTL-C to exit"

                echo ""

                KEY=`/usr/local/sbin/vars29521.sh | grep --color=always TK`

                UNKEY=`/usr/local/sbin/vars29521.sh | grep --color=always TU`

                if [ -n $KEY ]

                then

                                echo $KEY

                fi

                if [ -z $KEY ]

                then

                                echo $UNKEY

        fi

                count=1

                until [ $count = "10000" ]

                do

                                ##  echo "Argument number $count"

                        count=`expr $count + 1`

                                TMP1=`/usr/local/sbin/vars29521.sh | grep RPT_ALINKS`

                                TMP2=`/usr/local/sbin/vars29521.sh | grep RPT_ALINKS`

                                while [ $TMP1 == $TMP2 ]

                                do

                                                TMP1=`/usr/local/sbin/vars29521.sh | grep RPT_ALINKS`

                                done

                                clear

                        echo "Type CTL-C to exit"

                                echo ""

                                KEY=`/usr/local/sbin/vars29521.sh | grep --color=always TK`

                                UNKEY=`/usr/local/sbin/vars29521.sh | grep --color=always TU`

                                if [ -n $KEY ]

                                then

                                                echo $KEY

                                fi

                                if [ -z $KEY ]

                                then

                                                echo $UNKEY

                        fi

                done    

                echo ""

                echo ""

else

                echo "Asterisk is not running!"

fi

 

The scipt that is called internally is vars29521.sh:

 

#! /bin/bash

if [ -e /var/run/asterisk.ctl ]

then

                asterisk -rx "rpt showvars 29521"

                echo ""

else

                echo "Asterisk is not running!"

fi

 

 

You will have to replace 29521 with your node number of course.

 

Tom / K5TRA