[asterisk-users] Phone Inventory
Ing CIP. Alejandro Celi Mariátegui
alex at linux.org.pe
Wed Jun 6 18:00:41 CDT 2012
Perhaps another idea (works with extensions with 3 or more digits)
#!/bin/sh
asterisk -rx "sip show peers"|
grep -vP '(UNKNOWN|Unmonitored)' |
cut -f1 -d/ | grep -P '\d\d\d.*' |
while read PEER
do
echo " "$PEER
asterisk -rx "sip show peer ${PEER}" |
grep -P "(Useragent|Contact)"
echo "===="
done
Best regards.
--
Ing CIP. Alejandro Celi Mariátegui
<alex at linux.org.pe>
http://cipher.pe/web/asterisk.html
El jue, 23-02-2012 a las 09:20 -0600, Dale Noll escribió:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120606/3d2c271e/attachment.htm>
More information about the asterisk-users
mailing list