Browse Source

macros/runtime for max notify error and loglevel

update-rsyslog-config
lazedo 7 years ago
parent
commit
cb721316bf
1 changed files with 21 additions and 18 deletions
  1. +21
    -18
      kamailio/presence-notify.cfg

+ 21
- 18
kamailio/presence-notify.cfg View File

@ -1,4 +1,7 @@
#!trydef KZ_PRESENCE_REMOVE_WATCHER_ON_EXPIRED_REGISTRATION 0
#!trydef KZ_PRESENCE_MAX_NOTIFY_ERROR 3
#!trydef KZ_PRESENCE_NOTIFY_LOG_LEVEL 4
kazoo.presence_notify = 1 descr "enable/disable sending notify callback to omnipresence"
kazoo.presence_notify_timeout = 5000 descr "timeout in ms waiting for notify reply"
@ -10,13 +13,12 @@ kazoo.presence_notify_record_route = 1 descr "add record route header to notify
kazoo.presence_notify_log_init_body = 0 descr "logs the body before its sent"
kazoo.presence_notify_force_send_socket = 1 descr "forces the send socket to the contact"
kazoo.presence_remove_watcher_on_expired_registration = KZ_PRESENCE_REMOVE_WATCHER_ON_EXPIRED_REGISTRATION descr "removes watcher on expired registration"
kazoo.presence_max_notify_error = KZ_PRESENCE_MAX_NOTIFY_ERROR descr "number of consecutive fails allowed before removing the subscription"
kazoo.presence_notify_log_level = KZ_PRESENCE_NOTIFY_LOG_LEVEL descr "loglevel for informational log messages"
######## Generic Hash Table container in shared memory ########
modparam("htable", "htable", "notify=>size=16;autoexpire=3600;updateexpire=1;initval=0")
#!trydef PRESENCE_NOTIFY_INIT
#!trydef MAX_NOTIFY_ERROR 5
route[PRESENCE_LOCAL_REQ_NOTIFY]
{
if($rm != "NOTIFY") {
@ -60,33 +62,34 @@ event_route[presence:notify-reply]
$xavp(pres=>delete_subscription) = 0;
if($subs(reason) == "timeout") {
$xavp(pres=>delete_subscription) = 1;
xlog("L_INFO", "$ci|end|deleting subscription $subs(pres_uri) for $subs(watcher_username)@$subs(watcher_domain) due to timeout\n");
} else if($notify_reply($rs) == 200) {
if($notify_reply($rs) == 200) {
$sht(notify=>$ci) = $null;
$sht(notify=>$ci::count) = 0;
xlog("L_INFO", "$ci|end|notified $subs(watcher_username)@$subs(watcher_domain) on behalf of $subs(pres_uri)\n");
} else if($notify_reply($rs) == 481 && $subs(reason) == "timeout") {
xlog("L_INFO","$ci|end|sent subscription $hdr(Subscription-State)\n");
} else if($notify_reply($rs) == 481) {
xlog("$(sel(cfg_get.kazoo.presence_notify_log_level){s.int})", "$ci|end|notified $subs(watcher_username)@$subs(watcher_domain) on behalf of $subs(pres_uri)\n");
} else if($subs(reason) == "timeout") {
$xavp(pres=>delete_subscription) = 1;
xlog("L_INFO", "$ci|end|deleting subscription $subs(pres_uri) as $subs(watcher_username)@$subs(watcher_domain) replied with 481 (non existent)\n");
} else {
xlog("L_DEBUG", "$ci|end|deleting subscription $subs(pres_uri) for $subs(watcher_username)@$subs(watcher_domain) due to timeout\n");
} else if($notify_reply($rs) == 481 && $subs(reason) == "timeout") {
xlog("L_DEBUG","$ci|end|sent subscription $hdr(Subscription-State)\n");
} else if($notify_reply($rs) == 408) {
if($rP != "UDP") {
$xavp(pres=>delete_subscription) = 1;
xlog("L_ERROR", "$ci|error|removing $rP watcher $subs(watcher_username)@$subs(watcher_domain) for $subs(pres_uri) with reply $notify_reply($rs)\n");
xlog("L_ERROR", "$ci|warning|removing $rP watcher $subs(watcher_username)@$subs(watcher_domain) for $subs(pres_uri) with reply $notify_reply($rs)\n");
} else {
$var(shtinc) = $shtinc(notify=>$ci::count);
if($var(shtinc) > MAX_NOTIFY_ERROR) {
if($var(shtinc) > $sel(cfg_get.kazoo.presence_max_notify_error)) {
$xavp(pres=>delete_subscription) = 1;
xlog("L_ERROR", "$ci|error|removing $rP watcher $subs(watcher_username)@$subs(watcher_domain) for $subs(pres_uri) with reply $notify_reply($rs)\n");
xlog("L_WARNING", "$ci|error|removing $rP watcher $subs(watcher_username)@$subs(watcher_domain) for $subs(pres_uri) with reply $notify_reply($rs)\n");
} else {
$var(level) = 4 - $var(shtinc);
xlog("$var(level)", "$ci|error|received $notify_reply($rs) ($var(shtinc)/$def(MAX_NOTIFY_ERROR)) when notifying $subs(watcher_username)@$subs(watcher_domain) on behalf of $subs(pres_uri) with reply $notify_reply($rs)\n");
$var(level) = 6 - $var(shtinc);
xlog("$var(level)", "$ci|error|received $notify_reply($rs) ($var(shtinc)/$sel(cfg_get.kazoo.presence_max_notify_error)) when notifying $subs(watcher_username)@$subs(watcher_domain) on behalf of $subs(pres_uri) with reply $notify_reply($rs)\n");
}
}
} else {
$xavp(pres=>delete_subscription) = 1;
xlog("L_WARNING", "$ci|end|deleting subscription $subs(pres_uri) as $subs(watcher_username)@$subs(watcher_domain) replied with $notify_reply($rs)\n");
}
if($sel(cfg_get.kazoo.presence_notify_log_body) == 1)
xlog("L_INFO", "$ci|log|sent|body $(mb{s.escape.common}{s.replace,\','}{s.replace,$$,})\n");
if($sel(cfg_get.kazoo.presence_notify_log_resp_body) == 1)


Loading…
Cancel
Save