Browse Source

Merge remote-tracking branch 'origin/master' into 4.1

4.1
karl anderson 9 years ago
parent
commit
c344bd4cc4
3 changed files with 78 additions and 4 deletions
  1. +24
    -2
      kamailio/dispatcher-role.cfg
  2. +26
    -2
      kamailio/nodes-role.cfg
  3. +28
    -0
      kamailio/presence-role.cfg

+ 24
- 2
kamailio/dispatcher-role.cfg View File

@ -81,12 +81,12 @@ route[DISPATCHER_FIND_ROUTES]
# if we selected from group 1, try again in group 2
if ($var(ds_group) == 1) {
if (!ds_select_dst("2", "0")) {
xlog("L_WARN", "$ci|end|no servers avaliable in group 1 or 2\n");
xlog("L_WARN", "$ci|end|no servers available in group 1 or 2\n");
sl_send_reply("480", "All servers busy");
exit;
}
} else {
xlog("L_INFO", "$ci|end|no servers avaliable in group $var(ds_group)\n");
xlog("L_INFO", "$ci|end|no servers available in group $var(ds_group)\n");
sl_send_reply("480", "All servers busy");
exit;
}
@ -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

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

@ -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));
}
@ -107,7 +132,6 @@ route[CHECK_MEDIA_SERVERS]
if(kazoo_json_keys($var(Payload), "Media-Servers.$var(MediaKey).Interfaces", "$avp(ProfileKeys)") == 1) {
$var(ProfileCount) = $cnt($avp(ProfileKeys));
$var(ProfileIdx) = 0;
xlog("L_INFO", "nodes|media|$var(Node) profile count for $(avp(MediaKeys)[$var(Idx)]) is : $var(ProfileCount)\n");
while( $var(ProfileIdx) < $var(ProfileCount) ) {
$var(MediaRawUrl) = $(var(Payload){kz.json,Media-Servers.$var(MediaKey).Interfaces.$(avp(ProfileKeys)[$var(ProfileIdx)]).URL});
$var(MediaUrl) = $(var(MediaRawUrl){re.subst,/^sip:(.*)@(.*)/sip:\2/});


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

@ -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);


Loading…
Cancel
Save