Browse Source

KAZOO-5181 add roles & data to nodes publish

KAZOO-5650
lazedo 9 years ago
parent
commit
22ea8dea86
3 changed files with 76 additions and 1 deletions
  1. +22
    -0
      kamailio/dispatcher-role.cfg
  2. +26
    -1
      kamailio/nodes-role.cfg
  3. +28
    -0
      kamailio/presence-role.cfg

+ 22
- 0
kamailio/dispatcher-role.cfg View File

@ -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 # vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab

+ 26
- 1
kamailio/nodes-role.cfg View File

@ -28,7 +28,32 @@ modparam("mqueue","mqueue", "name=node_heartbeat")
####### NODES Logic ######## ####### NODES Logic ########
route[NODES_ADVERTISE_ROUTE] 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)); kazoo_publish("nodes", "", $var(Payload));
} }


+ 28
- 0
kamailio/presence-role.cfg View File

@ -193,6 +193,34 @@ route[COUNT_PRESENTITIES]
xavp_params_explode($var(p), "watchers"); 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] 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); $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);


Loading…
Cancel
Save