Asterisk stuff i use from time to time for troubleshooting.

Ok, so from time to time you need to get some stuff out of asterisk.

Here is one to show useragents of registered phones:

for a in `asterisk -rx "sip show peers"|cut -f1 -d/` ;do asterisk -rx "sip show peer $a";done|grep Useragent


Will provide IP address and peers as well:

for a in `asterisk -rx "sip show peers" | grep -v 'Monitored\|Name\|Unspecified' | cut -d '/' -f1` ;do echo $a; asterisk -rx "sip show peer $a" | grep 'Useragent\|Addr->IP';done

This one will show registered ip’s and contact

for a in `asterisk -rx "sip show peers"|cut -f1 -d/` ;do asterisk -rx "sip show peer $a";done|grep Contact

This one will show phones that have become lagged:

cat /var/log/asterisk/full |grep NOTICE |grep Lagged | awk '{print $6}' | sort -n | uniq