<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.3">
</HEAD>
<BODY>
<BR>
Perhaps another idea (works with extensions with 3 or more digits)<BR>
<BR>
<BLOCKQUOTE>
<TT>#!/bin/sh</TT><BR>
<TT>asterisk -rx "sip show peers"|</TT><BR>
<TT>grep -vP '(UNKNOWN|Unmonitored)' |</TT><BR>
<TT>cut -f1 -d/ | grep -P '\d\d\d.*' |</TT><BR>
<TT>while read PEER</TT><BR>
<TT>do</TT><BR>
<TT> echo " "$PEER</TT><BR>
<TT> asterisk -rx "sip show peer ${PEER}" |</TT><BR>
<TT> grep -P "(Useragent|Contact)"</TT><BR>
<TT> echo "===="</TT><BR>
<TT>done</TT><BR>
</BLOCKQUOTE>
<BR>
Best regards.<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Ing CIP. Alejandro Celi Mariátegui <BR>
<<A HREF="mailto:alex@linux.org.pe">alex@linux.org.pe</A>><BR>
<A HREF="http://cipher.pe/web/asterisk.html">http://cipher.pe/web/asterisk.html</A>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<BR>
<BR>
<BR>
<BR>
El jue, 23-02-2012 a las 09:20 -0600, Dale Noll escribió:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">On 02/23/2012 08:49 AM, Danny Nicholas wrote:</FONT>
<FONT COLOR="#000000">> Here is a snippet that somebody smarter than I am can improve upon</FONT>
<FONT COLOR="#000000">> for a in `asterisk -rx "sip show peers"|cut -f1 -d/` ;do asterisk -rx "sip</FONT>
<FONT COLOR="#000000">> show peer $a";done|grep Useragent</FONT>
<FONT COLOR="#000000">> for a in `asterisk -rx "sip show peers"|cut -f1 -d/` ;do asterisk -rx "sip</FONT>
<FONT COLOR="#000000">> show peer $a";done|grep Contact</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">Thanks for the inspiration!!</FONT>
<FONT COLOR="#000000">Here is my version, done with a single loop and gets Useragent and </FONT>
<FONT COLOR="#000000">Contact together with a visual separation between peers.</FONT>
<FONT COLOR="#000000">asterisk -rx "sip show peers"|</FONT>
<FONT COLOR="#000000">cut -f1 -d/ | grep -P '\d\d\d\d' |</FONT>
<FONT COLOR="#000000">grep -vP '(UNKNOWN|Unmonitored)' |</FONT>
<FONT COLOR="#000000">while read PEER</FONT>
<FONT COLOR="#000000">do</FONT>
<FONT COLOR="#000000"> asterisk -rx "sip show peer ${PEER}" |</FONT>
<FONT COLOR="#000000"> grep -P "(Useragent|Contact)"</FONT>
<FONT COLOR="#000000"> echo "===="</FONT>
<FONT COLOR="#000000">done</FONT>
<FONT COLOR="#000000">I hope others find it useful.</FONT>
<FONT COLOR="#000000">Dale</FONT>
<FONT COLOR="#000000">PS. I by no means claim to be smarter than thou. I just happen to </FONT>
<FONT COLOR="#000000">really like grep and the -P option ;-)</FONT>
<FONT COLOR="#000000">--</FONT>
<FONT COLOR="#000000">_____________________________________________________________________</FONT>
<FONT COLOR="#000000">-- Bandwidth and Colocation Provided by <A HREF="http://www.api-digital.com">http://www.api-digital.com</A> --</FONT>
<FONT COLOR="#000000">New to Asterisk? Join us for a live introductory webinar every Thurs:</FONT>
<FONT COLOR="#000000"> <A HREF="http://www.asterisk.org/hello">http://www.asterisk.org/hello</A></FONT>
<FONT COLOR="#000000">asterisk-users mailing list</FONT>
<FONT COLOR="#000000">To UNSUBSCRIBE or update options visit:</FONT>
<FONT COLOR="#000000"> <A HREF="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-use</FONT>rs</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>