TS-Steff / PRTG-AsteriskTrunk

Monitor an Asterisk Trunk
2 stars 1 forks source link

Two same pattern as Trunk Name #1

Open HichamINOX opened 2 years ago

HichamINOX commented 2 years ago

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

rafaelkoslop commented 1 year 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)

TS-Steff commented 1 year ago

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.

rafaelkoslop commented 1 year ago

Yes. I'll post the full code below. It works great. I have actived 25 PRTG sensors for all my clientes Trunks.

!/bin/bash

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

TS-Steff commented 1 year ago

Thank you