Table of Contents
List of Examples
script_counter
script_cnt_grp_name in the config file
cnt_inc usagecnt_add usagecnt_reset usagecnt.get grp counter_name usagecnt.reset grp name usagecnt.grps_list usagecnt.var_list group usagecnt.var_list group usagecnt.help grp name usageTable of Contents
Define a new counter that can be used from the script.
The declaration might include a group in front of the counter
name, separated with '.'. It might also include a counter
description string (help message), separated from the name
with a ' ' or ':'.
If the group is missing, the group defined in the
script_cnt_grp_name module parameter will
be used (the default is "script").
If the description is missing, the default is
"custom script counter".
The format of the declaration is: [group.]name[( |:)description].
Example 1.1.
Create a new script_counter
modparam("counters", "script_counter", "foo") # script.foo
modparam("counters", "script_counter", "test.bar") # test.bar
modparam("counters", "script_counter", "baz example counter") # script.baz
modparam("counters", "script_counter", "test.x:another example") # test.x
Increments the counter group.name. The counter
must be defined using the script_counter
module parameter.
If the group name is missing, the group specified by the
script_cnt_grp_name modparam will be used.
Example 1.3. cnt_inc usage
...
modparam("counters", "script_counter", "reqs")
modparam("counters", "script_counter", "out.reqs forwarded requests")
...
route {
cnt_inc("reqs");
if (forward(uri:host, uri:port))
cnt_inc("out.reqs");
...
}
Adds number the counter
group.name.
The counter must be defined using the
script_counter module parameter.
If the group name is missing, the group specified by the
script_cnt_grp_name modparam will be used.
Example 1.4. cnt_add usage
...
modparam("counters", "script_counter", "reqs10 reqs times 10")
...
route {
cnt_add("reqs10", 10);
...
}
Resets the counter group.name. The counter
must be defined using the script_counter
module parameter.
If the group name is missing, the group specified by the
script_cnt_grp_name modparam will be used.
Example 1.5. cnt_reset usage
...
modparam("counters", "script_counter", "reqs")
...
route {
if (...)
cnt_reset("reqs");
...
}
Get the value of the counter identified by group.counter_name.
Resets the counter identified by group.counter_name.
Lists all the declared counter groups.
Lists all the names of all the counters belonging to the specified group.
Lists all the counter names and their values in the specified group.