1 # -*- coding: utf-8 -*-
2 # Description: tomcat netdata python.d plugin
3 # Author: Pawel Krupa (paulfantom)
5 from base import UrlService
6 import xml.etree.ElementTree as ET # phone home...
8 # default module values (can be overridden per job in `config`)
13 # charts order (can be overridden if you want less charts, or different order)
14 ORDER = ['accesses', 'volume', 'threads', 'jvm']
18 'options': [None, "tomcat requests", "requests/s", "statistics", "tomcat.accesses", "area"],
23 'options': [None, "tomcat volume", "KB/s", "volume", "tomcat.volume", "area"],
25 ["volume", None, 'incremental']
28 'options': [None, "tomcat threads", "current threads", "statistics", "tomcat.threads", "line"],
30 ["current", None, "absolute"],
31 ["busy", None, "absolute"]
34 'options': [None, "JVM Free Memory", "MB", "statistics", "tomcat.jvm", "area"],
36 ["jvm", None, "absolute"]
41 class Service(UrlService):
42 def __init__(self, configuration=None, name=None):
43 UrlService.__init__(self, configuration=configuration, name=name)
44 if len(self.url) == 0:
45 self.url = "http://localhost:8080/manager/status?XML=true"
47 self.definitions = CHARTS
50 for i in self.url.split('/'):
53 self.port = i.split(':')[-1]
62 Format data received from http request
66 raw = self._get_raw_data()
67 data = ET.fromstring(raw)
68 memory = data.find('./jvm/memory')
69 threads = data.find("./connector[@name='\"http-bio-" + str(self.port) + "\"']/threadInfo")
70 requests = data.find("./connector[@name='\"http-bio-" + str(self.port) + "\"']/requestInfo")
72 return {'accesses': requests.attrib['requestCount'],
73 'volume': requests.attrib['bytesSent'],
74 'current': threads.attrib['currentThreadCount'],
75 'busy': threads.attrib['currentThreadsBusy'],
76 'jvm': memory.attrib['free']}
77 except (ValueError, AttributeError):