From 2e6cdd78d44b499b78b5d27ce9e5cd5044e0231d Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Fri, 9 Jul 2010 14:55:45 +0200 Subject: [PATCH] DSM: new monitor_select_filters, from P-App-Param when searching call records from monitoring for new calls, AVP names set in monitor_select_filters may be used to filter call records, additionally to caller/callee filters --- apps/dsm/DSM.cpp | 34 ++++++++++++++++++++++++++++++++-- apps/dsm/DSM.h | 1 + apps/dsm/etc/dsm.conf | 15 +++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/apps/dsm/DSM.cpp b/apps/dsm/DSM.cpp index 80c8576b..c37bc670 100644 --- a/apps/dsm/DSM.cpp +++ b/apps/dsm/DSM.cpp @@ -72,6 +72,7 @@ bool DSMFactory::MonitoringFullTransitions; MonSelectType DSMFactory::MonSelectCaller; MonSelectType DSMFactory::MonSelectCallee; +vector DSMFactory::MonSelectFilters; string DSMFactory::MonSelectFallback; @@ -211,6 +212,20 @@ int DSMFactory::onLoad() cfg_usecallee.c_str()); } + MonSelectFilters = explode(cfg.getParameter("monitor_select_filters"), ","); + string filters; + for (vector::iterator it = + MonSelectFilters.begin(); it != MonSelectFilters.end(); it++) { + if (it != MonSelectFilters.begin()) + filters += ", "; + filters+=*it; + } + if (MonSelectFilters.size()) { + DBG("using additional monitor app select filters: %s\n", + filters.c_str()); + } else { + DBG("not using additional monitor app select filters\n"); + } MonSelectFallback = cfg.getParameter("monitor_select_fallback"); #endif @@ -515,7 +530,8 @@ void AmArg2DSMStrMap(const AmArg& arg, } } -void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag, map& vars) { +void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag, + map& vars) { #define FALLBACK_OR_EXCEPTION(code, reason) \ if (MonSelectFallback.empty()) { \ throw AmSession::Exception(code, reason); \ @@ -579,8 +595,22 @@ void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag } DBG(" && looking for callee=='%s'\n", req.user.c_str()); - di_args.push(callee_filter); + di_args.push(callee_filter); } + // apply additional filters + if (MonSelectFilters.size()) { + string app_params = getHeader(req.hdrs, PARAM_HDR); + for (vector::iterator it = + MonSelectFilters.begin(); it != MonSelectFilters.end(); it++) { + AmArg filter; + filter.push(*it); // avp name + string app_param_val = get_header_keyvalue(app_params, *it); + filter.push(app_param_val); + di_args.push(filter); + DBG(" && looking for %s=='%s'\n", it->c_str(), app_param_val.c_str()); + } + } + MONITORING_GLOBAL_INTERFACE->invoke("listByFilter",di_args,ret); if ((ret.getType()!=AmArg::Array)|| diff --git a/apps/dsm/DSM.h b/apps/dsm/DSM.h index 8d0e0172..59a61841 100644 --- a/apps/dsm/DSM.h +++ b/apps/dsm/DSM.h @@ -83,6 +83,7 @@ class DSMFactory static MonSelectType MonSelectCaller; static MonSelectType MonSelectCallee; static string MonSelectFallback; + static vector MonSelectFilters; #endif // USE_MONITORING diff --git a/apps/dsm/etc/dsm.conf b/apps/dsm/etc/dsm.conf index 3f2a2fc7..a295b8e8 100644 --- a/apps/dsm/etc/dsm.conf +++ b/apps/dsm/etc/dsm.conf @@ -103,6 +103,21 @@ load_prompts=/usr/local/etc/sems/dsm_in_prompts.conf,/usr/local/etc/sems/dsm_out # #monitor_select_use_callee=no +# monitor_select_filters= +# +# for mon_select, records are also filtered by these variables, +# the values taked of P-App-Params. +# +# e.g. if +# P-App-Param: product_id=2;appdomain=iptel.org +# and +# monitor_select_filters=product_id,appdomain +# the record in monitoring must have also those avps set: +# appdomain=iptel.org +# product_id=2 +# +# monitor_select_filters=product_id,appdomain + # monitor_select_fallback=app # # fallback application for $(mon_select) application selection