[asterisk-users] Phone Inventory
Danny Nicholas
danny at debsinc.com
Thu Feb 23 09:39:13 CST 2012
+1 Dale - p.s. the grep -P '\d\d\d\d' killed the output on my 1.4 box.
P.P.S if you change grep -P "(Useragent|Contact)" to grep -P
"(Username|Contact|Username)" it produces a "nice" 4 line report like this:
Def. Username: Danny Nicholas
Useragent : PolycomSoundPointIP-SPIP_501-UA/3.1.2.0392
Reg. Contact : sip:104 at 192.168.23.114
=====
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Dale Noll
Sent: Thursday, February 23, 2012 9:21 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Phone Inventory
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 ;-)
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list