EvRExec Module

Daniel-Constantin Mierla

asipto.com

Edited by

Daniel-Constantin Mierla


Table of Contents

1. Admin Guide
1. Overview
2. Dependencies
2.1. Kamailio Modules
2.2. External Libraries or Applications
3. Parameters
3.1. exec (str)
4. RPC Commands
4.1. evrexec.run

List of Examples

1.1. Set exec parameter

Chapter 1. Admin Guide

1. Overview

The module executes event route blocks or KEMI functions on dedicated processes at startup. The execution can be delayed for a specified interval of time.

The actions in the event route should be a loop or other tasks that run forever.

2. Dependencies

2.1. Kamailio Modules

The following modules must be loaded before this module:

  • No dependencies on other Kamailio modules.

2.2. External Libraries or Applications

The following libraries or applications must be installed before running Kamailio with this module loaded:

  • None.

3. Parameters

3.1. exec (str)

The definition of an exec task. The value of the parameter must have the following format:

  • "name=_string_;wait=_number_;workers=_number_"

The parameter can be set multiple times to get more exec tasks in same configuration file.

  • name - name of the event route to be executed. When used with a KEMI embedded language, this has to be the name of a function from the KEMI script. The function must have a string parameter, which will retrieve the index of the works in string format.

  • workers - if set to 0 or 1 the task is executed in a dedicated process. Any number > 1 will create more dedicated processes, each of them executing the task.

  • wait - timer interval in micro-seconds to wait inside the dedicated process before executing the task.

Default value is NULL.

Example 1.1. Set exec parameter

...
modparam("evrexec", "exec", "name=evrexec:timer;wait=1000;workers=1;")
...
event_route[evrexec:timer] {
  $var(x) = 0;
  while(1) {
    xlog("$$var(x) is $var(x)\n");
    $var(x) = $var(x) + 1;
    sleep("600");
  }
}
...

4. RPC Commands

4.1. evrexec.run

Run an event_route block or a KEMI function upon an RPC command.

Name: evroute.run

Parameters:

  • evname

    - the name of the event route block or the KEMI function.
  • evdata

    - (optional) - arbitrary data passed as a string, which is made available inside event route block as $evr(data).

RPC Command Format:

...
event_route[evrexec:test] {
   xlog("rpc command data: $evr(data)\n");
}
...
kamctl rpc evroute.run evroute:test
kamctl rpc evroute.run evroute:test mydata
...