]> arthur.barton.de Git - netdata.git/blobdiff - python.d/tomcat.chart.py
Merge pull request #1568 from l2isbad/varnish_plugin
[netdata.git] / python.d / tomcat.chart.py
index a045d86a7d27c5067b6e953266c4e7fc9ef1a455..31f6ab2483b4f0660ad250fc1f47be394352f64f 100644 (file)
@@ -6,7 +6,7 @@
 
 from base import UrlService
 import xml.etree.ElementTree as ET  # phone home...
-import xml.parsers.expat.errors as errors
+#from xml.parsers.expat import errors
 
 # default module values (can be overridden per job in `config`)
 # update_every = 2
@@ -18,17 +18,17 @@ ORDER = ['accesses', 'volume', 'threads', 'jvm']
 
 CHARTS = {
     'accesses': {
-        'options': [None, "tomcat requests", "requests/s", "statistics", "tomcat.accesses", "area"],
+        'options': [None, "Requests", "requests/s", "statistics", "tomcat.accesses", "area"],
         'lines': [
-            ["accesses"]
+            ["accesses", None, 'incremental']
         ]},
     'volume': {
-        'options': [None, "tomcat volume", "KB/s", "volume", "tomcat.volume", "area"],
+        'options': [None, "Volume", "KB/s", "volume", "tomcat.volume", "area"],
         'lines': [
-            ["volume", None, 'incremental']
+            ["volume", None, 'incremental', 1, 1024]
         ]},
     'threads': {
-        'options': [None, "tomcat threads", "current threads", "statistics", "tomcat.threads", "line"],
+        'options': [None, "Threads", "current threads", "statistics", "tomcat.threads", "line"],
         'lines': [
             ["current", None, "absolute"],
             ["busy", None, "absolute"]
@@ -36,7 +36,7 @@ CHARTS = {
     'jvm': {
         'options': [None, "JVM Free Memory", "MB", "statistics", "tomcat.jvm", "area"],
         'lines': [
-            ["jvm", None, "absolute"]
+            ["jvm", None, "absolute", 1, 1048576]
         ]}
 }
 
@@ -66,7 +66,8 @@ class Service(UrlService):
         if self.port == 0:
             self.port = 80
 
-        if self._get_data() is None or len(self._get_data()) == 0:
+        test = self._get_data()
+        if test is None or len(test) == 0:
             return False
         else:
             return True
@@ -81,15 +82,15 @@ class Service(UrlService):
             try:
                 data = ET.fromstring(raw)
             except ET.ParseError as e:
-                if e.code == errors.codes[errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT]:
-                    # cut rest of invalid string
-                    pos = 0
-                    for i in range(e.position[0] - 1):
-                        pos += raw.find('\n', pos)
-                    raw = raw[:47604 + pos + e.position[0] - 1]
+                if e.code == errors.codes[errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT]:
+                if e.code == 9:
+                    end = raw.find('</status>')
+                    end += 9
+                    raw = raw[:end]
+                    self.debug(raw)
                     data = ET.fromstring(raw)
                 else:
-                    raise ET.ParseError(e)
+                    raise Exception(e)
 
             memory = data.find('./jvm/memory')
             threads = data.find("./connector[@name='\"http-bio-" + str(self.port) + "\"']/threadInfo")