def cli(ctx): """Print the uptime for kamailio \b Show time details since kamailio was started. """ command_ctl(ctx, 'core.uptime', [])
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' ])
def rtpengine_show(ctx): """Show the rtpengine records in memory \b Parameters: none """ command_ctl(ctx, 'rtpengine.show', [ 'all' ])
def mtree_show(ctx, tname): """Show the tree records in memory \b Parameters: <tname> - tree name """ command_ctl(ctx, "mtree.list", [tname])
def dialplan_list(ctx, dpid): """Show details for dialplan records in memory \b Parameters: <dpid> - dialplan id """ command_ctl(ctx, "dialplan.dump", [dpid])
def dispatcher_list(ctx, dpid): """Show details for dialplan records in memory \b Parameters: <dpid> - dialplan id """ command_ctl(ctx, 'dialplan.dump', [ dpid ])
def rtpengine_reload(ctx): """Reload the rtpengine records from database into memory \b Parameters: none """ command_ctl(ctx, 'rtpengine.reload', [ ])
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])
def mtree_show(ctx, tname): """Show the tree records in memory \b Parameters: <tname> - tree name """ command_ctl(ctx, 'mtree.list', [ tname ])
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 ])
def mtree_reload(ctx, tname): """Reload tree records from database into memory \b Parameters: <tname> - tree name """ command_ctl(ctx, 'mtree.reload', [ tname ])
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])
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])
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])
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])
def srv_ppdefines(ctx, full): """Show pre-processor defines \b """ if full: command_ctl(ctx, "core.ppdefines_full") else: command_ctl(ctx, "core.ppdefines")
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 ])
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])
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])
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])
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])
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])
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", [])
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 ])
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 ])
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])
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 ])
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])
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 ])
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], )
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])
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])
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()
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])
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}}, )
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])
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()
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 ])
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 ])
def domain_list(ctx): """Show details for domain records in memory \b """ command_ctl(ctx, 'domain.dump', [ ])
def tls_cfgoptions(ctx): """Show details for TLS options in memory \b """ command_ctl(ctx, 'tls.options', [ ])
def tls_cfgreload(ctx): """Reload tls configuration file \b """ command_ctl(ctx, 'tls.reload', [ ])
def tls_info(ctx): """Summary of tls usage \b """ command_ctl(ctx, 'tls.info', [ ])
def tls_conlist(ctx): """List current tls connections \b """ command_ctl(ctx, 'tls.list', [ ])
def dispatcher_list(ctx): """Show details for dispatcher records in memory \b """ command_ctl(ctx, 'dispatcher.list', [ ])
def dispatcher_list(ctx): """Show details for dispatcher records in memory \b """ command_ctl(ctx, 'dispatcher.list', [])
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', [ ])
def domain_reload(ctx): """Reload domain records from database into memory \b """ command_ctl(ctx, 'domain.reload', [ ])
def dialog_list(ctx): """Show details for dialog records in memory \b """ command_ctl(ctx, 'dlg.list', [ ])
def dialog_stats_active(ctx): """Show statistics for active dialogs \b """ command_ctl(ctx, 'dlg.stats_active', [ ])
def tcp_list(ctx): """List current TCP connections \b """ command_ctl(ctx, "core.tcp_list", [])
def address_reload(ctx): """Reload address records from database into memory """ command_ctl(ctx, 'permissions.addressReload', [ ])
def dispatcher_reload(ctx): """Reload dispatcher records from database into memory \b """ command_ctl(ctx, 'dispatcher.reload', [ ])
def tcp_info(ctx): """Summary of TCP usage \b """ command_ctl(ctx, "core.tcp_info", [])
def tcp_options(ctx): """Show details for TCP options in memory \b """ command_ctl(ctx, 'core.tcp_options', [ ])
def cli(ctx): """Show details about running kamailio processes \b """ command_ctl(ctx, 'core.psx', [], {"func": cmd_ps_result_print})
def tcp_list(ctx): """List current TCP connections \b """ command_ctl(ctx, 'core.tcp_list', [ ])
def dispatcher_reload(ctx): """Reload dispatcher records from database into memory \b """ command_ctl(ctx, 'dispatcher.reload', [])
def tcp_info(ctx): """Summary of TCP usage \b """ command_ctl(ctx, 'core.tcp_info', [ ])