I am trying to monitor the memory usage of kamailio. The PKG memory I have arranged, though the shared memory is something else. According to documentation you can get the shared memory like this:
kamcmd mod.stats all shm
In my case, I get the following:
Module: core
{
msg_lump_cloner(984): 1560
dns_cache_mk_bad_entry(867): 192
dns_cache_mk_rd_entry(1216): 232
build_req_buf_from_sip_req(2155): 2752
sip_msg_shm_clone(495): 822664
tcpconn_new(957): 16416728
counters_prefork_init(207): 30720
cfg_clone_str(130): 208
cfg_shmize(217): 976
init_pt(105): 4200
cfg_parse_str(906): 80
init_pt(106): 16
init_pt(111): 40
create_avp(175): 10368
register_timer(1012): 720
cfg_register_ctx(47): 128
init_tcp(4643): 8192
init_tcp(4637): 32768
init_tcp(4629): 8
init_tcp(4622): 8
init_tcp(4615): 8
init_tcp(4609): 8
init_tcp(4597): 8
init_avps(90): 8
init_avps(89): 8
init_dst_blacklist(437): 16384
init_dst_blacklist(430): 8
timer_alloc(515): 96
init_dns_cache(366): 8
init_dns_cache(358): 16384
init_dns_cache(351): 16
init_dns_cache(345): 8
init_timer(284): 8
init_timer(283): 16384
init_timer(282): 8
init_timer(281): 8
init_timer(270): 8
init_timer(238): 8
init_timer(221): 278544
init_timer(220): 8
init_timer(207): 8
cfg_child_cb_new(830): 64
sr_cfg_init(361): 8
sr_cfg_init(354): 8
sr_cfg_init(347): 8
sr_cfg_init(335): 8
sr_cfg_init(323): 24
shm_core_lock_init(153): 8
Total: 17660616
}
... [ list of modules here, snipped because not relevant I think] ...
So I guess the one I need is Total: 17660616
.
However, what does this mean? Is it the total allocated memory? Available memory?
The commands you used is for seeing the used of shared memory per module.
If you want the statistics for total used and free shared memory, then use the command:
kamctl stats shmem
or:
kamcmd stats.get_statistics shmem:
The output will be like:
shmem:fragments = 179
shmem:free_size = 127471848
shmem:max_used_size = 7269016
shmem:real_used_size = 6745880
shmem:total_size = 134217728
shmem:used_size = 5106728
The free_size value is the one you have to monitor for available shared memory.