Table of Contents
setsflag(flag)
issflagset(flag)
resetsflag(flag)
setbflag(flag [, branch])
isbflagset(flag [, branch])
resetbflag(flag [, branch])
setdsturi(uri)
resetdsturi()
isdsturiset()
pv_printf(var, str)
is_myself(uri)
is_myhost(uri)
setdebug(level)
resetdebug()
km_append_branch([uri])
core.aliases_list
core.arg
core.echo
core.flags
core.info
core.runinfo
core.kill
core.printi
core.prints
core.ps
core.psx
core.pwd
core.shmmem
core.sockets_list
core.tcp_info
core.tcp_list
core.tcp_options
core.udp4_raw_info
core.uptime
core.version
core.ppdefines
core.modules
modparam.getn
modparam.gets
modparam.setn
modparam.list
pkg.stats
pkg.info
stats.get_statistics
stats.fetch
stats.fetchn
stats.reset_statistics
stats.clear_statistics
system.listMethods
system.methodHelp
system.methodSignature
mod.mem_stats
mod.stats
mod.mem_statsx
List of Examples
setsflag usageissflagset usageresetsflag usagesetbflag usageisbflagset usageresetbflag usagesetdsturi usageresetdsturi usageisdsturiset usagepv_printf usageis_myself usageis_myhost usagesetdebug usageresetdebug usageTable of Contents
setsflag(flag)
issflagset(flag)
resetsflag(flag)
setbflag(flag [, branch])
isbflagset(flag [, branch])
resetbflag(flag [, branch])
setdsturi(uri)
resetdsturi()
isdsturiset()
pv_printf(var, str)
is_myself(uri)
is_myhost(uri)
setdebug(level)
resetdebug()
km_append_branch([uri])
core.aliases_list
core.arg
core.echo
core.flags
core.info
core.runinfo
core.kill
core.printi
core.prints
core.ps
core.psx
core.pwd
core.shmmem
core.sockets_list
core.tcp_info
core.tcp_list
core.tcp_options
core.udp4_raw_info
core.uptime
core.version
core.ppdefines
core.modules
modparam.getn
modparam.gets
modparam.setn
modparam.list
pkg.stats
pkg.info
stats.get_statistics
stats.fetch
stats.fetchn
stats.reset_statistics
stats.clear_statistics
system.listMethods
system.methodHelp
system.methodSignature
mod.mem_stats
mod.stats
mod.mem_statsx
This module collects extensions from Kamailio core.
Kamailio Core Cookbook is available at: https://www.kamailio.org/wikidocs/
The following modules must be loaded before this module:
No dependencies on other Kamailio modules.
Set the script flag.
Meaning of the parameters is as follows:
flag - the index of the script flag to be set. Can be integer or pseudo-variable with integer value.
This function can be used from ANY_ROUTE.
Return true if the script flag is set.
Meaning of the parameters is as follows:
flag - the index of the script flag to be tested. Can be integer or pseudo-variable with integer value.
This function can be used from ANY_ROUTE.
Reset the script flag.
Meaning of the parameters is as follows:
flag - the index of the script flag to be reset. Can be integer or pseudo-variable with integer value.
This function can be used from ANY_ROUTE.
Set the branch flag.
Meaning of the parameters is as follows:
flag - the index of the branch flag to be set. Can be integer or pseudo-variable with integer value.
branch - the index of the branch whose flag to be set. Can be integer or pseudo-variable with integer value. If omitted, then branch 0 is used (R-URI).
This function can be used from ANY_ROUTE.
Example 1.4. setbflag usage
...
setbflag("1");
...
$var(flag) = 11;
setbflag("$var(flag)", "1");
...
Return true if the branch flag is set.
Meaning of the parameters is as follows:
flag - the index of the branch flag to be tested. Can be integer or pseudo-variable with integer value.
branch - the index of the branch whose flag to be set. Can be integer or pseudo-variable with integer value. If omitted, then branch 0 is used (R-URI).
This function can be used from ANY_ROUTE.
Reset the branch flag.
Meaning of the parameters is as follows:
flag - the index of the branch flag to be reset. Can be integer or pseudo-variable with integer value.
branch - the index of the branch whose flag to be set. Can be integer or pseudo-variable with integer value. If omitted, then branch 0 is used (R-URI).
This function can be used from ANY_ROUTE.
Set the destination address URI (outbound proxy address).
Meaning of the parameters is as follows:
uri - Valid SIP URI representing the address where to send the request. It must be a static string, no variables are evaluated at runtime. If you need to set outbound proxy address via a variable, use assignment to $du.
This function can be used from ANY_ROUTE.
Reset the destination address URI (outbound proxy address).
This function can be used from ANY_ROUTE.
Check if the destination address URI (outbound proxy address) is set.
This function can be used from ANY_ROUTE.
Evaluates the str and sets the resulting value to variable var. For backward compatibility reasons, the same function can be executed via 'avp_printf(var, str)'.
Meaning of the parameters is as follows:
var - name of a writable variable
str - string that may contain variables which will be evaluated at runtime.
This function can be used from ANY_ROUTE.
Example 1.10. pv_printf usage
...
pv_printf("$ru", "sip:$rU@$fd");
pv_printf("$avp(x)", "From: $fU - To: $tU");
...
Check if the parameter matches the 'myself' condition (i.e., is a local IP or domain). Note that if the port is missing in the URI, then no port matching is done (in other words, port matching is skipped -- it does not use default SIP ports 5060 or 5061 for matching).
Meaning of the parameters is as follows:
uri - Valid SIP URI or IP address to check against the list of local IP addresses or domains, matching as well the port and protocol if they are provided. The parameter value can contain pseudo-variables.
This function can be used from ANY_ROUTE.
Check if the host part of the parameter matches a local domain or IP address.
Meaning of the parameters is as follows:
uri - Valid SIP URI, hostname of IP address to check against the list of local IP addresses or domains. If it is a SIP URI, the port and protocol are ignored. The parameter value can contain pseudo-variables.
This function can be used from ANY_ROUTE.
Set the debug log level per process.
Meaning of the parameters is as follows:
level - the debug log level to be set. Can be integer or pseudo-variable with integer value.
This function can be used from ANY_ROUTE.
Reset the local debug log level back to the value of core parameter 'debug'.
This function can be used from ANY_ROUTE.
Print command line arguments.
Name: core.arg
Parameters: none.
RPC Command Format:
... kamctl rpc core.arg ...
Kill the application.
Name: core.kill
Parameters: none.
RPC Command Format:
... kamctl rpc core.kill ...
Print working directory.
Name: core.pwd
Parameters: none.
RPC Command Format:
... kamctl rpc core.pwd ...
Returns shared memory info. It has an optional parameter that specifies the measuring unit: b - bytes (default), k or kb, m or mb, g or gb. Note: when using something different from bytes, the value is truncated.
Print uptime.
Name: core.uptime
Parameters: none.
RPC Command Format:
... kamctl rpc core.uptime ...
Print version information.
Name: core.version
Parameters: none.
RPC Command Format:
... kamctl rpc core.version ...
List preprocessor defines enabled in config.
Name: core.ppdefines
Parameters: none.
RPC Command Format:
... kamctl rpc core.ppdefines ...
List loaded modules in config.
Name: core.modules
Parameters: none.
RPC Command Format:
... kamctl rpc core.modules ...
Get the value of a module parameter with integer value.
Name: modparam.getn
Parameters: module_name and parameter_name.
RPC Command Format:
... kamcli rpc modparam.getn tls keylog_mode ...
Get the value of a module parameter with string value.
Name: modparam.gets
Parameters: module_name and parameter_name.
RPC Command Format:
... kamcli rpc modparam.gets tls config ...
Set the value of a module parameter with integer value stored in shared memory.
Name: modparam.setn
Parameters: module_name, parameter_name and value.
RPC Command Format:
... kamcli rpc modparam.setn tls keylog_mode 15 ...
List the parameters of the loaded modules.
Name: modparam.list
Parameters: module_name (optional).
RPC Command Format:
... kamcli rpc modparam.list kamcli rpc modparam.list tls ...
Print private memory (pkg) usage statistics per process. It can take optionally a filter to print statistics only for a specific process or set of processes. If no filter is given, it prints statistics for all processes.
The filter can be:
pid value - print statistics for specific process pid.
rank value - print statistics for specific process rank.
index value - print statistics for specific index in process table.
Examples:
kamctl rpc pkg.stats kamctl rpc pkg.stats pid 1234 kamctl rpc pkg.stats rank 1 kamctl rpc pkg.stats index 10
Print the list of available internal statistics.
NOTE: the result is an array of strings that have the list of statistics formatted like "name = value", being propagated over the time from the MI variant. Use "stats.fetch" or "stats.fetchn"commands to have a more JSON-friendly output.
Parameters: statsid - which statistics to be printed. If set to 'all' then all statistics are printed; if set to 'statsgroup:' then all statistics in the group are printed; if set to 'statsname' then the statistics identified by the name is printed.
Examples:
kamctl rpc stats.get_statistics all kamctl rpc stats.get_statistics core: kamctl rpc stats.get_statistics unsupported_methods kamctl rpc stats.get_statistics shmem: fwd_requests fwd_replies
Print the list of available internal statistics with a more json friendly output. Each printed statistic is a field in the output structure: {"statsgroup.statsname" : "statsvalue"}. The value is represented as string to accommodate large numbers.
Parameters: statsid - which statistics to be printed. If set to 'all' then all statistics are printed; if set to 'statsgroup:' then all statistics in the group are printed; if set to 'statsname' then the statistics identified by the name is printed (can be also 'statsgroup.stastname' or 'statsgroup:statsname').
Examples:
kamctl rpc stats.fetch all kamctl rpc stats.fetch core: kamctl rpc stats.fetch unsupported_methods kamctl rpc stats.fetch shmem.free_size kamctl rpc stats.fetch shmem: fwd_requests fwd_replies
Print the list of available internal statistics with a more json friendly output. Each printed statistic is a field in the output structure: {"statsgroup.statsname" : statsvalue}. The value is represented as number.
Parameters: statsid - which statistics to be printed. If set to 'all' then all statistics are printed; if set to 'statsgroup:' then all statistics in the group are printed; if set to 'statsname' then the statistics identified by the name is printed (can be also 'statsgroup.stastname' or 'statsgroup:statsname').
Examples:
kamctl rpc stats.fetchn all kamctl rpc stats.fetchn core: kamctl rpc stats.fetchn unsupported_methods kamctl rpc stats.fetchn shmem.free_size kamctl rpc stats.fetchn shmem: fwd_requests fwd_replies
Reset internal statistics.
Parameters: statsid - same as for get_statistics.
Examples:
kamctl rpc stats.reset_statistics all kamctl rpc stats.reset_statistics core: kamctl rpc stats.reset_statistics unsupported_methods kamctl rpc stats.reset_statistics shmem: fwd_requests fwd_replies
Return statistics and reset their value in one command.
Parameters: statsid - same as for get_statistics.
Examples:
kamctl rpc stats.reset_statistics all kamctl rpc stats.reset_statistics core: kamctl rpc stats.reset_statistics unsupported_methods kamctl rpc stats.reset_statistics shmem: fwd_requests fwd_replies
Print list of available RPC commands.
Name: system.listMethods
Parameters: none.
RPC Command Format:
... kamctl rpc system.listMethods ...
Print private(pkg) or shared(shm) memory currently allocated a given module or by all modules.
NOTE: Processing is done only when the command is issued and involves iterating through the list of memory fragments and printing details about them.
NOTE: Only the module functions that directly calls shm_alloc or pkg_alloc are taken into consideration.
The first parameter can be one of the following:
module_name - print statistics for specific module. Either a module name (like "usrloc") or "core" for the Kamailio core.
all - print statistics for all modules that uses memory.
The second parameter can be:
pkg - print private (process) memory statistics.
shm - print shared memory statistics.
all - print both private and shared memory statistics.
Examples:
kamctl rpc mod.stats core all kamctl rpc mod.stats tm shm kamctl rpc mod.stats kex pkg kamctl rpc mod.stats all all
Output:
Module: kex
{
// this is the pkg zone of the module
// function_name(line_where_pkg_malloc_was_called): size_alloc'ed_by_pkg_malloc
init_rpc_uptime(74): 56
Total: 56
}
{
// this is the shm zone of the module
// function_name(line_where_shm_malloc_was_called): size_alloc'ed_by_shm_malloc
pkg_proc_stats_init(79): 864
Total: 864
}
Same as RPC command "mod.mem_stats", this is an alias command to preserve backward compatibility.