[SR-Users] get server parameters from DB when kamailio starts
Daniel-Constantin Mierla
miconda at gmail.com
Tue Feb 14 11:35:17 CET 2012
Hello,
On 2/13/12 7:48 PM, Uri Shacked wrote:
> thanks.
> i find the htable module a little confusing, or a little harder to
> understand. (although i said so on the mtree and today i find myself
> using it a lot).
you have to understand first the structures behind it:
http://en.wikipedia.org/wiki/Hash_table
In few words, it is a generic storage in shared memory, of pairs (key,
value) -- the key is a string and the value can be string or integer.
$sht(x=>a) = "b"; -- this means storing in hash table 'x' a pair ("a",
"b"), getting the value is just using $sht(x=>a)
The items in a hash table can be loaded from a database table at
startup, you don't need event_route[htable:mod-init] and sqlops for that.
Cheers,
Daniel
> but, i notice at the end of the doc at section 7 to the
> "event_route[htable:mod-init]".
> i wonder, if i just load the htable module, and on this route, perform
> an SQL query and save the values in $shv(), will it do the trick?
> cheers,
> uri
> On Mon, Feb 13, 2012 at 5:34 PM, Daniel-Constantin Mierla
> <miconda at gmail.com <mailto:miconda at gmail.com>> wrote:
>
> Hello,
>
>
> On 2/10/12 2:32 PM, Uri Shacked wrote:
>> thanks,
>> it is good see there is a wayto start with -A... and it
>> might make it easier a little (cause i use the define as the
>> group the server belongs to).
>> but, it doesn't help me fully in my case.
>> i would like to have a generic start, and generic cfg file (it is
>> much easier when you need to maintain).
>> the best thing i would like to do is something like that:
>> let say i have "route on start" or "get data from DB on start"...
>> then, i set something like:
>> get "myself"
>> from list of kamailio servers"
>> and set my group to "the value set on me"
>> it seems to me something very usefull, when you use 2 and more
>> kamailio at different sites, and still want a generic code and
>> functions.
>> if i was a programer... i might try to write some module :-)
> you can load values from a database table via htable module and
> then use them to build the logic -- htable values are accessible
> via $sht(...).
>
> Cheers,
> Daniel
>
>> thanks anyway,
>> Uri
>>
>> On Fri, Feb 10, 2012 at 2:51 PM, Daniel-Constantin Mierla
>> <miconda at gmail.com <mailto:miconda at gmail.com>> wrote:
>>
>> Hello,
>>
>> you can use defines to control the order (the values of NP
>> servers), here is an example of defining NP servers (to str
>> value, for sake of explanation):
>>
>> #!ifdef SRV1
>> #!define NPSRV1 "abc"
>> #!define NPSRV2 "xyz"
>> #!else
>> #!define NPSRV2 "abc"
>> #!define NPSRV1 "xyz"
>> #!endif
>>
>> and start kamailio with parameter '-A SRV1' for the first
>> instance.
>>
>> Cheers,
>> Daniel
>>
>>
>>
>> On 2/10/12 6:28 AM, Uri Shacked wrote:
>>> Hi again...
>>> (i do find myself ask many questions these days.... :-))
>>>
>>> well, now here is one more:
>>>
>>> i have 2 kamailio servers that i use in 2 locations. both
>>> use the same
>>> tables and DBURL.
>>> each of my server turns to a number portability (NP) server
>>> at its same
>>> location.
>>> for example, if server 1 has the call, it will turn to NP
>>> server 1 with the
>>> query, and if the query fails, it will then turn to NP server 2.
>>> the kamailio server 2 does the same. but, turns to NP server
>>> 2 first and if
>>> it fails, to NP server 1.
>>>
>>> once this is understood....
>>>
>>> here is my issue - i want to have 1 generic cfg file for my
>>> 2 servers.
>>> today, i use the same cfg file, but in server 1 i set it in
>>> the cfg to its
>>> group, and on server 2 the same but a different group....
>>>
>>> i tried to understand how do i get each server to "pull" its
>>> group from the
>>> DB. something like "what is my group when my IP is X.Y.Z.Q ?
>>> i raed the cfg_db module but didn't understand how to set it
>>> on my cfg file
>>> and on the DB.
>>>
>>> what is the best way to do what i want?
>>> hope i was clear....
>>>
>>> BR,
>>> thanks to all the guys that help me so far, i appriciate it
>>> a lot!
>>> Uri
>>>
>>>
>>> _______________________________________________
>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>> sr-users at lists.sip-router.org <mailto: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://www.asipto.com/>
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>>
>>
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org <mailto: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://www.asipto.com/>
> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>
>
>
>
> _______________________________________________
> 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://linkedin.com/in/miconda -- http://twitter.com/miconda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20120214/0b348922/attachment.htm>
More information about the sr-users
mailing list