**opensipsctl fifo get_statistics all **命令可以获取所有统计数据,在所有统计数据中,我们只关心内存,事务和回话的数量。然后将数据使用curl工具写入到influxdb中。

opensipsctl fifo reset_statistics all 重置统计数据

常用指令

命令描述
opensipsctl fifo which显示所有可用命令
opensipsctl fifo ps显示所有进程
opensipsctl fifo get_statistics all获取所有统计信息
opensipsctl fifo get_statistics core:获取内核统计信息
opensipsctl fifo get_statistics net:获取网路统计信息
opensipsctl fifo get_statistics pkmem:获取私有内存相关信息
opensipsctl fifo get_statistics tm:获取事务模块统计信息
opensipsctl fifo get_statistics sl:获取sl模块统计信息
opensipsctl fifo get statistics shmem:获取共享内存相关信息
opensipsctl fifo get statistics usrloc:获取
opensipsctl fifo get statistics registrar:获取注册统计信息
opensipsctl fifo get statistics uri:获取uri统计信息
opensipsctl fifo get statistics load:获取负载信息
opensipsctl fifo reset_statistics all重置所有统计信息
shmem:total_size:: 6467616768
shmem:used_size:: 4578374040
shmem:real_used_size:: 4728909408
shmem:max_used_size:: 4728909408
shmem:free_size:: 1738707360
shmem:fragments:: 1

# 事务
tm:UAS_transactions:: 296337
tm:UAC_transactions:: 30
tm:2xx_transactions:: 174737
tm:3xx_transactions:: 0
tm:4xx_transactions:: 110571
tm:5xx_transactions:: 2170
tm:6xx_transactions:: 0
tm:inuse_transactions:: 289651


dialog:active_dialogs:: 156
dialog:early_dialogs:: 680
dialog:processed_dialogs:: 104061
dialog:expired_dialogs:: 964
dialog:failed_dialogs:: 78457
dialog:create_sent:: 0
dialog:update_sent:: 0
dialog:delete_sent:: 0
dialog:create_recv:: 0
dialog:update_recv:: 0
dialog:delete_recv:: 0
CONF_DB_URL="ip:port" # influxdb地址
CONF_DB_NAME="dbname" # influxdb数据库名
CONF_OPENSIPS_ROLE="a" # 角色,随便写个字符串

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"

LOCAL_IP=`ip route get 8.8.8.8 | head -n +1 | tr -s " " | cut -d " " -f 7`

MSG=`opensipsctl fifo get_statistics all | grep -E "tm:|shmem:|dialog" | awk -F ':: ' 'BEGIN{OFS="=";ORS=","} {print $1,$2}' | sed 's/[-:.]/_/g'`
MSG=${MSG:0:${#MSG}-1}
echo $MSG
influxdb="http://$CONF_DB_URL/write?db=$CONF_DB_NAME"

curl -i -XPOST $influxdb  --data-binary "opensips,type=$CONF_OPENSIPS_ROLE,ip=$LOCAL_IP $MSG"

shmem:total_size:: 33554432shmem:used_size:: 2910624shmem:real_used_size:: 3722856shmem:max_used_size:: 21963544shmem:free_size:: 29831576shmem:fragments:: 30761core:rcv_requests:: 1625972core:rcv_replies:: 580098core:fwd_requests:: 26146core:fwd_replies:: 0core:drop_requests:: 27core:drop_replies:: 0core:err_requests:: 0core:err_replies:: 0core:bad_URIs_rcvd:: 0core:unsupported_methods:: 0core:bad_msg_hdr:: 0core:timestamp:: 179429net:waiting_udp:: 0net:waiting_tcp:: 0sl:1xx_replies:: 0sl:2xx_replies:: 930643sl:3xx_replies:: 0sl:4xx_replies:: 265459sl:5xx_replies:: 168472sl:6xx_replies:: 0sl:sent_replies:: 1364574sl:sent_err_replies:: 0sl:received_ACKs:: 27tm:received_replies:: 570374tm:relayed_replies:: 402332tm:local_replies:: 155868tm:UAS_transactions:: 181106tm:UAC_transactions:: 71770tm:2xx_transactions:: 117167tm:3xx_transactions:: 0tm:4xx_transactions:: 138052tm:5xx_transactions:: 29tm:6xx_transactions:: 0tm:inuse_transactions:: 2uri:positive checks:: 195024uri:negative_checks:: 0usrloc:registered_users:: 0usrloc:location-users:: 0usrloc:location-contacts:: 0usrloc:location-expires:: 0registrar:max_expires:: 180registrar:max_contacts:: 1registrar:default_expire:: 150registrar:accepted_regs:: 110781registrar:rejected_regs:: 84236dialog:active_dialogs:: 0dialog:early_dialogs:: 0dialog:processed_dialogs:: 150397dialog:expired_dialogs:: 0dialog:failed_dialogs:: 137297dialog:create_sent:: 0dialog:update_sent:: 0dialog:delete_sent:: 0dialog:create_recv:: 0dialog:update_recv:: 0dialog:delete_recv:: 0