Thursday, February 7, 2008

Shared variables in configuration script

OpenSER is a multiprocess application. Sometimes, as an VoIP administrator of an OpenSER based platform, you feel the need to have a variable whose value is visible in all OpenSER processes.

Few days ago, the cfgutils module introduced this feature. A shared variable is specified via $shv(name), name can be any string of alpha-numeric characters. The shared variables can be initialized via a parameter of the cfgutils module. Also, they can be set via MI commands, giving the possibility to control routing logic in a nice way, without restarting OpenSER.

xlog was enhanced to take the log lever from any pseudo-variable, including shared variables. Now you can enable/disable printing of the log messages via MI.

Example of usage:

---
debug=3
...
loadmodule "cfgutils.so"
...
modparam("cfgutils", "shvset", "debug=i:4")
...
xlog("$shv(debug)", "request [$rm] from [$fu] to [$ru]\n");
---

To get your xlog message printed, issue the command:

# openserct fifo shv_set debug int 3


More details at:

http://www.openser.org/docs/modules/devel/cfgutils.html
http://www.openser.org/docs/modules/devel/xlog.html