]> arthur.barton.de Git - netdata.git/commitdiff
fix issue with rotating log
authorpaulfantom <paulfantom@gmail.com>
Fri, 1 Jul 2016 12:06:51 +0000 (14:06 +0200)
committerpaulfantom <paulfantom@gmail.com>
Fri, 1 Jul 2016 12:06:51 +0000 (14:06 +0200)
python.d/python_modules/base.py

index 6958eb8e228cc920d731d682b45cd53aece0f5b8..79e0438bc69b4058c105003c627b48c978249457 100644 (file)
@@ -437,16 +437,20 @@ class LogService(SimpleService):
         #    self._log_reader = Popen(['tail', '-F', self.log_path], stdout=PIPE, stderr=STDOUT)
         lines = []
         last = 0
+        total = 0
         try:
             with open(self.log_path) as fp:
                 for i, line in enumerate(fp):
                     if i > self._last_line:
                         lines.append(line)
                         last = i
+                    total += 1
         except Exception as e:
             msg.error(self.__module__, str(e))
         if last != 0:
             self._last_line = last
+        elif self._last_line > total:
+            self._last_line = 0
 
         if len(lines) != 0:
             return lines