Skip to content

Commit 8e43ceb

Browse files
committed
aggregate request counts over all servlets and rewrite item list
1 parent ff567ca commit 8e43ceb

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

agents/plugins/mk_jolokia.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@
252252
"tomcat": [
253253
("*:type=Manager,*", "activeSessions,maxActiveSessions", None, ["path", "context"], False),
254254
("*:j2eeType=Servlet,name=default,*", "stateName", None, ["WebModule"], False),
255-
# Check not yet working
256-
("*:j2eeType=Servlet,name=default,*", "requestCount", None, ["WebModule"], False),
257-
# too wide location for addressing the right info
258-
# ( "*:j2eeType=Servlet,*", "requestCount", None, [ "WebModule" ] , False),
255+
# Check not yet working. Counts only requests handled by the default servlet.
256+
# ("*:j2eeType=Servlet,name=default,*", "requestCount", None, ["WebModule"], False),
257+
# Too wide location for addressing the right info. Compensation implemented in fetch_metric.
258+
( "*:j2eeType=Servlet,*", "requestCount", None, [ "WebModule" ] , False),
259259
],
260260
"jboss": [
261261
("*:type=Manager,*", "activeSessions,maxActiveSessions", None, ["path", "context"], False),
@@ -580,6 +580,17 @@ def fetch_metric(inst, path, title, itemspec, inst_add=None):
580580
values = fetch_var(inst, "read", path, use_target=True)
581581
item_list = make_item_list((), values, itemspec)
582582

583+
# aggregate request counts over all servlets per web application
584+
# (identified by the web applications context path) and replace item list
585+
if path == "*:j2eeType=Servlet,*/requestCount":
586+
item_list_map = {} # type: dict[str, int]
587+
for subinstance, partial_request_count in item_list:
588+
context_path = subinstance[0]
589+
item_list_map[context_path] = item_list_map.get(context_path, 0) + partial_request_count
590+
item_list = []
591+
for context_path, total_request_count in item_list_map.items():
592+
item_list.append(((context_path, 'requestCount'), total_request_count))
593+
583594
for subinstance, value in item_list:
584595
if not subinstance and not title:
585596
sys.stderr.write("INTERNAL ERROR: %s\n" % value)

0 commit comments

Comments
 (0)