Esempio n. 1
0
def cli(ctx):
    """Print the uptime for kamailio

    \b
    Show time details since kamailio was started.
    """
    command_ctl(ctx, 'core.uptime', [])
Esempio n. 2
0
def cli(ctx, single, names):
    """Print internal statistics

        \b
        Parameters:
            - [<name>]  - name of statistic or statistics group
                        - if missing, all statistics are printed
                        - it can be a list of names
    """
    if names:
        for n in names:
            if n.endswith(":"):
                # enforce group name by ending with ':'
                command_ctl(ctx, 'stats.get_statistics', [ n ])
            elif n.find(":")>0:
                # get only stat name, when providing 'group:stat'
                command_ctl(ctx, 'stats.get_statistics', [ n.split(":")[1] ])
            elif single:
                # single stat name flag
                command_ctl(ctx, 'stats.get_statistics', [ n ])
            else:
                # default is group name
                command_ctl(ctx, 'stats.get_statistics', [ n+":" ])
    else:
        # no name, print all
        command_ctl(ctx, 'stats.get_statistics', [ 'all' ])
Esempio n. 3
0
def rtpengine_show(ctx):
    """Show the rtpengine records in memory

    \b
    Parameters:
        none
    """
    command_ctl(ctx, 'rtpengine.show', [ 'all' ])
Esempio n. 4
0
def mtree_show(ctx, tname):
    """Show the tree records in memory

    \b
    Parameters:
        <tname> - tree name
    """
    command_ctl(ctx, "mtree.list", [tname])
Esempio n. 5
0
def dialplan_list(ctx, dpid):
    """Show details for dialplan records in memory

    \b
    Parameters:
        <dpid> - dialplan id
    """
    command_ctl(ctx, "dialplan.dump", [dpid])
Esempio n. 6
0
def dispatcher_list(ctx, dpid):
    """Show details for dialplan records in memory

    \b
    Parameters:
        <dpid> - dialplan id
    """
    command_ctl(ctx, 'dialplan.dump', [ dpid ])
Esempio n. 7
0
def rtpengine_reload(ctx):
    """Reload the rtpengine records from database into memory

    \b
    Parameters:
        none 
    """
    command_ctl(ctx, 'rtpengine.reload', [ ])
Esempio n. 8
0
def dialog_profile_list(ctx, profile):
    """List the dialogs groupped in a profile

    \b
    Parameters:
        <profile> - the name of the profile
    """
    command_ctl(ctx, "dlg.profile_list", [profile])
Esempio n. 9
0
def mtree_show(ctx, tname):
    """Show the tree records in memory

    \b
    Parameters:
        <tname> - tree name
    """
    command_ctl(ctx, 'mtree.list', [ tname ])
Esempio n. 10
0
def dialog_profile_list(ctx, profile):
    """List the dialogs groupped in a profile

    \b
    Parameters:
        <profile> - the name of the profile
    """
    command_ctl(ctx, 'dlg.profile_list', [ profile ])
Esempio n. 11
0
def mtree_reload(ctx, tname):
    """Reload tree records from database into memory

    \b
    Parameters:
        <tname> - tree name
    """
    command_ctl(ctx, 'mtree.reload', [ tname ])
Esempio n. 12
0
def srv_seti(ctx, name, ival):
    """Set $shv(name) to int value

    \b
    Parameters:
        <name> - the name of shv variable
        <ival> - the int value
    """
    command_ctl(ctx, "pv.shvSet", [name, "int", ival])
Esempio n. 13
0
def shv_sets(ctx, name, sval):
    """Set $shv(name) to string value

    \b
    Parameters:
        <name> - the name of shv variable
        <sval> - the string value
    """
    command_ctl(ctx, "pv.shvSet", [name, "str", sval])
Esempio n. 14
0
def htable_rm(ctx, htname, itname):
    """Remove the item $sht(htname=>itname)

    \b
    Parameters:
        <htname> - the name of hash table
        <itname> - the name of item
    """
    command_ctl(ctx, "htable.delete", [htname, itname])
Esempio n. 15
0
def dialplan_translate(ctx, dpid, ivalue):
    """Translate using the rules from dialplan applied to input value

    \b
    Parameters:
        <dpid> - dialplan id
        <ivalue> - input value
    """
    command_ctl(ctx, "dialplan.translate", [dpid, ivalue])
Esempio n. 16
0
def srv_ppdefines(ctx, full):
    """Show pre-processor defines

    \b
    """
    if full:
        command_ctl(ctx, "core.ppdefines_full")
    else:
        command_ctl(ctx, "core.ppdefines")
Esempio n. 17
0
def dispatcher_list(ctx, dpid, ivalue):
    """Translate using the rules from dialplan applied to input value

    \b
    Parameters:
        <dpid> - dialplan id
        <ivalue> - input value
    """
    command_ctl(ctx, 'dialplan.translate', [ dpid, ivalue ])
Esempio n. 18
0
def dispatcher_memrm(ctx, setid, destination):
    """Remove a destination from dispatcher memory

    \b
    Parameters:
        <setid> - dispatching set id
        <destination> - SIP URI for destination
    """
    command_ctl(ctx, "dispatcher.remove", [setid, destination])
Esempio n. 19
0
def htable_sets(ctx, htname, itname, sval):
    """Set $sht(htname=>itname) to string value

    \b
    Parameters:
        <htname> - the name of hash table
        <itname> - the name of item
        <sval> - the string value
    """
    command_ctl(ctx, "htable.sets", [htname, itname, sval])
Esempio n. 20
0
def htable_seti(ctx, htname, itname, ival):
    """Set $sht(htname=>itname) to int value

    \b
    Parameters:
        <htname> - the name of hash table
        <itname> - the name of item
        <ival> - the int value
    """
    command_ctl(ctx, "htable.seti", [htname, itname, ival])
Esempio n. 21
0
def dialog_terminate(ctx, callid, fromtag, totag):
    """Send BYE to the dialog identified by callid, from-tag and to-tag

    \b
    Parameters:
        <callid> - Call-Id value
        <fromtag> - From-Tag value
        <to-tag> - To-Tag value
    """
    command_ctl(ctx, "dlg.terminate_dlg", [callid, fromtag, totag])
Esempio n. 22
0
def dispatcher_memadd(ctx, flags, setid, destination):
    """Add a new destination in a set of dispatcher memory

    \b
    Parameters:
        <setid> - dispatching set id
        <destination> - SIP URI for destination
    """
    ctx.vlog("Adding to setid [%d] destination [%s]", setid, destination)
    command_ctl(ctx, "dispatcher.add", [setid, destination, flags])
Esempio n. 23
0
def cli(ctx):
    """Print the list of available raw RPC methods

    \b
    Show all available methods that can be executed with command 'rpc'.
    Examples:
        - kamcli rpcmethods
        - kamcli rpc <method> <params>
    """
    command_ctl(ctx, "system.listMethods", [])
Esempio n. 24
0
def dialog_list(ctx, callid, fromtag, totag):
    """Send BYE to the dialog identified by callid, from-tag and to-tag

    \b
    Parameters:
        <callid> - Call-Id value
        <fromtag> - From-Tag value
        <to-tag> - To-Tag value
    """
    command_ctl(ctx, 'dlg.terminate_dlg', [ callid, fromtag, totag ])
Esempio n. 25
0
def ul_add(ctx, table, expires, qval, cpath, flags, bflags, methods, userid, curi):
    """Add location record

    \b
    Parameters:
        <userid>       - username, AoR or SIP URI for subscriber
        <contact-uri>  - contact SIP URI
    """
    udata = parse_user_spec(ctx, userid)
    ctx.vlog('Adding record for [%s@%s]', udata['username'], udata['domain'])
    aor =  udata['username'] + '@' + udata['domain']
    command_ctl(ctx, 'ul.add', [ table, aor, curi, expires, qval, cpath, flags, bflags, methods ])
Esempio n. 26
0
def shv_get(ctx, name):
    """Get the value for $shv(name)

    \b
    Parameters:
        <name> - the name of shv variable
    """
    if not name:
        command_ctl(ctx, "pv.shvGet")
    else:
        for n in name:
            command_ctl(ctx, "pv.shvGet", [n])
Esempio n. 27
0
def ul_add(ctx, table, expires, qval, cpath, flags, bflags, methods, userid, curi):
    """Add location record

    \b
    Parameters:
        <userid>       - username, AoR or SIP URI for subscriber
        <contact-uri>  - contact SIP URI
    """
    udata = parse_user_spec(ctx, userid)
    ctx.vlog('Adding record for [%s@%s]', udata['username'], udata['domain'])
    aor =  udata['username'] + '@' + udata['domain']
    command_ctl(ctx, 'ul_add', [ table, aor, curi, expires, qval, cpath, flags, bflags, methods ])
Esempio n. 28
0
def htable_get(ctx, htname, itname):
    """Get the value for $sht(htname=>itname)

    \b
    Parameters:
        <htname> - the name of hash table
        <itname> - the name of item
    """
    if not itname:
        command_ctl(ctx, "htable.dump", [htname])
    else:
        for itn in itname:
            command_ctl(ctx, "htable.get", [htname, itn])
Esempio n. 29
0
def ul_rm(ctx, table, userid, curi):
    """Show details for location records in memory

    \b
    Parameters:
        <userid>         - username, AoR or SIP URI for subscriber
        [<contact-uri>]  - contact SIP URI
                         - optional, it can be a list of URIs
    """
    udata = parse_user_spec(ctx, userid)
    ctx.vlog('Showing record for [%s@%s]', udata['username'], udata['domain'])
    aor =  udata['username'] + '@' + udata['domain']
    if curi:
        for c in curi:
            command_ctl(ctx, 'ul_rm', [ table, aor, c ])
    else:
        command_ctl(ctx, 'ul_rm', [ table, aor ])
Esempio n. 30
0
def ul_add(ctx, table, expires, qval, cpath, flags, bflags, methods, userid,
           curi):
    """Add location record

    \b
    Parameters:
        <userid>       - username, AoR or SIP URI for subscriber
        <contact-uri>  - contact SIP URI
    """
    udata = parse_user_spec(ctx, userid)
    ctx.vlog("Adding record for [%s@%s]", udata["username"], udata["domain"])
    aor = udata["username"] + "@" + udata["domain"]
    command_ctl(
        ctx,
        "ul.add",
        [table, aor, curi, expires, qval, cpath, flags, bflags, methods],
    )
Esempio n. 31
0
def dialog_match(ctx, mkey, mop, mval):
    """Show the details for the matching dialogs

    \b
    Parameters:
        <mkey> - matching key:
          ruri - use R-URI;
          furi - use From-URI;
          turi - use To-URI;
          callid - use Call-Id
        <mop> - matching operator:
          eq - string comparison;
          re - regular expression;
          sw - starts-with
        <mval> - matching value
    """
    command_ctl(ctx, "dlg.list_match", [mkey, mop, mval])
Esempio n. 32
0
def ul_rm(ctx, table, userid, curi):
    """Show details for location records in memory

    \b
    Parameters:
        <userid>         - username, AoR or SIP URI for subscriber
        [<contact-uri>]  - contact SIP URI
                         - optional, it can be a list of URIs
    """
    udata = parse_user_spec(ctx, userid)
    ctx.vlog("Showing record for [%s@%s]", udata["username"], udata["domain"])
    aor = udata["username"] + "@" + udata["domain"]
    if curi:
        for c in curi:
            command_ctl(ctx, "ul.rm", [table, aor, c])
    else:
        command_ctl(ctx, "ul.rm", [table, aor])
Esempio n. 33
0
def cli(ctx, norefresh):
    """Monitor relevant statistics on display

    \b
    Parameters:
        - --no-refresh - execute once
    Monitored statistics:
        tm, sl and usrloc
    """

    def clear():
        return os.system("tput reset")

    count = 0
    slist = [
        "rcv_requests",
        "fwd_requests",
        "rcv_replies",
        "fwd_replies",
        "free_size",
        "sent_replies",
        "tmx:",
        "usrloc:",
    ]
    if norefresh is True:
        command_ctl(
            ctx, "stats.get_statistics", slist, {"func": cmd_moni_result_print}
        )
    else:
        while True:
            count = count + 1
            command_ctl(
                ctx,
                "stats.get_statistics",
                slist,
                {"func": cmd_moni_result_print},
            )
            print()
            print(
                "[cycle #: "
                + str(count)
                + "; if constant make sure server is running]"
            )
            time.sleep(2)
            clear()
Esempio n. 34
0
def dlgs_getall(ctx, mkey, mop, mval):
    """Show the details for all matching dialogs

    \b
    Parameters:
        <mkey> - matching key:
          src - src attribute;
          dst - dst attribute;
          data - data attribute;
        <mop> - matching operator:
          eq - equal string comparison;
          ne - not-equal string comparison;
          re - regular expression;
          sw - starts-with
          fm - fast match
        <mval> - matching value
    """
    command_ctl(ctx, "dlgs.getall", [mkey, mop, mval])
Esempio n. 35
0
def cli(ctx, all):
    """Store runtime details and gdb full backtrace for all Kamailio processes to a file

    \b
    """
    ofile = (
        "/tmp/gdb_kamailio_"
        + datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
        + ".txt"
    )
    if all:
        command_ctl(
            ctx,
            "core.version",
            [],
            {
                "func": cmd_trap_rpc_print,
                "params": {"ofile": ofile, "otitle": "core.version"},
            },
        )
        command_ctl(
            ctx,
            "core.uptime",
            [],
            {
                "func": cmd_trap_rpc_print,
                "params": {"ofile": ofile, "otitle": "core.uptime"},
            },
        )
    command_ctl(
        ctx,
        "core.psx",
        [],
        {"func": cmd_trap_print, "params": {"ofile": ofile}},
    )
Esempio n. 36
0
def ul_show(ctx, brief, table, userid):
    """Show details for location records in memory

    \b
    Parameters:
        [<userid>] - username, AoR or SIP URI for subscriber
                   - it can be a list of userids
                   - if not provided then all records are shown
    """
    if not userid:
        ctx.vlog("Showing all records")
        if brief:
            command_ctl(ctx, "ul.dump", ["brief"])
        else:
            command_ctl(ctx, "ul.dump", [])
    else:
        for u in userid:
            udata = parse_user_spec(ctx, u)
            ctx.vlog(
                "Showing record for [%s@%s]",
                udata["username"],
                udata["domain"],
            )
            aor = udata["username"] + "@" + udata["domain"]
            command_ctl(ctx, "ul.lookup", [table, aor])
Esempio n. 37
0
def cli(ctx, norefresh):
    """Monitor relevant statistics on display

    \b
    Parameters:
        - --no-refresh - execute once
    Monitored statistics:
        tm, sl and usrloc
    """

    clear = lambda : os.system('tput reset')
    count = 0
    slist = [ "rcv_requests", "fwd_requests", "rcv_replies", "fwd_replies",
            "free_size", "sent_replies", "tmx:", "usrloc:" ]
    if norefresh is True:
        command_ctl(ctx, 'stats.get_statistics', slist, {"func": cmd_moni_result_print})
    else:
        while True:
            count = count + 1
            command_ctl(ctx, 'stats.get_statistics', slist, {"func": cmd_moni_result_print})
            print()
            print("[cycle #: " + str(count) + "; if constant make sure server is running]")
            time.sleep(2)
            clear()
Esempio n. 38
0
def ul_show(ctx, brief, table, userid):
    """Show details for location records in memory

    \b
    Parameters:
        [<userid>] - username, AoR or SIP URI for subscriber
                   - it can be a list of userids
                   - if not provided then all records are shown
    """
    if not userid:
        ctx.vlog('Showing all records')
        if brief:
            command_ctl(ctx, 'ul.dump', [ 'brief' ])
        else:
            command_ctl(ctx, 'ul.dump', [ ])
    else:
        for u in userid:
            udata = parse_user_spec(ctx, u)
            ctx.vlog('Showing record for [%s@%s]', udata['username'], udata['domain'])
            aor =  udata['username'] + '@' + udata['domain']
            command_ctl(ctx, 'ul.lookup', [ table, aor ])
Esempio n. 39
0
def ul_show(ctx, brief, table, userid):
    """Show details for location records in memory

    \b
    Parameters:
        [<userid>] - username, AoR or SIP URI for subscriber
                   - it can be a list of userids
                   - if not provided then all records are shown
    """
    if not userid:
        ctx.vlog('Showing all records')
        if brief:
            command_ctl(ctx, 'ul_dump', [ 'brief' ])
        else:
            command_ctl(ctx, 'ul_dump', [ ])
    else:
        for u in userid:
            udata = parse_user_spec(ctx, u)
            ctx.vlog('Showing record for [%s@%s]', udata['username'], udata['domain'])
            aor =  udata['username'] + '@' + udata['domain']
            command_ctl(ctx, 'ul_show_contact', [ table, aor ])
Esempio n. 40
0
def domain_list(ctx):
    """Show details for domain records in memory

    \b
    """
    command_ctl(ctx, 'domain.dump', [ ])
Esempio n. 41
0
def tls_cfgoptions(ctx):
    """Show details for TLS options in memory

    \b
    """
    command_ctl(ctx, 'tls.options', [ ])
Esempio n. 42
0
def tls_cfgreload(ctx):
    """Reload tls configuration file

    \b
    """
    command_ctl(ctx, 'tls.reload', [ ])
Esempio n. 43
0
def tls_info(ctx):
    """Summary of tls usage

    \b
    """
    command_ctl(ctx, 'tls.info', [ ])
Esempio n. 44
0
def tls_conlist(ctx):
    """List current tls connections

    \b
    """
    command_ctl(ctx, 'tls.list', [ ])
Esempio n. 45
0
def dispatcher_list(ctx):
    """Show details for dispatcher records in memory

    \b
    """
    command_ctl(ctx, 'dispatcher.list', [ ])
Esempio n. 46
0
def dispatcher_list(ctx):
    """Show details for dispatcher records in memory

    \b
    """
    command_ctl(ctx, 'dispatcher.list', [])
Esempio n. 47
0
def address_list(ctx, mode, group):
    """Show details for address records in memory

    \b
    Parameters:
        <group> - address group
    """
    if mode == "all":
        command_ctl(ctx, 'permissions.addressDump', [ ])
        command_ctl(ctx, 'permissions.subnetDump', [ ])
        command_ctl(ctx, 'permissions.domainDump', [ ])
    elif mode == "addresses":
        command_ctl(ctx, 'permissions.addressDump', [ ])
    elif mode == "subnets":
        command_ctl(ctx, 'permissions.subnetDump', [ ])
    elif mode == "domains":
        command_ctl(ctx, 'permissions.domainDump', [ ])
    else:
        command_ctl(ctx, 'permissions.addressDump', [ ])
Esempio n. 48
0
def domain_reload(ctx):
    """Reload domain records from database into memory

    \b
    """
    command_ctl(ctx, 'domain.reload', [ ])
Esempio n. 49
0
def dialog_list(ctx):
    """Show details for dialog records in memory

    \b
    """
    command_ctl(ctx, 'dlg.list', [ ])
Esempio n. 50
0
def dialog_stats_active(ctx):
    """Show statistics for active dialogs

    \b
    """
    command_ctl(ctx, 'dlg.stats_active', [ ])
Esempio n. 51
0
def tcp_list(ctx):
    """List current TCP connections

    \b
    """
    command_ctl(ctx, "core.tcp_list", [])
Esempio n. 52
0
def address_reload(ctx):
    """Reload address records from database into memory
    """
    command_ctl(ctx, 'permissions.addressReload', [ ])
Esempio n. 53
0
def dispatcher_reload(ctx):
    """Reload dispatcher records from database into memory

    \b
    """
    command_ctl(ctx, 'dispatcher.reload', [ ])
Esempio n. 54
0
def tcp_info(ctx):
    """Summary of TCP usage

    \b
    """
    command_ctl(ctx, "core.tcp_info", [])
Esempio n. 55
0
def tcp_options(ctx):
    """Show details for TCP options in memory

    \b
    """
    command_ctl(ctx, 'core.tcp_options', [ ])
Esempio n. 56
0
def cli(ctx):
    """Show details about running kamailio processes

    \b
    """
    command_ctl(ctx, 'core.psx', [], {"func": cmd_ps_result_print})
Esempio n. 57
0
def tcp_list(ctx):
    """List current TCP connections

    \b
    """
    command_ctl(ctx, 'core.tcp_list', [ ])
Esempio n. 58
0
def dispatcher_reload(ctx):
    """Reload dispatcher records from database into memory

    \b
    """
    command_ctl(ctx, 'dispatcher.reload', [])
Esempio n. 59
0
def tcp_info(ctx):
    """Summary of TCP usage

    \b
    """
    command_ctl(ctx, 'core.tcp_info', [ ])