MI命令
管理接口(MI)是OpenSIPS提供的http接口,允许外部应用程序在OpenSIPS中触发预定义的命令。
有以下功能:
- 将配置设置到OpenSIPS(如设置调试级别,注册联系人等)
- 从OpenSIPS获取数据(查看注册用户,查看正在进行的呼叫,获取统计信息等)
- 在OpenSIPS中触发内部操作(重新加载数据,发送消息等)
1 curl命令使用方式
1.1 不带参数的命令
举例:curl -X POST 127.0.0.1:8888/mi -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": "1", "method": "ps"}'
说明:
- method参数的值就是对应的命令
1.2 带参数的命令
参数存在2种写法
- 不指定参数名,直接传值的方式
- log_level 命令有2个参数level和pid,则参数这么传 "params":[3, 1234],
完整URL请求就是curl -X POST 127.0.0.1:8888/mi -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": "1", "method": "log_level", "params":[3, 1234]}'
- 指定参数名的值传递(建议用这种,参数清晰点)
- log_level 命令有2个参数level和pid,则参数这么传 "params":{"level" : 3, "pid" : 1234},
完整URL请求就是 curl -X POST 127.0.0.1:8888/mi -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": "1", "method": "log_level", "params":{"level" : 3, "pid" : 1234}'
2 常用命令
2.1 get_statistics
获取统计值
参数:statistics,是一个数组,一定要带且不能为空,
- 传all,
#请求消息体,传all
{
"jsonrpc": "2.0",
"id": "1",
"method": "get_statistics",
"params": {
"statistics": [
"all"
]
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"cdb:cdb_slow_queries": 0,
"cdb:cdb_total_queries": 667,
"core:bad_URIs_rcvd": 0,
"core:bad_msg_hdr": 0,
"core:drop_replies": 0,
"core:drop_requests": 0,
"core:err_replies": 0,
"core:err_requests": 0,
"core:fwd_replies": 0,
"core:fwd_requests": 0,
"core:rcv_replies": 1388,
"core:rcv_requests": 667,
"core:slow_messages": 0,
"core:timestamp": 23703,
"dns:dns_slow_queries": 0,
"dns:dns_total_queries": 0,
"load:load": 0,
"load:load-all": 0,
"load:load-proc-1": 0,
"load:load-proc-2": 0,
"load:load-proc-3": 0,
"load:load-proc-4": 0,
"load:load-proc-5": 0,
"load:load-proc-6": 0,
"load:load-proc-7": 0,
"load:load10m": 0,
"load:load10m-all": 0,
"load:load10m-proc-1": 0,
"load:load10m-proc-2": 0,
"load:load10m-proc-3": 0,
"load:load10m-proc-4": 0,
"load:load10m-proc-5": 0,
"load:load10m-proc-6": 0,
"load:load10m-proc-7": 0,
"load:load1m": 0,
"load:load1m-all": 0,
"load:load1m-proc-1": 0,
"load:load1m-proc-2": 0,
"load:load1m-proc-3": 0,
"load:load1m-proc-4": 0,
"load:load1m-proc-5": 0,
"load:load1m-proc-6": 0,
"load:load1m-proc-7": 0,
"load:processes_number": 8,
"nat_traversal:dialog_endpoints": 0,
"nat_traversal:keepalive_endpoints": 0,
"nat_traversal:registered_endpoints": 0,
"nat_traversal:subscribed_endpoints": 0,
"net:waiting_tcp": 0,
"net:waiting_tls": 0,
"net:waiting_udp": 0,
"pkmem:1-fragments": 329,
"pkmem:1-free_size": 1073242208,
"pkmem:1-max_used_size": 502528,
"pkmem:1-real_used_size": 499616,
"pkmem:1-total_size": 1073741824,
"pkmem:1-used_size": 249480,
"pkmem:2-fragments": 0,
"pkmem:2-free_size": 0,
"pkmem:2-max_used_size": 0,
"pkmem:2-real_used_size": 0,
"pkmem:2-total_size": 0,
"pkmem:2-used_size": 0,
"pkmem:3-fragments": 0,
"pkmem:3-free_size": 0,
"pkmem:3-max_used_size": 0,
"pkmem:3-real_used_size": 0,
"pkmem:3-total_size": 0,
"pkmem:3-used_size": 0,
"pkmem:4-fragments": 324,
"pkmem:4-free_size": 1073246840,
"pkmem:4-max_used_size": 507120,
"pkmem:4-real_used_size": 494984,
"pkmem:4-total_size": 1073741824,
"pkmem:4-used_size": 245136,
"pkmem:5-fragments": 321,
"pkmem:5-free_size": 1073247528,
"pkmem:5-max_used_size": 494976,
"pkmem:5-real_used_size": 494296,
"pkmem:5-total_size": 1073741824,
"pkmem:5-used_size": 244928,
"pkmem:6-fragments": 321,
"pkmem:6-free_size": 1073247528,
"pkmem:6-max_used_size": 494976,
"pkmem:6-real_used_size": 494296,
"pkmem:6-total_size": 1073741824,
"pkmem:6-used_size": 244928,
"pkmem:7-fragments": 249,
"pkmem:7-free_size": 1073261984,
"pkmem:7-max_used_size": 479840,
"pkmem:7-real_used_size": 479840,
"pkmem:7-total_size": 1073741824,
"pkmem:7-used_size": 234984,
"rpmem:rpm_fragments": 0,
"rpmem:rpm_free_size": 0,
"rpmem:rpm_max_used_size": 0,
"rpmem:rpm_real_used_size": 0,
"rpmem:rpm_total_size": 0,
"rpmem:rpm_used_size": 0,
"shmem:fragments": 519,
"shmem:free_size": 1069410776,
"shmem:max_used_size": 4517456,
"shmem:real_used_size": 4331048,
"shmem:total_size": 1073741824,
"shmem:used_size": 4062000,
"sl:1xx_replies": 0,
"sl:2xx_replies": 0,
"sl:3xx_replies": 0,
"sl:4xx_replies": 0,
"sl:5xx_replies": 0,
"sl:6xx_replies": 0,
"sl:received_ACKs": 0,
"sl:sent_err_replies": 0,
"sl:sent_replies": 0,
"sql:sql_slow_queries": 0,
"sql:sql_total_queries": 0,
"tm:2xx_transactions": 1384,
"tm:3xx_transactions": 0,
"tm:4xx_transactions": 4019,
"tm:5xx_transactions": 0,
"tm:6xx_transactions": 0,
"tm:UAC_transactions": 4740,
"tm:UAS_transactions": 664,
"tm:cluster_cancel_recv": 0,
"tm:cluster_cancel_sent": 0,
"tm:cluster_reply_recv": 0,
"tm:cluster_reply_sent": 0,
"tm:cluster_request_recv": 0,
"tm:cluster_request_sent": 0,
"tm:inuse_transactions": 2,
"tm:local_replies": 4015,
"tm:received_replies": 1388,
"tm:relayed_replies": 1388
}
}
- 具体模块,比如rpmem模块:"rpmem:",注意传具体模块时,一定要带上冒号
#请求,传多个指定模块
{
"jsonrpc": "2.0",
"id": "1",
"method": "get_statistics",
"params": {
"statistics": [
"rpmem:",
"pkmem:"
]
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"pkmem:1-fragments": 329,
"pkmem:1-free_size": 1073242192,
"pkmem:1-max_used_size": 502528,
"pkmem:1-real_used_size": 499632,
"pkmem:1-total_size": 1073741824,
"pkmem:1-used_size": 249496,
"pkmem:2-fragments": 0,
"pkmem:2-free_size": 0,
"pkmem:2-max_used_size": 0,
"pkmem:2-real_used_size": 0,
"pkmem:2-total_size": 0,
"pkmem:2-used_size": 0,
"pkmem:3-fragments": 0,
"pkmem:3-free_size": 0,
"pkmem:3-max_used_size": 0,
"pkmem:3-real_used_size": 0,
"pkmem:3-total_size": 0,
"pkmem:3-used_size": 0,
"pkmem:4-fragments": 324,
"pkmem:4-free_size": 1073246840,
"pkmem:4-max_used_size": 507120,
"pkmem:4-real_used_size": 494984,
"pkmem:4-total_size": 1073741824,
"pkmem:4-used_size": 245136,
"pkmem:5-fragments": 321,
"pkmem:5-free_size": 1073247528,
"pkmem:5-max_used_size": 494976,
"pkmem:5-real_used_size": 494296,
"pkmem:5-total_size": 1073741824,
"pkmem:5-used_size": 244928,
"pkmem:6-fragments": 321,
"pkmem:6-free_size": 1073247528,
"pkmem:6-max_used_size": 494976,
"pkmem:6-real_used_size": 494296,
"pkmem:6-total_size": 1073741824,
"pkmem:6-used_size": 244928,
"pkmem:7-fragments": 249,
"pkmem:7-free_size": 1073261984,
"pkmem:7-max_used_size": 479840,
"pkmem:7-real_used_size": 479840,
"pkmem:7-total_size": 1073741824,
"pkmem:7-used_size": 234984,
"rpmem:rpm_fragments": 0,
"rpmem:rpm_free_size": 0,
"rpmem:rpm_max_used_size": 0,
"rpmem:rpm_real_used_size": 0,
"rpmem:rpm_total_size": 0,
"rpmem:rpm_used_size": 0
}
}
- 传具体的统计项,如 total_size
#请求,传具体统计项
{
"jsonrpc": "2.0",
"id": "1",
"method": "get_statistics",
"params": {
"statistics": [
"total_size"
]
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"shmem:total_size": 1073741824
}
}
2.2 list_statistics
打印可用统计信息列表,参数和get_statistics命令基本一致,只是查所有(all)在这里换成不带参数
参数:
- 空
- 不带参数时,显示的是所有的统计信息
#请求不带参数
{
"jsonrpc": "2.0",
"id": "1",
"method": "list_statistics",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"cdb:cdb_slow_queries": "incremental",
"cdb:cdb_total_queries": "incremental",
"core:bad_URIs_rcvd": "incremental",
"core:bad_msg_hdr": "incremental",
"core:drop_replies": "incremental",
"core:drop_requests": "incremental",
"core:err_replies": "incremental",
"core:err_requests": "incremental",
"core:fwd_replies": "incremental",
"core:fwd_requests": "incremental",
"core:rcv_replies": "incremental",
"core:rcv_requests": "incremental",
"core:slow_messages": "incremental",
"core:timestamp": "non-incremental",
"dns:dns_slow_queries": "incremental",
"dns:dns_total_queries": "incremental",
"load:load": "non-incremental",
"load:load-all": "non-incremental",
"load:load-proc-1": "non-incremental",
"load:load-proc-2": "non-incremental",
"load:load-proc-3": "non-incremental",
"load:load-proc-4": "non-incremental",
"load:load-proc-5": "non-incremental",
"load:load-proc-6": "non-incremental",
"load:load-proc-7": "non-incremental",
"load:load10m": "non-incremental",
"load:load10m-all": "non-incremental",
"load:load10m-proc-1": "non-incremental",
"load:load10m-proc-2": "non-incremental",
"load:load10m-proc-3": "non-incremental",
"load:load10m-proc-4": "non-incremental",
"load:load10m-proc-5": "non-incremental",
"load:load10m-proc-6": "non-incremental",
"load:load10m-proc-7": "non-incremental",
"load:load1m": "non-incremental",
"load:load1m-all": "non-incremental",
"load:load1m-proc-1": "non-incremental",
"load:load1m-proc-2": "non-incremental",
"load:load1m-proc-3": "non-incremental",
"load:load1m-proc-4": "non-incremental",
"load:load1m-proc-5": "non-incremental",
"load:load1m-proc-6": "non-incremental",
"load:load1m-proc-7": "non-incremental",
"load:processes_number": "non-incremental",
"nat_traversal:dialog_endpoints": "non-incremental",
"nat_traversal:keepalive_endpoints": "non-incremental",
"nat_traversal:registered_endpoints": "non-incremental",
"nat_traversal:subscribed_endpoints": "non-incremental",
"net:waiting_tcp": "non-incremental",
"net:waiting_tls": "non-incremental",
"net:waiting_udp": "non-incremental",
"pkmem:1-fragments": "non-incremental",
"pkmem:1-free_size": "non-incremental",
"pkmem:1-max_used_size": "non-incremental",
"pkmem:1-real_used_size": "non-incremental",
"pkmem:1-total_size": "non-incremental",
"pkmem:1-used_size": "non-incremental",
"pkmem:2-fragments": "non-incremental",
"pkmem:2-free_size": "non-incremental",
"pkmem:2-max_used_size": "non-incremental",
"pkmem:2-real_used_size": "non-incremental",
"pkmem:2-total_size": "non-incremental",
"pkmem:2-used_size": "non-incremental",
"pkmem:3-fragments": "non-incremental",
"pkmem:3-free_size": "non-incremental",
"pkmem:3-max_used_size": "non-incremental",
"pkmem:3-real_used_size": "non-incremental",
"pkmem:3-total_size": "non-incremental",
"pkmem:3-used_size": "non-incremental",
"pkmem:4-fragments": "non-incremental",
"pkmem:4-free_size": "non-incremental",
"pkmem:4-max_used_size": "non-incremental",
"pkmem:4-real_used_size": "non-incremental",
"pkmem:4-total_size": "non-incremental",
"pkmem:4-used_size": "non-incremental",
"pkmem:5-fragments": "non-incremental",
"pkmem:5-free_size": "non-incremental",
"pkmem:5-max_used_size": "non-incremental",
"pkmem:5-real_used_size": "non-incremental",
"pkmem:5-total_size": "non-incremental",
"pkmem:5-used_size": "non-incremental",
"pkmem:6-fragments": "non-incremental",
"pkmem:6-free_size": "non-incremental",
"pkmem:6-max_used_size": "non-incremental",
"pkmem:6-real_used_size": "non-incremental",
"pkmem:6-total_size": "non-incremental",
"pkmem:6-used_size": "non-incremental",
"pkmem:7-fragments": "non-incremental",
"pkmem:7-free_size": "non-incremental",
"pkmem:7-max_used_size": "non-incremental",
"pkmem:7-real_used_size": "non-incremental",
"pkmem:7-total_size": "non-incremental",
"pkmem:7-used_size": "non-incremental",
"rpmem:rpm_fragments": "non-incremental",
"rpmem:rpm_free_size": "non-incremental",
"rpmem:rpm_max_used_size": "non-incremental",
"rpmem:rpm_real_used_size": "non-incremental",
"rpmem:rpm_total_size": "non-incremental",
"rpmem:rpm_used_size": "non-incremental",
"shmem:fragments": "non-incremental",
"shmem:free_size": "non-incremental",
"shmem:max_used_size": "non-incremental",
"shmem:real_used_size": "non-incremental",
"shmem:total_size": "non-incremental",
"shmem:used_size": "non-incremental",
"sl:1xx_replies": "incremental",
"sl:2xx_replies": "incremental",
"sl:3xx_replies": "incremental",
"sl:4xx_replies": "incremental",
"sl:5xx_replies": "incremental",
"sl:6xx_replies": "incremental",
"sl:received_ACKs": "incremental",
"sl:sent_err_replies": "incremental",
"sl:sent_replies": "incremental",
"sql:sql_slow_queries": "incremental",
"sql:sql_total_queries": "incremental",
"tm:2xx_transactions": "incremental",
"tm:3xx_transactions": "incremental",
"tm:4xx_transactions": "incremental",
"tm:5xx_transactions": "incremental",
"tm:6xx_transactions": "incremental",
"tm:UAC_transactions": "incremental",
"tm:UAS_transactions": "incremental",
"tm:cluster_cancel_recv": "incremental",
"tm:cluster_cancel_sent": "incremental",
"tm:cluster_reply_recv": "incremental",
"tm:cluster_reply_sent": "incremental",
"tm:cluster_request_recv": "incremental",
"tm:cluster_request_sent": "incremental",
"tm:inuse_transactions": "non-incremental",
"tm:local_replies": "incremental",
"tm:received_replies": "incremental",
"tm:relayed_replies": "incremental"
}
}
- statistics
- 传具体模块,比如rpmem模块:"rpmem:",注意传具体模块时,一定要带上冒号
#请求,传指定模块,
{
"jsonrpc": "2.0",
"id": "1",
"method": "list_statistics",
"params": {
"statistics": [
"rpmem:"
]
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"rpmem:rpm_fragments": "non-incremental",
"rpmem:rpm_free_size": "non-incremental",
"rpmem:rpm_max_used_size": "non-incremental",
"rpmem:rpm_real_used_size": "non-incremental",
"rpmem:rpm_total_size": "non-incremental",
"rpmem:rpm_used_size": "non-incremental"
}
}
- 传具体统计项,如 total_size
#请求,传具体统计项
{
"jsonrpc": "2.0",
"id": "1",
"method": "list_statistics",
"params": {
"statistics": [
"total_size"
]
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"total_size": "non-incremental"
}
}
2.3 reset_statistics
将统计值重置
参数:statistics:是一个数组,一定要带且不能为空,只能传指定的统计项,比如 received_replies,注意不是所有的统计项都能reset
#传具体统计项
#传具体统计项
{
"jsonrpc": "2.0",
"id": "1",
"method": "reset_statistics",
"params": {
"statistics": [
"received_replies"
]
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.4 uptime
打印启动时间
参数:空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "uptime",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Now": "Thu Nov 3 16:26:55 2022",
"Up since": "Thu Nov 3 09:11:55 2022",
"Up time": "26100 [sec]"
}
}
2.5 version
打印版本
参数:
- 空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "version",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Server": "OpenSIPS (3.4.0-dev (x86_64/linux))"
}
}
- revision:暂时没看到有什么用
2.6 pwd
打印工作目录
参数:空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "pwd",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"WD": "/"
}
}
2.7 arg
打印运行参数
参数:空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "arg",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
"./opensips",
"-f",
"./opensips.cfg",
"-m",
"1024",
"-M",
"1024"
]
}
2.8 which
打印所有的命令
参数:
- 空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "which",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
"get_statistics",
"list_statistics",
"reset_statistics",
"uptime",
"version",
"pwd",
"arg",
"which",
"ps",
"kill",
"log_level",
"xlog_level",
"shm_check",
"cache_store",
"cache_fetch",
"cache_remove",
"event_subscribe",
"events_list",
"subscribers_list",
"raise_event",
"list_tcp_conns",
"mem_pkg_dump",
"mem_shm_dump",
"mem_rpm_dump",
"reload_routes",
"sr_get_status",
"sr_list_status",
"sr_list_reports",
"sr_list_identifiers",
"help",
"list_blacklists",
"t_uac_dlg",
"t_uac_cancel",
"t_hash",
"t_reply",
"httpd_list_root_path",
"tcp_trace",
"ds_set_state",
"ds_list",
"ds_reload",
"ds_push_script_attrs",
"nh_enable_ping",
"cache_remove_chunk"
]
}
- command:具体的命令,通过这个能将命令需要带的参数组合打印出来
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "which",
"params": {
"command": "subscribers_list"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
[],
[
"event"
],
[
"event",
"socket"
]
]
}
2.9 ps
打印所有的进程
参数:空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ps",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Processes": [
{
"ID": 0,
"PID": 11925,
"Type": "attendant"
},
{
"ID": 1,
"PID": 11926,
"Type": "HTTPD *:8888"
},
{
"ID": 2,
"PID": 11927,
"Type": "time_keeper"
},
{
"ID": 3,
"PID": 11928,
"Type": "timer"
},
{
"ID": 4,
"PID": 11929,
"Type": "SIP receiver udp:192.168.1.100:5999"
},
{
"ID": 5,
"PID": 11930,
"Type": "TCP receiver"
},
{
"ID": 6,
"PID": 11931,
"Type": "Timer handler"
},
{
"ID": 7,
"PID": 11932,
"Type": "TCP main"
}
]
}
}
2.10 kill
终止程序,执行后程序会退出
参数:空
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "kill",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.11 log_level
获取、设置程序的日志级别
参数
- 空:打印日志级别
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "log_level",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Processes": [
{
"Log level": 3,
"PID": 54053,
"Type": "attendant"
},
{
"Log level": 3,
"PID": 54054,
"Type": "HTTPD *:8888"
},
{
"Log level": 3,
"PID": 54055,
"Type": "time_keeper"
},
{
"Log level": 3,
"PID": 54056,
"Type": "timer"
},
{
"Log level": 3,
"PID": 54057,
"Type": "SIP receiver udp:192.168.1.100:5999"
},
{
"Log level": 3,
"PID": 54058,
"Type": "TCP receiver"
},
{
"Log level": 3,
"PID": 54059,
"Type": "Timer handler"
},
{
"Log level": 3,
"PID": 54060,
"Type": "TCP main"
}
]
}
}
- level:设置所有的日志级别
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "log_level",
"params": {
"level": 4
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"New global log level": 4
}
}
- level、pid:设置指定pid的日志级别
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "log_level",
"params": {
"level": 3,
"pid": 54060
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Log level": 4
}
}
2.12 xlog_level
获取、设置xlog的日志级别
参数:
- 空:打印xlog日志级别
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "xlog_level",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"xLog Level": 2
}
}
- level:设置xlog日志级别
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "xlog_level",
"params": {
"level": 4
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"xLog Level": 4
}
}
2.13 shm_check
2.13 扫描共享内存池,如果发现错误,则终止opensips
参数:无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "shm_check",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {},
"total_fragments": 530
}
2.14 cache_store
保存数据到缓存系统
说明
- system:缓存系统,例如local、redis、mongodb
- attr:属性名
- value:值
参数:
- system、attr、values:缓存数据到指定缓存系统。
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "cache_store",
"params": {
"system": "redis",
"attr": "testKey",
"value": "testValue"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
- system、attr、value、expire:缓存数据到指定缓存系统,并设置过期时间
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "cache_store",
"params": {
"system": "redis",
"attr": "testKey2",
"value": "testValue2",
"expire": 1000
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.15 cache_fetch
读取缓存系统里面的数据
说明
- system:缓存系统,例如local、redis、mongodb
- attr:属性名
参数:
- system、attr
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "cache_fetch",
"params": {
"system": "redis",
"attr": "testKey"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"key": "testKey",
"value": "testValue"
}
}
2.16 cache_remove
删除缓存系统里面的数据
说明
- system:缓存系统,例如local、redis、mongodb
- attr:属性名
参数:
- system、attr
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "cache_remove",
"params": {
"system": "redis",
"attr": "testKey"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.17 event_subscribe ???
订阅一个事件
说明:
- event:事件
- socket:
- expire:单位秒,如果需要设置过期时间,则设置这个值,不设置默认是3600
参数:
- event、socket:
- event、socket、expire:
2.18 events_list
打印所有事件
参数:无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "events_list",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Events": [
{
"id": 0,
"name": "E_CORE_SR_STATUS_CHANGED"
},
{
"id": 1,
"name": "E_CORE_THRESHOLD"
},
{
"id": 2,
"name": "E_CORE_SHM_THRESHOLD"
},
{
"id": 3,
"name": "E_CORE_PKG_THRESHOLD"
},
{
"id": 4,
"name": "E_CORE_PROC_AUTO_SCALE"
},
{
"id": 5,
"name": "E_CORE_TCP_DISCONNECT"
},
{
"id": 6,
"name": "E_MYSQL_CONNECTION"
},
{
"id": 7,
"name": "E_DISPATCHER_STATUS"
}
]
}
}
2.19 subscribers_list
打印订阅信息
参数:
- 不带参数:打印所有的订阅事件
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "subscribers_list",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Events": [
{
"name": "E_RTPPROXY_STATUS",
"id": 1,
"subscribers": [
...
]
},
{
"name": "E_PIKE_BLOCKED",
"id": 2,
"subscribers": [
...
]
}
]
}
}
- event:打印指定event订阅
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "subscribers_list",
"params": {
"event": "E_RTPPROXY_STATUS"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Event": {
"name": "E_RTPPROXY_STATUS",
"id": 1,
"subscribers": [
{
"socket": "unix:/tmp/event.sock",
"expire": "never"
},
{
"socket": "udp:127.0.0.1:8888",
"expire": 1100
}
]
}
}
}
- event、socket:打印指定event、socket的订阅
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "subscribers_list",
"params": {
"event": "E_RTPPROXY_STATUS",
"socket": "unix:/tmp/event.sock"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Event": {
"name": "E_RTPPROXY_STATUS",
"id": 1,
"Subscriber": {
"socket": "unix:/tmp/event.sock",
"expire": "never"
}
}
}
}
2.20 raise_event ????
引发事件
参数:
- event:事件
- event、params:,
- params 可以是数组:"params" :[ "aaa", "bbbb"] (??? 看代码看的)
- params 也可以是单个值:"params" : {"key1":"aaa", "key2" : "bbbb"} (??? 看代码看的)
{
"jsonrpc": "2.0",
"id": "1",
"method": "raise_event",
"params": {
"event": "xxxxxx",
"params": {
"key1": "aaa",
"key2": "bbbb"
}
}
}
2.21 list_tcp_conns
打印tcp连接
参数:无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "list_tcp_conns",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Connections": []
}
}
2.22 mem_pkg_dump
将pkg(私有内存)dump出来
参数:
- pid:指定pid
- pid、log_level:可选,指定dump出来的日志级别,默认是0
#输入
{
"jsonrpc": "2.0",
"id": "1",
"method": "mem_pkg_dump",
"params": {
"pid": 9957,
"log_level": "4"
}
}
#输出
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
输出到日志的内容是
Nov 3 19:14:46 vcs001 ./opensips[54057]: Memory status (pkg):
Nov 3 19:14:46 vcs001 ./opensips[54057]: qm_status (0x7f4d07093010):
Nov 3 19:14:46 vcs001 ./opensips[54057]: heap size= 1073741824
Nov 3 19:14:46 vcs001 ./opensips[54057]: used= 245048, used+overhead=494896, free=1073246928
Nov 3 19:14:46 vcs001 ./opensips[54057]: max used (+overhead)= 507048
Nov 3 19:14:46 vcs001 ./opensips[54057]: failed to walk through all fragments (0x7f4d47093010 0x7f4d070c8508 0x7f4d47092fe0)
Nov 3 19:14:46 vcs001 ./opensips[54057]: dumping summary of all alloc'ed. fragments:
Nov 3 19:14:46 vcs001 ./opensips[54057]: ----------------------------------------------------
Nov 3 19:14:46 vcs001 ./opensips[54057]: total_bytes | num_allocations x [file: func, line]
Nov 3 19:14:46 vcs001 ./opensips[54057]: ----------------------------------------------------
Nov 3 19:14:46 vcs001 ./opensips[54057]: 80 : 2 x [pvar.c: new_pv_context, line 5267]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 56 : 1 x [cachedb_redis_dbase.c: redis_connect, line 254]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 16 : 1 x [script_var.c: add_var, line 59]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 140112 : 1 x [pvar.c: init_pvar_support, line 134]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 8192 : 1 x [io_wait.c: init_io_wait, line 568]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 8 : 1 x [dispatcher.c: partition_init, line 645]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 1 x [sr_module_deps.c: _alloc_module_dep, line 60]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 104 : 2 x [context.c: context_alloc, line 120]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 96 : 7 x [map.c: map_get, line 155]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 224 : 4 x [route_struct.c: mk_exp, line 53]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32768 : 1 x [io_wait.c: init_io_wait, line 559]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 1 x [ipc.c: ipc_register_handler, line 154]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 1272 : 9 x [pvar.c: pv_parse_format, line 4621]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 24 : 1 x [script_var.c: set_var_value, line 112]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 1 x [script_var.c: add_var, line 52]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 56 : 1 x [sl_cb.c: register_slcb, line 61]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 72 : 1 x [cachedb_redis_dbase.c: redis_new_connection, line 394]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32 : 1 x [map.c: map_create, line 84]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 16 : 1 x [../../cachedb/../db/../ut.h: pkg_nt_str_dup, line 838]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 96 : 1 x [mi/mi_trace.c: try_load_trace_api, line 53]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 704 : 3 x [cachedb/cachedb.c: register_cachedb, line 173]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 10448 : 1 x [route.c: new_sroutes_holder, line 105]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 120 : 8 x [cachedb/cachedb_id.c: dupl_string, line 45]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 12416 : 97 x [cfg.lex: addstr, line 792]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 96 : 2 x [sr_module_deps.c: solve_module_dependencies, line 293]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 1 x [sr_module_deps.c: solve_module_dependencies, line 275]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 168 : 2 x [cachedb/cachedb_id.c: new_cachedb_id, line 359]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 12288 : 1 x [io_wait.c: init_io_wait, line 621]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 616 : 11 x [route_struct.c: mk_elem, line 69]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 16 : 1 x [sipmsgops.c: fixup_method, line 737]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 1 x [flags.c: get_flag_id_by_name, line 202]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 112 : 1 x [db/db.c: db_do_init, line 314]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32 : 2 x [cfg.y: yyparse, line 512]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 320 : 2 x [db/db.c: db_do_init, line 352]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 936 : 9 x [cfg.y: yyparse, line 1600]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 24 : 1 x [net/net_tcp.c: tcp_init, line 1756]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 128 : 2 x [cfg.y: mk_listen_id, line 2322]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32 : 2 x [socket_info.c: new_sock_info, line 127]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 4104 : 1 x [xlog.c: buf_init, line 124]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 88 : 1 x [my_con.c: db_sqlite_new_connection, line 123]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 120 : 3 x [script_cb.c: add_callback, line 60]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 1 x [transformations.c: parse_transformation, line 2568]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 2 x [cfg.y: yyparse, line 1330]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 312 : 6 x [sr_module_deps.c: solve_module_dependencies, line 335]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 3784 : 1 x [mi/mi.c: register_mi_cmd, line 146]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 896 : 28 x [mod_fix.c: alloc_gp, line 72]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 960 : 12 x [pvar.c: pv_add_extra, line 5192]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 392 : 7 x [sr_module_deps.c: add_module_dependency, line 135]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32 : 2 x [socket_info.c: fix_socket_list, line 687]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 72 : 1 x [db/db_id.c: new_db_id, line 272]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 2 x [socket_info.c: fix_socket_list, line 781]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32 : 1 x [cachedb_local.c: lcache_new_connection, line 283]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 7688 : 31 x [route_struct.c: mk_action, line 105]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 72 : 1 x [context.c: register_context_destroy, line 66]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 392 : 7 x [map.c: map_get, line 144]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 576 : 2 x [socket_info.c: new_sock_info, line 120]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 8 : 1 x [pvar.c: pv_init_extra_list, line 5128]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 96 : 2 x [cachedb/cachedb.c: cachedb_do_init, line 646]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 2048 : 1 x [mi/fmt.c: mi_fmt_init, line 43]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 16 : 1 x [io_wait.c: init_io_wait, line 576]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 48 : 3 x [db/db_id.c: dupl_string, line 47]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 1216 : 19 x [sr_module.c: register_module, line 151]
Nov 3 19:14:46 vcs001 ./opensips[54057]: 32 : 2 x [socket_info.c: fix_socket_list, line 636]
Nov 3 19:14:46 vcs001 ./opensips[54057]: ----------------------------------------------------
Nov 3 19:14:46 vcs001 ./opensips[54057]: dumping free list stats :
Nov 3 19:14:46 vcs001 ./opensips[54057]: hash= 4. fragments no.: 1, unused: 0#012#011#011 bucket size: 32 - 32 (first 32)
Nov 3 19:14:46 vcs001 ./opensips[54057]: hash= 210. fragments no.: 1, unused: 0#012#011#011 bucket size: 1680 - 1680 (first 1680)
Nov 3 19:14:46 vcs001 ./opensips[54057]: hash= 746. fragments no.: 1, unused: 0#012#011#011 bucket size: 5968 - 5968 (first 5968)
Nov 3 19:14:46 vcs001 ./opensips[54057]: hash= 2064. fragments no.: 1, unused: 0#012#011#011 bucket size: 536870912 - 1073741824 (first 1073239248)
Nov 3 19:14:46 vcs001 ./opensips[54057]: -----------------------------
2.23 mem_shm_dump
将shm(共享内存)dump出来
参数:
- log_level:可选,指定dump出来的日志级别,默认是0
#输入
{
"jsonrpc": "2.0",
"id": "1",
"method": "mem_shm_dump",
"params": {
"log_level": 4
}
}
#输出
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
日志输出内容
Nov 3 19:16:37 vcs001 ./opensips[54054]: Memory status (shm):
Nov 3 19:16:37 vcs001 ./opensips[54054]: qm_status (0x7f4cc7093000):
Nov 3 19:16:37 vcs001 ./opensips[54054]: heap size= 1073741824
Nov 3 19:16:37 vcs001 ./opensips[54054]: used= 4084064, used+overhead=4353688, free=1069388136
Nov 3 19:16:37 vcs001 ./opensips[54054]: max used (+overhead)= 4393504
Nov 3 19:16:37 vcs001 ./opensips[54054]: failed to walk through all fragments (0x7f4d07093000 0x7f4cc70c84f8 0x7f4d07092fd0)
Nov 3 19:16:37 vcs001 ./opensips[54054]: dumping summary of all alloc'ed. fragments:
Nov 3 19:16:37 vcs001 ./opensips[54054]: ----------------------------------------------------
Nov 3 19:16:37 vcs001 ./opensips[54054]: total_bytes | num_allocations x [file: func, line]
Nov 3 19:16:37 vcs001 ./opensips[54054]: ----------------------------------------------------
Nov 3 19:16:37 vcs001 ./opensips[54054]: 262144 : 32 x [net/net_tcp.c: tcp_init, line 1788]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 80 : 1 x [cfg_reload.c: init_script_reload, line 113]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [xlog.c: init_xlog, line 143]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 16 : 1 x [hash.c: lcache_htable_init, line 45]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 4080 : 9 x [statistics.c: add_stats_group, line 998]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 24 : 1 x [../tm/../../rw_locking.h: lock_init_rw, line 40]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [timer.c: init_timer, line 111]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 976 : 12 x [statistics.c: __register_stat, line 430]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 64 : 1 x [core_stats.c: init_pkg_stats, line 202]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 16 : 1 x [lock.c: lock_initialize, line 88]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [timer.c: init_timer, line 113]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8192 : 1 x [hash.c: lcache_htable_init, line 55]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 16 : 1 x [dispatch.c: ds_load_data, line 1047]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 56 : 1 x [httpd.c: httpd_register_httpdcb, line 240]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 72 : 1 x [cachedb_local.c: mod_init, line 485]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 624 : 7 x [timer.c: new_os_timer, line 186]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 56 : 1 x [map.c: map_create, line 84]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 904 : 1 x [timer.c: tm_init_timers, line 538]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [nat_traversal.c: mod_init, line 1848]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 10632 : 127 x [statistics.c: __register_stat, line 433]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 64 : 8 x [evi/event_interface.c: evi_publish_event, line 76]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 48 : 2 x [t_fwd.c: pre_print_uac_request, line 215]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [../tm/../../rw_locking.h: lock_init_rw, line 45]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 16 : 1 x [dispatch.c: init_ds_data, line 108]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [dispatch.c: init_ds_data, line 86]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8192 : 1 x [nat_traversal.c: HashTable_new, line 547]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [usr_avp.c: init_extra_avps, line 75]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 208 : 4 x [usr_avp.c: new_avp, line 118]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 256 : 32 x [net/net_tcp.c: tcp_init, line 1775]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [../../rw_locking.h: lock_init_rw, line 45]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 5744 : 3 x [status_report.c: sr_register_identifier, line 262]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 2080 : 1 x [dispatch.c: reindex_dests, line 482]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 1328 : 2 x [msg_translator.c: build_req_buf_from_sip_req, line 2308]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 541080 : 1 x [mem/shm_mem.c: shm_mem_init_mallocs, line 535]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 168 : 3 x [proxy.c: hostent_shm_cpy, line 66]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 280 : 1 x [dispatcher.c: mod_init, line 903]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 72 : 3 x [rw_locking.h: lock_init_rw, line 40]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 96 : 1 x [hash.c: _lcache_htable_insert, line 135]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [mem/shm_mem.c: shm_mem_init_mallocs, line 545]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 80 : 1 x [dispatch.c: ds_check_timer, line 2771]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 262144 : 32 x [net/net_tcp.c: tcp_init, line 1794]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 608 : 2 x [t_reply.c: relay_reply, line 1321]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 1832 : 69 x [statistics.c: build_stat_name, line 142]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 16 : 1 x [nat_traversal.c: HashTable_new, line 538]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 360 : 1 x [t_msgbuilder.c: build_uac_req, line 856]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 480 : 47 x [statistics.c: __register_stat, line 444]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 11616 : 2 x [sip_msg.c: sip_msg_cloner, line 535]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [usr_avp.c: init_extra_avps, line 84]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 360 : 9 x [statistics.c: register_stats_group, line 979]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 40 : 1 x [t_hooks.c: insert_tmcb, line 98]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 24 : 1 x [../../rw_locking.h: lock_init_rw, line 40]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 80 : 2 x [dispatch.c: add_dest2list, line 237]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 56 : 3 x [rw_locking.h: lock_init_rw, line 45]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 2621448 : 1 x [h_table.c: init_hash_table, line 372]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 192 : 3 x [../../resolve.h: shm_clone_proxy, line 203]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 20136 : 3 x [h_table.c: build_cell, line 244]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 160 : 5 x [status_report.c: sr_add_report, line 564]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [net/proto_tcp/proto_tcp.c: mod_init, line 256]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 520 : 1 x [statistics.c: __add_stat_module, line 202]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 440 : 1 x [core_stats.c: init_pkg_stats, line 201]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 40 : 1 x [dispatch.c: add_dest2list, line 211]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 4128 : 1 x [statistics.c: init_stats_collector, line 258]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 37504 : 1 x [pt.c: init_multi_proc_support, line 77]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [net/net_tcp.c: tcp_init, line 1763]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 424 : 43 x [mi/mi.c: register_mi_cmd, line 173]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [sl_funcs.c: sl_startup, line 80]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 48 : 2 x [sip_msg.c: sip_msg_cloner, line 1013]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [timer.c: init_timer, line 112]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 270544 : 1 x [mem/shm_mem.c: shm_mem_init_mallocs, line 521]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 104 : 2 x [status_report.c: _create_new_group, line 115]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 32 : 2 x [status_report.c: sr_set_status, line 453]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 2208 : 2 x [sip_msg.c: sip_msg_cloner, line 1021]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 16 : 1 x [t_hooks.c: new_tmcb_list, line 63]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 400 : 1 x [evi/event_interface.c: evi_publish_event, line 62]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 8 : 1 x [http_fnc.c: mi_json_init_async_lock, line 41]
Nov 3 19:16:37 vcs001 ./opensips[54054]: 320 : 13 x [statistics.c: __add_stat_module, line 215]
Nov 3 19:16:37 vcs001 ./opensips[54054]: ----------------------------------------------------
Nov 3 19:16:37 vcs001 ./opensips[54054]: dumping free list stats :
Nov 3 19:16:37 vcs001 ./opensips[54054]: hash= 1. fragments no.: 1, unused: 0#012#011#011 bucket size: 8 - 8 (first 8)
Nov 3 19:16:37 vcs001 ./opensips[54054]: hash= 2. fragments no.: 1, unused: 0#012#011#011 bucket size: 16 - 16 (first 16)
Nov 3 19:16:37 vcs001 ./opensips[54054]: hash= 2064. fragments no.: 1, unused: 0#012#011#011 bucket size: 536870912 - 1073741824 (first 1069388112)
Nov 3 19:16:37 vcs001 ./opensips[54054]: -----------------------------
2.24 mem_rpm_dump
将rpm(restart persistent memory)内存dump出来
参数:
- log_level:可选,指定dump出来的日志级别,默认是0
#输入
{
"jsonrpc": "2.0",
"id": "1",
"method": "mem_rpm_dump",
"params": {
"log_level": 4
}
}
#输出
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.25 reload_routes
重新加载路由
参数:无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "reload_routes",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.26 sr_get_status
获取指定group/identifier的状态
参数:
- group:过滤指定group,只有改group下仅有一个identifier时才可以这么用,如果有多个,必须指定identifier
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_get_status",
"params": {
"group": "core"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Details": "running",
"Readiness": true,
"Status": 1
}
}
- group、identifier:当group内有多个Identifiers时需要指定,identifier指定为all的特殊情况
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_get_status",
"params": {
"group": "dispatcher",
"identifier": "default"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Details": "data available",
"Readiness": true,
"Status": 1
}
}
2.27 sr_list_status
打印所有statusReport的状态
参数:
- 无:打印所有
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_status",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"Identifiers": [
{
"Name": "default;events",
"Readiness": true,
"Status": 1
},
{
"Details": "data available",
"Name": "default",
"Readiness": true,
"Status": 1
}
],
"Name": "dispatcher"
},
{
"Identifiers": [
{
"Details": "running",
"Name": "main",
"Readiness": true,
"Status": 1
}
],
"Name": "core"
}
]
}
- group:列出指定group的状态
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_status",
"params": {
"group": "dispatcher"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"Name": "default;events",
"Readiness": true,
"Status": 1
},
{
"Details": "data available",
"Name": "default",
"Readiness": true,
"Status": 1
}
]
}
2.28 sr_list_reports
打印reports内容
参数:
- 空:列出所有的
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_reports",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"Identifiers": [
{
"Name": "default;events",
"Reports": [
{
"Date": "Fri Nov 4 09:06:09 2022",
"Log": "DESTINATION <sip:192.168.1.100:5080>, set 1 switched to [inactive] due to negative probing reply\n",
"Timestamp": 1667523969
}
]
},
{
"Name": "default",
"Reports": [
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "starting DB data loading",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "DB data loading successfully completed",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "2 destinations loaded (0 discarded)",
"Timestamp": 1667523943
}
]
}
],
"Name": "dispatcher"
},
{
"Identifiers": [
{
"Name": "main",
"Reports": [
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "initializing",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "initialization completed, ready now",
"Timestamp": 1667523943
}
]
}
],
"Name": "core"
}
]
}
- group:过滤指定group
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_reports",
"params": {
"group": "dispatcher"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"Name": "default;events",
"Reports": [
{
"Date": "Fri Nov 4 09:06:09 2022",
"Log": "DESTINATION <sip:192.168.1.100:5080>, set 1 switched to [inactive] due to negative probing reply\n",
"Timestamp": 1667523969
}
]
},
{
"Name": "default",
"Reports": [
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "starting DB data loading",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "DB data loading successfully completed",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "2 destinations loaded (0 discarded)",
"Timestamp": 1667523943
}
]
}
]
}
- group、identifier:当group内有多个Identifiers时,用来过滤identifier
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_reports",
"params": {
"group": "dispatcher",
"identifier": "default"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "starting DB data loading",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "DB data loading successfully completed",
"Timestamp": 1667523943
},
{
"Date": "Fri Nov 4 09:05:43 2022",
"Log": "2 destinations loaded (0 discarded)",
"Timestamp": 1667523943
}
]
}
2.29 sr_list_identifiers
打印identifier
参数:
- 空:列出所有的statusReport的identifier数据
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_identifiers",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"Group": "dispatcher",
"Identifiers": [
"default;events",
"default"
]
},
{
"Group": "core",
"Identifiers": [
"main"
]
}
]
}
- group:列出指定group数据
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "sr_list_identifiers",
"params": {
"group": "dispatcher"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Group": "dispatcher",
"Identifiers": [
"default;events",
"default"
]
}
}
2.30 help
打印帮助信息
参数
- mi_cmd:指定命令
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "help",
"params": {
"mi_cmd": "sr_list_reports"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"Exported by": "core",
"Help": "list the reports produced by some 'status-report' identifiers / groups"
}
}
2.31 list_blacklists
打印黑名单
参数:无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "list_blacklists",
"params": {}
}
#响应
{
"jsonrpc": "2.0",
"result": {
"Lists": []
},
"id": "1"
}
2.32 t_uac_dlg
2.33 t_uac_cancel
2.34 t_hash
2.35 t_reply
2.36 httpd_list_root_path
打印http服务的rootPath
参数:无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "httpd_list_root_path",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": [
{
"http_root": "mi",
"module": "mi_http"
}
]
}
2.37 tcp_trace
查看、设置tcp trace模式
参数:
- 无
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "tcp_trace",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"TCP tracing": "off"
}
}
- trace_mode:取值on、off
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "tcp_trace",
"params": {
"trace_mode": "on"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
设置结果
2.38 ds_set_state
设置ds状态
说明
- state:
- 值为 0、I、i,表示0
- 值为1、a、A,表示1
- 值为2、p、P,表示2
- group:传值方式 [partitionName]:[id],例如:default:1,具体值通过ds_list可以查看
- address:distination里面的URI,例如:sip:168.1.100:5080,具体值通过ds_list可以查看
参数:
- state、group、address
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_set_state",
"params": {
"state": 1,
"group": "default:1",
"address": "sip:192.168.1.100:5080"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.39 ds_list
获取分发列表
说明:
- partition不传,显示所有的
- full不传,默认是0
参数:
- 无:获取所有的
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_list",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"PARTITIONS": [
{
"SETS": [
{
"Destinations": [
{
"URI": "sip:192.168.1.100:5080",
"first_hit_counter": 0,
"resolved_addresses": [
"192.168.1.100:5080"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing"
},
{
"URI": "sip:192.168.1.100:5090",
"first_hit_counter": 0,
"resolved_addresses": [
"192.168.1.100:5090"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing"
}
],
"id": 1
}
],
"name": "default"
}
]
}
}
- partition:指定过滤partition
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_list",
"params": {
"partition": "default"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"PARTITIONS": [
{
"SETS": [
{
"Destinations": [
{
"URI": "sip:192.168.1.100:5080",
"first_hit_counter": 0,
"resolved_addresses": [
"192.168.1.100:5080"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing"
},
{
"URI": "sip:192.168.1.100:5090",
"first_hit_counter": 0,
"resolved_addresses": [
"192.168.1.100:5090"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing"
}
],
"id": 1
}
],
"name": "default"
}
]
}
}
- full:1 打印全量信息,0非全量
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_list",
"params": {
"partition": "default"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"PARTITIONS": [
{
"SETS": [
{
"Destinations": [
{
"URI": "sip:192.168.1.100:5080",
"first_hit_counter": 0,
"resolved_addresses": [
"192.168.1.100:5080"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing"
},
{
"URI": "sip:192.168.1.100:5090",
"first_hit_counter": 0,
"resolved_addresses": [
"192.168.1.100:5090"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing"
}
],
"id": 1
}
],
"name": "default"
}
]
}
}
c.full:1 打印全量信息,0非全量
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_list",
"params": {
"full": "1"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"PARTITIONS": [
{
"SETS": [
{
"Destinations": [
{
"URI": "sip:192.168.1.100:5080",
"description": "vss-gb28181-1",
"first_hit_counter": 0,
"priority": 0,
"resolved_addresses": [
"192.168.1.100:5080"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing",
"weight": 1
},
{
"URI": "sip:192.168.1.100:5090",
"description": "vss-gb28181-2",
"first_hit_counter": 0,
"priority": 0,
"resolved_addresses": [
"192.168.1.100:5090"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing",
"weight": 1
}
],
"id": 1
}
],
"name": "default"
}
]
}
}
- full、partition:指定打印partition的指定全量信息
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_list",
"params": {
"partition": "default",
"full": "1"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"PARTITIONS": [
{
"SETS": [
{
"Destinations": [
{
"URI": "sip:192.168.1.100:5080",
"description": "vss-gb28181-1",
"first_hit_counter": 0,
"priority": 0,
"resolved_addresses": [
"192.168.1.100:5080"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing",
"weight": 1
},
{
"URI": "sip:192.168.1.100:5090",
"description": "vss-gb28181-2",
"first_hit_counter": 0,
"priority": 0,
"resolved_addresses": [
"192.168.1.100:5090"
],
"socket": "udp:192.168.1.100:5999",
"state": "Probing",
"weight": 1
}
],
"id": 1
}
],
"name": "default"
}
]
}
}
2.40 ds_reload
重新加载ds
参数:
- 无:reload所有的
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_reload",
"params": {}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
- partition:reload指定partition
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_reload",
"params": {
"partition": "default"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.41 ds_push_script_attrs ???
为ds信息设置脚本属性
说明:
- attrs:脚本????脚本不知道什么格式
- ip:ip地址
- port:端口
- set:集合里面的id,-1表是不区分
- partition:指定partition名称
参数:
- attrs、ip、port、set:不指定partition设置属性,设置的是默认partition
- attrs、ip、port、set,partition:指定partition设置属性
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "ds_push_script_attrs",
"params": {
"attrs": "{\"ping\":\"30000\",\"load\":\"50\"}",
"ip": "192.168.1.100",
"port": 5080,
"set": 1,
"partition": "default"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}
2.42 nh_enable_ping
获取、设置nat ping状态
参数:
- 无:获取nat ping状态
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "nh_enable_ping",
"params": {}
}
#响应
{
"error": {
"code": 400,
"message": "NATping disabled from script"
},
"id": "1",
"jsonrpc": "2.0"
}
- status:设置nat ping状态
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "nh_enable_ping",
"params": {
"status": 1
}
}
#响应
{
"error": {
"code": 400,
"message": "NATping disabled from script"
},
"id": "1",
"jsonrpc": "2.0"
}
2.43 cache_remove_chunk
从本地缓存中删除与glob匹配的项
参数:
- glob:匹配字符串,例如:keyprefix*
- glob、collection:删除指定集合的匹配项
#请求
{
"jsonrpc": "2.0",
"id": "1",
"method": "cache_remove_chunk",
"params": {
"glob": "keyprefix*",
"collection": "myCollection"
}
}
#响应
{
"id": "1",
"jsonrpc": "2.0",
"result": "OK"
}