diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index 15ddbec..a9bfaa2 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -229,5 +229,27 @@ route[DISPATCHER_CHECK_MEDIA_SERVER] } } +route[DISPATCHER_SUMMARY] +{ + $var(ds_groups_json) = ""; + if (sql_xquery("cb", "select * from dispatcher order by setid, id", "ra") == 1) + { + $var(Sep1) = ""; + while($xavp(ra) != $null) { + $var(ds_group) = $xavp(ra=>setid); + $var(Sep2)=""; + $var(ds_group_json)=""; + while($xavp(ra) != $null && $var(ds_group) == $xavp(ra=>setid) ) + { + $var(record) = $_s("$xavp(ra=>id)" : {"destination" : "$xavp(ra=>destination)", "flags" : "$xavp(ra=>flags)", "priority" : $xavp(ra=>priority), "attrs" : "$xavp(ra=>attrs)" , "description" : "$xavp(ra=>description)"}); + $var(ds_group_json) = $var(ds_group_json) + $var(Sep2) + $var(record); + $var(Sep2) = ","; + pv_unset("$xavp(ra)"); + } + $var(ds_groups_json) = $var(ds_groups_json) + $var(Sep1) + $_s("$var(ds_group)" : { $var(ds_group_json) }); + $var(Sep1)=", "; + } + } +} # vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab diff --git a/kamailio/nodes-role.cfg b/kamailio/nodes-role.cfg index 1f708d3..04c88a2 100644 --- a/kamailio/nodes-role.cfg +++ b/kamailio/nodes-role.cfg @@ -28,7 +28,32 @@ modparam("mqueue","mqueue", "name=node_heartbeat") ####### NODES Logic ######## route[NODES_ADVERTISE_ROUTE] { - $var(Payload) = '{"Event-Category" : "nodes", "Event-Name" : "advertise", "Expires" : 5000, "Used-Memory" : $(stat(real_used_size){s.int}), "Registrations" : $(stat(registered_users){s.int}), "WhApps" : {"kamailio" : {"Startup" : $Tb }} }'; + +#!ifdef REGISTRAR_ROLE + $var(Registrar) = $_s("Registrar" : {"Registrations" : $(stat(registered_users){s.int})}); +#!else + $var(Registrar) = ""; +#!endif + +#!ifdef DISPATCHER_ROLE + route(DISPATCHER_SUMMARY); + $var(Dispatcher) = $_s("Dispatcher" : {"Groups" : { $var(ds_groups_json) }}); +#!else + $var(Dispatcher) = ""; +#!endif + +#!ifdef PRESENCE_ROLE + route(COUNT_ALL_SUBSCRIBERS); + $var(Subscriptions) = $_s("Subscriptions" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); + route(COUNT_ALL_PRESENTITIES); + $var(Presentities) = $_s("Presentities" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); + $var(Presence) = $_s("Presence" : {$var(Subscriptions), $var(Presentities)}); +#!else + $var(Presence) = ""; +#!endif + + $var(Roles) = $_s("Roles" : {$var(Dispatcher), $var(Presence) , $var(Registrar)}); + $var(Payload) = '{"Event-Category" : "nodes", "Event-Name" : "advertise", "Expires" : 5000, "Used-Memory" : $(stat(real_used_size){s.int}), "Startup" : $Tb, "XWhApps" : {"kamailio" : {"Startup" : $Tb }}, $var(Roles)}'; kazoo_publish("nodes", "", $var(Payload)); } diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 1b70f0c..c928021 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -193,6 +193,34 @@ route[COUNT_PRESENTITIES] xavp_params_explode($var(p), "watchers"); } +route[COUNT_ALL_PRESENTITIES] +{ + $var(Query) = $_s(select event, (select count(*) from presentity b where b.event = a.event) count from event_list a); + $var(p) = "uri=none"; + if (sql_xquery("cb", "$var(Query)", "subs") == 1) + { + while($xavp(subs) != $null) { + $var(p) = $var(p) + ";" + $xavp(subs=>event) + "=" + $xavp(subs=>count); + pv_unset("$xavp(subs)"); + } + } + xavp_params_explode($var(p), "watchers"); +} + +route[COUNT_ALL_SUBSCRIBERS] +{ + $var(Query) = $_s(select event, (select count(*) from active_watchers b where b.event = a.event) count from event_list a); + $var(p) = $_s(uri=$var(presentity)); + if (sql_xquery("cb", "$var(Query)", "subs") == 1) + { + while($xavp(subs) != $null) { + $var(p) = $var(p) + ";" + $xavp(subs=>event) + "=" + $xavp(subs=>count); + pv_unset("$xavp(subs)"); + } + } + xavp_params_explode($var(p), "watchers"); +} + route[COUNT_SUBSCRIBERS] { $var(Query) = $_s(select event, (select count(*) from active_watchers b where presentity_uri = "$var(presentity)" and b.event = a.event) count from event_list a);