EvRExec Module

Daniel-Constantin Mierla

   asipto.com
   <miconda@gmail.com>

Edited by

Daniel-Constantin Mierla

   <miconda@gmail.com>

   Copyright © 2017 http://www.asipto.com
     __________________________________________________________________

   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

   Table of Contents

   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

1. Overview

   The module executes event route blocks or KEMI functions on dedicated
   processes at startup, upon an RPC command or data received on a custom
   UDP socket.

   For startup event route, 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
   2.2. External Libraries or Applications

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)

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_;sockaddr=_udp_socket_
       "

   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 startup task. For UDP data execution (when
       'sockaddr' is set), only 1 worker process is created.
     * wait - timer interval in micro-seconds to wait inside the dedicated
       process before executing the task.
     * sockaddr - full UDP socket address in format 'udp:ip:port'
       (example: 'udp:127.0.0.1:54321'). Received data is made available
       in the event route via $evr(data).

   Default value is NULL.

   Example 1.1. Set exec parameter
...
modparam("evrexec", "exec", "name=evrexec:timer;wait=1000;workers=1;")
modparam("evrexec", "exec", "name=evrexec:udp;sockaddr=udp:127.0.0.1:4444;worker
s=1;")
...
event_route[evrexec:timer] {
  $var(x) = 0;
  while(1) {
    xlog("$$var(x) is $var(x)\n");
    $var(x) = $var(x) + 1;
    sleep("600");
  }
}

event_route[evrexec:udp] {
  xinfo("udp socket data: [$evr(data)] from [$evr(srcip)]\n");
}

...

4. RPC Commands

   4.1. evrexec.run

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
...
