]> git.openstreetmap.org Git - nominatim.git/blobdiff - munin/nominatim_query_speed_querylog
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / munin / nominatim_query_speed_querylog
index 1959e38e42e1a6cd4662213ec0cc783721fb20af..f35793fe1d8e6e7ccb07ef34deba8d41fc34530c 100755 (executable)
@@ -4,7 +4,7 @@
 #
 # Uses the query log.
 #
-# Parameters: 
+# Parameters:
 #
 #       config   (required)
 #       autoconf (optional - used by munin-config)
@@ -33,11 +33,11 @@ avgr.type GAUGE
 avgr.min 0
 avgr.info Moving 5 minute average time to perform reverse
 
-max.label Slowest time to response
+max.label Slowest time to response (1/100)
 max.draw LINE
 max.type GAUGE
 max.min 0
-max.info Slowest query in last 5 minutes"""
+max.info Slowest query in last 5 minutes (unit: 100s)"""
 
 ENTRY_REGEX = re.compile(r'\[[^]]+\] (?P<dur>[0-9.]+) (?P<numres>\d+) (?P<type>[a-z]+) ')
 TIME_REGEX = re.compile(r'\[(?P<t_year>\d\d\d\d)-(?P<t_month>\d\d)-(?P<t_day>\d\d) (?P<t_hour>\d\d):(?P<t_min>\d\d):(?P<t_sec>\d\d)[0-9.]*\] ')
@@ -47,7 +47,7 @@ class LogFile:
     """ A query log file, unpacked. """
 
     def __init__(self, filename):
-        self.fd = open(filename, encoding='utf-8')
+        self.fd = open(filename, encoding='utf-8', errors='replace')
         self.len = os.path.getsize(filename)
 
     def __del__(self):
@@ -128,9 +128,8 @@ class LogFile:
     def loglines(self):
         for l in self.fd:
             e = ENTRY_REGEX.match(l)
-            if e is None:
-                raise ValueError("Invalid log line:", l)
-            yield e.groupdict()
+            if e is not None:
+                yield e.groupdict()
 
 
 if __name__ == '__main__':
@@ -161,4 +160,4 @@ if __name__ == '__main__':
 
     print('avgs.value', 0 if numsearch == 0 else sumsearch/numsearch)
     print('avgr.value', 0 if numrev == 0 else sumrev/numrev)
-    print('max.value', maxres)
+    print('max.value', maxres/100.0)