Open HichamINOX opened 2 years ago
If some column for the output command "sip show peers" is empty, AWK output may be wrong.
I fix it by the code: /usr/sbin/asterisk -rx "sip show peer $value"| grep -i status | cut -d' ' -f11)
actually i can't test it.
@rafaelkoslop you changed line 6 from
status=$(/usr/sbin/asterisk -rx "sip show peers" |grep ${value} |awk '{print $6}')
to
status=$(/usr/sbin/asterisk -rx "sip show peer $value"| grep -i status | cut -d' ' -f11)
if @HichamINOX could confirm that this works, i'll update the code.
Thanks for your effort.
Yes. I'll post the full code below. It works great. I have actived 25 PRTG sensors for all my clientes Trunks.
value=$1 serviceIsRunning=false
status=$(sudo /usr/sbin/asterisk -rx "sip show peer $value"| grep -i status | cut -d' ' -f11)
if [ "$status" == OK ]; then serviceIsRunning=true echo "0:200:$status" fi
if [ $serviceIsRunning == false ]; then echo "2:404:$status" fi
Thank you
if we have two trunks with the same pattern in name like "Trunk" and "TrunkBackup" , PRTG receive a false result. you can add -w in grep command tu have exact match pattern.
asterisk -rx "sip show peers" |grep -w 'webhelp' |awk '{print $6}'