]> git.openstreetmap.org Git - nominatim.git/blobdiff - munin/nominatim_requests_querylog
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / munin / nominatim_requests_querylog
index 64293d6fdad9b7da862315cda52b8b2563c4fa3c..8a103cfcbb2533f491715db2ce4204fe9ab848f8 100755 (executable)
@@ -28,6 +28,9 @@ z2.type GAUGE
 z3.label search (no result)
 z3.draw STACK
 z3.type GAUGE
+z4.label lookup
+z4.draw STACK
+z4.type GAUGE
 z4.label details
 z4.draw STACK
 z4.type GAUGE"""
@@ -40,7 +43,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):
@@ -121,9 +124,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__':
@@ -135,6 +137,7 @@ if __name__ == '__main__':
     reverse = 0
     searchy = 0
     searchn = 0
+    lookup = 0
     details = 0
     if 'NOMINATIM_QUERYLOG' in os.environ:
         lf = LogFile(os.environ['NOMINATIM_QUERYLOG'])
@@ -147,6 +150,8 @@ if __name__ == '__main__':
                         searchn += 1
                     else:
                         searchy += 1
+                elif  l['type'] == 'place':
+                    lookup +=1
                 else:
                     details += 1
 
@@ -154,4 +159,5 @@ if __name__ == '__main__':
     print('z1.value', reverse/5)
     print('z2.value', searchy/5)
     print('z3.value', searchn/5)
+    print('z4.value', lookup/5)
     print('z4.value', details/5)