[OpenSIPS-Users] Logging selected users full SDP

Matti Zemack Matti.Zemack at rtcfactory.com
Mon Feb 9 17:33:06 CET 2009


Thanks Bogdan and Stefano for your replies earlier!


Sorry for asking everyone a follow up question so late... Been working
on other projects for the last week.
My basic problem is not knowing enough about how to program the config
in opensips.
Lots of example scripts would be a big help... (I could set up some sort
of de-classified, open for everyone, "working config" repository if
wanted. Maybe on the wiki? Just mail me configs without personal details
together with some basic info like OpenSIPS version etc.)


Anyway, I just can't get the sip_trace() to be true throughout the whole
DIALOGUE. I'm hoping for sip_trace to work if flag(13) is set. I would
like all SDP for that user being kept in the sip_trace table. I suppose
I'm doing things in the wrong way. Most thankful for more advice!

Config file (in shortened form):
------------------------------------------------------------------------
--------------------------------------------
#Of course loadmodules, and other modparams...
modparam("auth_db", "load_credentials", "do_siptrace")       #
Individual user's SipTrace-Flag
modparam("siptrace", "db_url", "the usual DB connect stuff")
modparam("siptrace", "trace_on", 1)
modparam("siptrace", "table", "sip_trace")
modparam("siptrace", "trace_flag", 13)

route{	xlog("\n-- Is Siptrace flag set for subscriber? --
$avp(s:do_siptrace)\n");
	if (isflagset(13)) {xlog("-- Flag 13 = SET\n");} else {xlog("--
Flag 13 = NOT set\n");}

	# sip_trace();    # NOTE 2
	# setflag(13);    # NOTE 2

	if (is_method("REGISTER")) {
		if (!www_authorize("", "subscriber")) {
			www_challenge("", "0");
			exit;
		}
		if (!check_to()) {
			sl_send_reply("403","Forbidden auth ID");
			exit;
		}
		if (!save("location")) {
			sl_reply_error();
		} else {
			xlog("Saved new location $from\n");
			if ($avp(s:do_siptrace)==1) {
				xlog("\n-- do_siptrace=TRUE\n");
				# sip_trace(); # This should not be
needed as I setflag(13) below. NOTE 1.
				setflag(13);
			} else {
				xlog("\n-- do_siptrace=FALSE\n");
			}
			
			###  Below is Working! Insert or Update latest
registration info in usr_preferences as 'registerkeeper'
			###  for later usage...
			###  Completely separate matter!
	    		avp_db_query("INSERT INTO usr_preferences
(username, domain, attribute, value, last_modified)
		  	VALUES ('$aU', '$od', 'registerkeeper', '$si:$sp
- $ua', FROM_UNIXTIME('$Ts'))
		  	ON DUPLICATE KEY UPDATE value='$si:$sp - $ua',
last_modified=FROM_UNIXTIME('$Ts')");
		}
		exit;
	}
}
------------------------------------------------------------------------
--------------------------------------------
As you can see I got to NOTE 1. When user authorizes flag(13) is set.
But nothing is added to the sip_trace table. If NOTE 1 isn't commented
my table adds the single REGISTER but nothing else from the dialogue.

A note if I uncomment any of the NOTE 2 statements I get all SIP info
added to the correct table. But for all users of course.

I understand that there is something fundamental with flag handling
which I don't understand. Bear with me. One of these days I'll hopefully
understand?


Best Regards,
Matti Zemack, Stockholm, Sweden



-----Original Message-----
From: Bogdan-Andrei Iancu [mailto:bogdan at voice-system.ro] 
Sent: den 3 februari 2009 11:41
To: Matti Zemack
Cc: users at lists.opensips.org
Subject: Re: [OpenSIPS-Users] Logging selected users full SDP

Hi Matii

As Stefano already said, for logging, you might consider using the 
siptrace module (specially designed for such purposes):
http://www.opensips.org/html/docs/modules/1.4.x/siptrace.html

For step (2), to avoid the extra query, use the "load_credentials" 
option in the auth_db module:
http://www.opensips.org/html/docs/modules/1.4.x/auth_db.html#id228277
The idea is to load (during the password check at auth) other fields 
form the subscriber table (like a custom one, some flags).

Regards,
Bogdan

Matti Zemack wrote:
>
> Hi all,
>
> More and more fascinated with what opensips can handle. Running SIPp 
> to see how many simultaneous users, and I'm amazed!
>
> I'll try not to bother you all too much, but I wanted to test a 
> scenario with you as I'm still a newbie and want to dip my toes 
> without the shark eating me alive...
>
> Some customers need more attention, and need more fault finding. I 
> thought of adding some sort of customer tracer to my OpenSIPS config. 
> Basically, IF a customer's-debug-flag is ON: all SIP messages except 
> REGISTER get recorded, both coming in to OpenSIPS and just before 
> leaving OpenSIPS.
>
> 1. SDP enters OpenSIPS.
>
> 2. Check if customer-debug-flag is set. (Probably a costly 
> avp_db_query operation, or can one easily save/load transaction flags 
> for each user?)
>
> 3. If not a REGISTER write as much as possible from header to new db 
> table (what variable would this be?).
>
> 4. Process request.
>
> 5. Change all "exit();" to "route (42); exit();" in old config file.
>
> 6. Route [42] checks if customer-debug-flag is set and NOT REGISTER. 
> Write outgoing SIP header to new db table (what variable would this
be?)
>
> 7. Exit().
>
> Pretty much as using tcpdump on a selected user. I believe the 
> solution would be much more elegant if contained in OpenSIPS.
>
> Is this just simply crazy idea? Has it been done before? Will it cost 
> too much in processing power? Should I instead do some clever 
> selective tcpdump?
>
> Thanks in advance,
>
> Matti Zemack
>
> Stockholm
>
> Sweden//
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   




More information about the Users mailing list