Hello,
I want to define a counter that increase in every invite.
I tried the below :
if (is_method("INVITE"))
{
$var(u)=$var(u)+1;
xlog("L_INFO","Counter : $var(u) " );
}
But the counter is reset to 1 randomly (even before restarting kamailio service)
How can have a proper counter that count invite messages.
Thanks
Ali
Hi,
$var is in a scope per thread, so you will have a different counter in every thread.
You should use shared memory instead:
http://www.kamailio.org/wiki/cookbooks/4.2.x/pseudovariables#shv_name_-_shar...
Cheers, Dirk
On 19-06-15 15:54, Ali Taher wrote:
Hello,
I want to define a counter that increase in every invite.
I tried the below :
if (is_method("INVITE"))
{
$var(u)=$var(u)+1;
xlog("L_INFO","Counter : $var(u) " );
}
But the counter is reset to 1 randomly (even before restarting kamailio service)
How can have a proper counter that count invite messages.
Thanks
Ali
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Thanks Dirk it worked as I want!
-----Original Message----- From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Dirk Teurlings - SIGNET B.V. Sent: Friday, June 19, 2015 5:03 PM To: sr-users@lists.sip-router.org Subject: Re: [SR-Users] Kamailio invite counter
Hi,
$var is in a scope per thread, so you will have a different counter in every thread.
You should use shared memory instead:
http://www.kamailio.org/wiki/cookbooks/4.2.x/pseudovariables#shv_name_-_shar ed_memory_variables
Cheers, Dirk
On 19-06-15 15:54, Ali Taher wrote:
Hello,
I want to define a counter that increase in every invite.
I tried the below :
if (is_method("INVITE"))
{
$var(u)=$var(u)+1;
xlog("L_INFO","Counter : $var(u) " );
}
But the counter is reset to 1 randomly (even before restarting kamailio service)
How can have a proper counter that count invite messages.
Thanks
Ali
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 06/19/2015 09:54 AM, Ali Taher wrote:
Hello,
I want to define a counter that increase in every invite.
I tried the below :
if (is_method("INVITE"))
{
$var(u)=$var(u)+1;
xlog("L_INFO","Counter : $var(u) " );
}
But the counter is reset to 1 randomly (even before restarting kamailio service)
How can have a proper counter that count invite messages.
Thanks
Ali
Have you considered using either Dialog module or HTABLE instead?
http://kamailio.org/docs/modules/stable/modules/dialog.html http://kamailio.org/docs/modules/stable/modules/htable.html
I would start with htable...
--fred
Thanks Alex,
I used $shv instead of $var and worked as expected so far
Is it a good approach for a large number of requests or should I use statistics module?
From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Alex Balashov Sent: Friday, June 19, 2015 5:16 PM To: Ali Taher Subject: Re: [SR-Users] Kamailio invite counter
Ali,
$var variables do not persist outside the scope of the processing of a single SIP message. They live in the private memory of every receiver process.
Take a look at the 'htable' or 'statistics' modules.
-- Alex Balashov | Principal | Evariste Systems LLC 303 Perimeter Center North, Suite 300 Atlanta, GA 30346 United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Sent from my BlackBerry.
From: Ali Taher
Sent: Friday, June 19, 2015 09:55
To: 'Kamailio (SER) - Users Mailing List'
Reply To: Kamailio (SER) - Users Mailing List
Subject: [SR-Users] Kamailio invite counter
Hello,
I want to define a counter that increase in every invite.
I tried the below :
if (is_method("INVITE"))
{
$var(u)=$var(u)+1;
xlog("L_INFO","Counter : $var(u) " );
}
But the counter is reset to 1 randomly (even before restarting kamailio service)
How can have a proper counter that count invite messages.
Thanks
Ali
Hi Alex,
I need to limit the number of requests received within 1 second, meaning that if the number of request during 1 second exceeds a certain limit(let’s say 1000 call per second), these requests must be blocked.
How can I reset the counter every one second to achieve this?
Thanks,
Ali
From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Alex Balashov Sent: Friday, June 19, 2015 5:16 PM To: Ali Taher Subject: Re: [SR-Users] Kamailio invite counter
Ali,
$var variables do not persist outside the scope of the processing of a single SIP message. They live in the private memory of every receiver process.
Take a look at the 'htable' or 'statistics' modules.
-- Alex Balashov | Principal | Evariste Systems LLC 303 Perimeter Center North, Suite 300 Atlanta, GA 30346 United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Sent from my BlackBerry.
From: Ali Taher
Sent: Friday, June 19, 2015 09:55
To: 'Kamailio (SER) - Users Mailing List'
Reply To: Kamailio (SER) - Users Mailing List
Subject: [SR-Users] Kamailio invite counter
Hello,
I want to define a counter that increase in every invite.
I tried the below :
if (is_method("INVITE"))
{
$var(u)=$var(u)+1;
xlog("L_INFO","Counter : $var(u) " );
}
But the counter is reset to 1 randomly (even before restarting kamailio service)
How can have a proper counter that count invite messages.
Thanks
Ali