[asterisk-users] Phone Inventory

Dale Noll dnoll at wi.rr.com
Thu Feb 23 09:20:46 CST 2012


On 02/23/2012 08:49 AM, Danny Nicholas wrote:
> Here is a snippet that somebody smarter than I am can improve upon
> for a in `asterisk -rx "sip show peers"|cut -f1 -d/` ;do asterisk -rx "sip
> show peer $a";done|grep Useragent
> for a in `asterisk -rx "sip show peers"|cut -f1 -d/` ;do asterisk -rx "sip
> show peer $a";done|grep Contact
>

Thanks for the inspiration!!

Here is my version, done with a single loop and gets Useragent and 
Contact together with a visual separation between peers.


asterisk -rx "sip show peers"|
cut -f1 -d/ | grep -P '\d\d\d\d' |
grep -vP '(UNKNOWN|Unmonitored)' |
while read PEER
do
    asterisk -rx "sip show peer ${PEER}" |
    grep -P "(Useragent|Contact)"
    echo "===="
done

I hope others find it useful.

Dale

PS. I by no means claim to be smarter than thou.  I just happen to 
really like grep and the -P option  ;-)



More information about the asterisk-users mailing list