|
|
@ -8,8 +8,8 @@ |
|
|
#!define NODES_FUDGE_FACTOR 3 |
|
|
#!define NODES_FUDGE_FACTOR 3 |
|
|
#!endif |
|
|
#!endif |
|
|
|
|
|
|
|
|
modparam("htable", "htable", "nodes=>size=8;initval=0;autoexpire=180"); |
|
|
|
|
|
modparam("htable", "htable", "media=>size=8;initval=0;autoexpire=180"); |
|
|
|
|
|
|
|
|
modparam("htable", "htable", "nodes=>size=8;initval=0;autoexpire=180;"); |
|
|
|
|
|
modparam("htable", "htable", "media=>size=8;initval=0;autoexpire=180;"); |
|
|
|
|
|
|
|
|
####### RTIMER module ########## |
|
|
####### RTIMER module ########## |
|
|
#!ifndef RTIMER_LOADED |
|
|
#!ifndef RTIMER_LOADED |
|
|
@ -30,11 +30,11 @@ modparam("mqueue","mqueue", "name=node_heartbeat") |
|
|
route[NODES_ADVERTISE_ROUTE] |
|
|
route[NODES_ADVERTISE_ROUTE] |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
$var(separator) = ""; |
|
|
|
|
|
|
|
|
route(LISTENER_STATUS); |
|
|
|
|
|
|
|
|
#!ifdef DISPATCHER_ROLE |
|
|
#!ifdef DISPATCHER_ROLE |
|
|
route(DISPATCHER_STATUS); |
|
|
route(DISPATCHER_STATUS); |
|
|
$var(Dispatcher) = $_s("Dispatcher" : {"Groups" : { $var(ds_groups_json) }}); |
|
|
|
|
|
$var(separator) = " , "; |
|
|
|
|
|
|
|
|
$var(Dispatcher) = $_s(, "Dispatcher" : {"Groups" : { $var(ds_groups_json) }}); |
|
|
#!else |
|
|
#!else |
|
|
$var(Dispatcher) = ""; |
|
|
$var(Dispatcher) = ""; |
|
|
#!endif |
|
|
#!endif |
|
|
@ -47,20 +47,18 @@ $var(separator) = ""; |
|
|
route(COUNT_ALL_PRESENTITIES); |
|
|
route(COUNT_ALL_PRESENTITIES); |
|
|
$var(Presentities) = $_s("Presentities" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); |
|
|
$var(Presentities) = $_s("Presentities" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); |
|
|
|
|
|
|
|
|
$var(Presence) = $_s($var(separator) "Presence" : {$var(Subscribers), $var(Subscriptions), $var(Presentities)}); |
|
|
|
|
|
$var(separator) = " , "; |
|
|
|
|
|
|
|
|
$var(Presence) = $_s(, "Presence" : {$var(Subscribers), $var(Subscriptions), $var(Presentities)}); |
|
|
#!else |
|
|
#!else |
|
|
$var(Presence) = ""; |
|
|
$var(Presence) = ""; |
|
|
#!endif |
|
|
#!endif |
|
|
|
|
|
|
|
|
#!ifdef REGISTRAR_ROLE |
|
|
#!ifdef REGISTRAR_ROLE |
|
|
$var(Registrar) = $_s($var(separator) "Registrar" : {"Registrations" : $(stat(registered_users){s.int})}); |
|
|
|
|
|
$var(separator) = " , "; |
|
|
|
|
|
|
|
|
$var(Registrar) = $_s(, "Registrar" : {"Registrations" : $(stat(registered_users){s.int})}); |
|
|
#!else |
|
|
#!else |
|
|
$var(Registrar) = ""; |
|
|
$var(Registrar) = ""; |
|
|
#!endif |
|
|
#!endif |
|
|
|
|
|
|
|
|
$var(Roles) = $_s("Roles" : {$var(Dispatcher) $var(Presence) $var(Registrar)}); |
|
|
|
|
|
|
|
|
$var(Roles) = $_s("Roles" : {"Proxy" : $var(listeners) $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, "WhApps" : {"kamailio" : {"Startup" : $Tb }}, $var(Roles)}'; |
|
|
$var(Payload) = '{"Event-Category" : "nodes", "Event-Name" : "advertise", "Expires" : 5000, "Used-Memory" : $(stat(real_used_size){s.int}), "Startup" : $Tb, "WhApps" : {"kamailio" : {"Startup" : $Tb }}, $var(Roles)}'; |
|
|
kazoo_publish("nodes", "", $var(Payload)); |
|
|
kazoo_publish("nodes", "", $var(Payload)); |
|
|
} |
|
|
} |
|
|
@ -124,7 +122,7 @@ route[CHECK_MEDIA_SERVERS] |
|
|
if($(var(Payload){kz.json,Media-Servers}) == "") { |
|
|
if($(var(Payload){kz.json,Media-Servers}) == "") { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$var(Media) = $(var(Payload){kz.json,Media-Servers}); |
|
|
$var(Media) = $(var(Payload){kz.json,Media-Servers}); |
|
|
$var(Zone) = $(var(Payload){kz.json,AMQP-Broker-Zone}); |
|
|
$var(Zone) = $(var(Payload){kz.json,AMQP-Broker-Zone}); |
|
|
|
|
|
|
|
|
@ -135,20 +133,25 @@ route[CHECK_MEDIA_SERVERS] |
|
|
$var(Count) = $cnt($avp(MediaKeys)); |
|
|
$var(Count) = $cnt($avp(MediaKeys)); |
|
|
$var(Idx) = 0; |
|
|
$var(Idx) = 0; |
|
|
while( $var(Idx) < $var(Count) ) { |
|
|
while( $var(Idx) < $var(Count) ) { |
|
|
$var(MediaKey) = $(avp(MediaKeys)[$var(Idx)]{s.replace,$var(Dot),$var(Perc)}); |
|
|
|
|
|
|
|
|
$var(MediaName) = $(avp(MediaKeys)[$var(Idx)]); |
|
|
|
|
|
$var(MediaKey) = $(var(MediaName){s.replace,$var(Dot),$var(Perc)}); |
|
|
avp_delete("$avp(ProfileKeys)/g"); |
|
|
avp_delete("$avp(ProfileKeys)/g"); |
|
|
if(kazoo_json_keys($var(Payload), "Media-Servers.$var(MediaKey).Interfaces", "$avp(ProfileKeys)") == 1) { |
|
|
if(kazoo_json_keys($var(Payload), "Media-Servers.$var(MediaKey).Interfaces", "$avp(ProfileKeys)") == 1) { |
|
|
$var(ProfileCount) = $cnt($avp(ProfileKeys)); |
|
|
$var(ProfileCount) = $cnt($avp(ProfileKeys)); |
|
|
$var(ProfileIdx) = 0; |
|
|
$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) ) { |
|
|
while( $var(ProfileIdx) < $var(ProfileCount) ) { |
|
|
$var(MediaRawUrl) = $(var(Payload){kz.json,Media-Servers.$var(MediaKey).Interfaces.$(avp(ProfileKeys)[$var(ProfileIdx)]).URL}); |
|
|
|
|
|
|
|
|
$var(MediaProfile) = $(avp(ProfileKeys)[$var(ProfileIdx)]); |
|
|
|
|
|
$var(MediaRawUrl) = $(var(Payload){kz.json,Media-Servers.$var(MediaKey).Interfaces.$var(MediaProfile).URL}); |
|
|
$var(MediaUrl) = $(var(MediaRawUrl){re.subst,/^sip:(.*)@(.*)/sip:\2/}); |
|
|
$var(MediaUrl) = $(var(MediaRawUrl){re.subst,/^sip:(.*)@(.*)/sip:\2/}); |
|
|
if($shtinc(media=>$var(MediaUrl)::count) == 1) { |
|
|
if($shtinc(media=>$var(MediaUrl)::count) == 1) { |
|
|
$sht(media=>$var(MediaUrl)::zone) = $var(Zone); |
|
|
$sht(media=>$var(MediaUrl)::zone) = $var(Zone); |
|
|
$shtex(media=>$var(MediaUrl)::zone) = 0; |
|
|
$shtex(media=>$var(MediaUrl)::zone) = 0; |
|
|
route(MEDIA_SERVER_UP); |
|
|
route(MEDIA_SERVER_UP); |
|
|
}; |
|
|
}; |
|
|
$shtex(media=>$var(MediaUrl)::count) = ($(var(Payload){kz.json,Expires}{s.int}) / 1000) + NODES_FUDGE_FACTOR; |
|
|
|
|
|
|
|
|
$var(MediaExpire) = ($(var(Payload){kz.json,Expires}{s.int}) / 1000) + NODES_FUDGE_FACTOR; |
|
|
|
|
|
$shtex(media=>$var(MediaUrl)::count) = $var(MediaExpire); |
|
|
|
|
|
## xlog("L_INFO", "nodes|media|$var(Node) expire is $var(MediaExpire)\n"); |
|
|
|
|
|
|
|
|
$var(ProfileIdx) = $var(ProfileIdx) + 1; |
|
|
$var(ProfileIdx) = $var(ProfileIdx) + 1; |
|
|
} |
|
|
} |
|
|
@ -158,7 +161,6 @@ route[CHECK_MEDIA_SERVERS] |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event_route[htable:expired:media] |
|
|
event_route[htable:expired:media] |
|
|
{ |
|
|
{ |
|
|
$var(MediaUrl) = $(shtrecord(key){re.subst,/(.*)::(.*)/\1/}); |
|
|
$var(MediaUrl) = $(shtrecord(key){re.subst,/(.*)::(.*)/\1/}); |
|
|
@ -198,6 +200,31 @@ route[NODES_BINDINGS] |
|
|
} |
|
|
} |
|
|
#!endif |
|
|
#!endif |
|
|
|
|
|
|
|
|
|
|
|
route[LISTENER_STATUS] |
|
|
|
|
|
{ |
|
|
|
|
|
jsonrpc_exec('{"jsonrpc": "2.0", "method": "corex.list_sockets", "id": 1}'); |
|
|
|
|
|
$var(count) = $(jsonrpl(body){kz.json.count,result}); |
|
|
|
|
|
$var(loop) = 0; |
|
|
|
|
|
$var(sep) = ""; |
|
|
|
|
|
$var(listeners) = ""; |
|
|
|
|
|
while( $var(loop) < $var(count) ) { |
|
|
|
|
|
$var(listener) = $(jsonrpl(body){kz.json,result[$var(loop)]}); |
|
|
|
|
|
$var(proto) = $(var(listener){kz.json,PROTO}); |
|
|
|
|
|
$var(address) = $(var(listener){kz.json,ADDRLIST.ADDR}); |
|
|
|
|
|
$var(port) = $(var(listener){kz.json,PORT}); |
|
|
|
|
|
$var(uri) = $_s($var(proto):$var(address):$var(port)); |
|
|
|
|
|
if($(var(listener){kz.json,ADVERTISE}) != "-") { |
|
|
|
|
|
$var(advertise) = $_s( , "advertise" : "$(var(listener){kz.json,ADVERTISE})"); |
|
|
|
|
|
} else { |
|
|
|
|
|
$var(advertise) = ""; |
|
|
|
|
|
} |
|
|
|
|
|
$var(x) = $_s("$var(uri)" : {"proto" : "$var(proto)", "address" : "$var(address)", "port" : $var(port) $var(advertise) }); |
|
|
|
|
|
$var(listeners) = $_s($var(listeners)$var(sep)$var(x)); |
|
|
|
|
|
$var(loop) = $var(loop) + 1; |
|
|
|
|
|
$var(sep) = " , "; |
|
|
|
|
|
} |
|
|
|
|
|
$var(listeners) = $_s({"Listeners" : { $var(listeners) }}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab |
|
|
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab |