|Summary:||ASTERISK-01454: [patch] 'sip show peers' additional parameters|
|Date Opened:||2004-04-22 14:23:29||Date Closed:||2008-01-15 14:53:10.000-0600|
|Environment:||Attachments:||( 0) iax2_show_peers.diff.txt|
( 1) sip_show_peers.diff.txt
|Description:||Request a "sip show peers registered" to show only registered peers.|
|Comments:||By: Olle Johansson (oej) 2004-04-22 14:24:37|
Check chan_sip2 cli command "sip show active" that does *exactly* that. If that works for you, confirm here.
By: Brian West (bkw918) 2004-04-23 11:11:52
sip_show_peers.diff add ability to "grep" through the output of sip show peers.. examples..
sip show peers include 5060
sip show peers exclude UNKNOWN
sip show peers begin 21
This is Connor's patch from bug 850 it really should have went here. :P
By: Olle Johansson (oej) 2004-04-23 16:48:54
you need to cli_unregister as well
By: connor (connor) 2004-04-23 17:17:22
Thanks oej, Fixed. Also backported for IAX2 Channel. (IAX2 untested). Please check them out and give feedback.
By: connor (connor) 2004-04-23 17:26:12
P.S. Disclaimer has been faxed in.
By: z_smurf (z_smurf) 2004-04-25 05:44:40
I would like a "sip show peers" where the mysql-friend-peers also are included.
By: Brian West (bkw918) 2004-04-26 02:52:02
updated to patch
By: Olle Johansson (oej) 2004-04-26 14:17:39
z_smurf: Use 'mysql' in unix shell :-)
The Mysql Peers are not stored in memory, so that means we have to fetch them from database. Only sip.conf peers are stored in memory.
By: z_smurf (z_smurf) 2004-04-26 14:52:51
oej: Yes, it would not hurt to get them anyway, shown together with sip.conf-peers... But what the heck... :)
By: connor (connor) 2004-04-28 17:35:37
Would someone mind testing this.. I think it's clean enough and valuable enough to be commited to cvs.
By: James Golovich (jamesgolovich) 2004-04-28 17:42:50
A few comments on this. I'd really like to see the include/exclude/begin type stuff be handled on a global level so it will work with any cli command. I can think of a few possible ways to do it, but thats a big change to make.
Another thing, if this was to be used this should all be bundled into one cli command. We don't want to bloat the app name list
By: connor (connor) 2004-04-28 17:50:51
I would like to see this stiff be handled on a global level too.. Just didn't look like it was going to be a easy thing to handle, nor did I want to take on that task. I needed a command for SIP, and someone else needed it for IAX2, so I back ported it for IAX2.
As for the commands being bundled into one cli command, I choose to do it that way because of tab completion. Which is a very handy thing.
By: James Golovich (jamesgolovich) 2004-04-28 17:54:00
You can do tab completion by passing a completion generator function in your ast_cli_entry.
By: twisted (twisted) 2004-04-28 18:20:34
I like the idea, however, if one wishes to use the functionality as described, they must conform their peer entry lists to cisco IOS style. This is not the desired style of peering that some people wish to use. I reccomended allowing the 'begin' option to specify '/' as a delimiter and search on either side of the delimiter for that option, but was told to use include instead. Include can return any result it finds with a string in it, not the operation that's desired with begin.
I do not see how this will be useful to those who want different methods of peer registration, other than cisco's style.
will show a result soemthing like this in 'sip show peers':
when i do an Include 123, i can wind up with undesired entries... for example if i had a peer of [test123] that had NOTHING to do with the lines beginning with 123, it would show up in the results.
If begin would search the other side of the delimiter '/', i could use begin 123, and only return the results where the username begins with 123, which would solve this issue.
Otherwise, this patch works as described.
edited on: 04-28-04 17:15
By: connor (connor) 2004-04-28 18:44:11
okay, First, I wasn't talking about how Cisco does thier peer registrations with SIP.. I was talking about how this function mimics thier IOS cli function. Second, I was mistaken on how cisco IOS handles the begin function in thier IOS software. here is a helpfile from IOS..
begin Begin with the line that matches
exclude Exclude lines that match
include Include lines that match
exclude and include work as the should same, MY begin works by displaying every line that begins with what you specify.
To do what you want in your example... you could do sip show peers include /123 thus producing every peer that had a username that starts with /123 In this application, begin is probably not a very usefull cli grep function, but exists nontheless. I prefer using include for everything myself.
By: twisted (twisted) 2004-04-28 18:47:20
The point is not having to change the string used to search, simply becaue you are trying to do the same thing another function allows, because it doesn't work properly for the style [peer] entries that it requires. If the begin function really doesn't have a use, why bloat the code with it?
By: connor (connor) 2004-04-28 19:59:11
Well, as stated, the begin function was designed to grep the beginning of the CLI line, and it does that. If more people or kram say they want it to do the beginning of each field, or just peer and username, then I'll fix it to do so.
By: Brian West (bkw918) 2004-04-28 20:28:25
fix it to work on every field.
By: z_smurf (z_smurf) 2004-04-29 05:56:11
Why not just drop to shell for external commands like grep?
sip show peers|grep -v 5060
If we could include the mysql-peers in this, it would become really useful. For example
sip show peers|grep 192.168.0.1|grep ONLINE| wc -l
to see how many phones and connections is active behind a NAT...
By: James Golovich (jamesgolovich) 2004-04-29 13:36:05
What z_smurf said is what I aluded to earlier and I worked on a bit of code last night. It works awesome on the master console, but remote consoles will be a little bit more tricky. Aside from using stuff like grep it also has the benefit of using pagers like less and more.
I'll do a bit more work and see if I can come up with a generic way to implement on all types of consoles (remote as well as cli commands from manager)
By: Mark Spencer (markster) 2004-05-02 01:30:58
Added to CVS, thanks, this is a great patch.
By: Digium Subversion (svnbot) 2008-01-15 14:53:10.000-0600
r2856 | markster | 2008-01-15 14:53:09 -0600 (Tue, 15 Jan 2008) | 2 lines
Provide more fine grained control of sip and iax show peers (bug ASTERISK-1454)