Friday, April 23, 2010

Kamailio 3.0.x - DYK-07 - custom cfg parameters

Define your own config parameters

See also: Kamailio 3.0.x - DYK - Table of Content

Kamailio 3.0.0 introduced custom config global parameters. These are variables that can be declared in the global parameters part and can be used inside the routing logic. Very useful as well is the features of being able to change its value at runtime via RPC commands, without SIP server restart.

Defining a new cfg parameter has a special format:
group.id = value 'desc' description
Then you can get access to them via pseudo-variables as $sel(cfg_get.group.id) or selects as @cfg_get.group.id.

Example - define a variable that can be used to control printing of some custom log messages:
...
local.dbg = 0 desc "Custom debug mode"
...
route {
...
if($sel(cfg_get.local.dbg)==1)
xlog("My extra log message\n");
...
}
You can update it at runtime with sercmd:
sercmd cfg.set_now_int local dbg 1
I wrote a bit more in a previous post.

No comments:

Post a Comment