[SR-Users] Adding IPs from which 503 messages originates to a database

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 4 09:57:06 CEST 2014


On 04/09/14 09:19, aft wrote:
> On Wed, Sep 3, 2014 at 11:36 PM, Daniel-Constantin Mierla
> <miconda at gmail.com> wrote:
>> Hello,
>>
>> The $si is the source ip of the sip packet. Bu in a rtimer route there is no
>> packet received from the network.
>>
>> So your config is not going to work for what you want to do.
>>
>> You can try to use mqueue to push sql queries from sip worker to rtimer as
>> you need to write something to database.
>>
> Should i push $si using mq_add() and fetch it using mq_fetch()?
It should work with pushing $si as well.

I was thinking to do the check in onreply route and push the entire sql 
query, so the rtimer route just execute it.

Cheers,
Daniel

>
>
>> Cheers,
>> Daniel
>>
>>
>> On Wednesday, September 3, 2014, aft <aftnix at gmail.com> wrote:
>>> I'm trying to configure HOMER sip capture server to do some accounting
>>> of the cases when "503 Service Unavailable" message arrives from
>>> capture agents.
>>>
>>> I've implemented the following to record the source IPs from which 503
>>> message originates.
>>>
>>>
>>>
>>>
>>> onreply_route {
>>> ......................
>>> ......................
>>> ......................
>>>
>>>   else if(status == "503") {
>>>                  if($sht(a=>alarm::503) == $null) {
>>>                          $sht(a=>alarm::503) = 0;
>>>                          $sht(a=>alarm::$si::503) = 0;
>>>                  }
>>>                  xlog("Got 503");
>>>                  xlog("($sht(a=>alarm::$si::503))");
>>>                  $sht(a=>alarm::$si::503) = $sht(a=>alarm::$si::503) + 1;
>>>          }
>>> ...................
>>> ...................
>>> ...................
>>>
>>> The following route supposed run periodically to update the databases.
>>>
>>> }
>>>
>>> route[TIMER_STATS] {
>>>
>>> .....................
>>> .....................
>>>
>>>   xlog("($sht(a=>alarm::$si::503))");
>>>      if($sht(a=>alarm::$si::503) > 0) {
>>>          sql_query("cb", "INSERT INTO alarm_data (create_date, type,
>>> total, description, source_ip) VALUES(NOW(), 'Too Many 503',
>>> $sht(a=>alarm::$si::503), 'service unavailable', $si)");
>>>      xlog("adding stuff to db");
>>>      }
>>>      $sht(a=>alarm::503) = 0;
>>>      $sht(a=>alarm::$si::503) = 0;
>>>
>>>
>>> }
>>>
>>>
>>> But the xlog("adding stuff to db") never executed. But in the first
>>> block of code, the log message to print the value
>>> $sht(a=>alarm::$si::503), which is shown to be non zero.
>>>
>>> Don't understand why its not working.
>>> --
>>> -Cheers
>>> -Arif
>>>
>>> _______________________________________________
>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>> sr-users at lists.sip-router.org
>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>> --
>> Daniel-Constantin Mierla - http://www.asipto.com
>> http://twitter.com/#!/miconda - http://www.linkedin.com/in/micond
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>
>

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany




More information about the sr-users mailing list