Просмотр исходного кода

fix(python.d/smartd_log): handle log rotation (#13460)

Ilya Mashchenko 2 лет назад
Родитель
Сommit
cf83bad6c1
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      collectors/python.d.plugin/smartd_log/smartd_log.chart.py

+ 5 - 1
collectors/python.d.plugin/smartd_log/smartd_log.chart.py

@@ -630,6 +630,7 @@ class Service(SimpleService):
         self.exclude = configuration.get('exclude_disks', str()).split()
         self.exclude = configuration.get('exclude_disks', str()).split()
         self.disks = list()
         self.disks = list()
         self.runs = 0
         self.runs = 0
+        self.do_force_rescan = False
 
 
     def check(self):
     def check(self):
         return self.scan() > 0
         return self.scan() > 0
@@ -637,9 +638,10 @@ class Service(SimpleService):
     def get_data(self):
     def get_data(self):
         self.runs += 1
         self.runs += 1
 
 
-        if self.runs % DEF_RESCAN_INTERVAL == 0:
+        if self.do_force_rescan or self.runs % DEF_RESCAN_INTERVAL == 0:
             self.cleanup()
             self.cleanup()
             self.scan()
             self.scan()
+            self.do_force_rescan = False
 
 
         data = dict()
         data = dict()
 
 
@@ -654,10 +656,12 @@ class Service(SimpleService):
 
 
             if changed is None:
             if changed is None:
                 disk.alive = False
                 disk.alive = False
+                self.do_force_rescan = True
                 continue
                 continue
 
 
             if changed and disk.populate_attrs() is None:
             if changed and disk.populate_attrs() is None:
                 disk.alive = False
                 disk.alive = False
+                self.do_force_rescan = True
                 continue
                 continue
 
 
             data.update(disk.data())
             data.update(disk.data())