]> arthur.barton.de Git - netdata.git/commitdiff
add resync/check/recovery progress charts
authorlgz <lgz@loled2>
Sun, 1 Jan 2017 09:06:15 +0000 (18:06 +0900)
committerlgz <lgz@loled2>
Sun, 1 Jan 2017 09:07:20 +0000 (18:07 +0900)
python.d/mdstat.chart.py

index 5a51660d2957f4625a28ec9ca68d8f825e5867fd..e9a041dfe90d8dd0bb41656d314ba73a4df561a4 100644 (file)
@@ -19,6 +19,7 @@ class Service(SimpleService):
                                  'lines': []}}
         self.proc_mdstat = '/proc/mdstat'
         self.regex_disks = compile(r'((?<=\ )[a-zA-Z_0-9]+(?= : active)).*?((?<= \[)[0-9]+)/([0-9]+(?=\] ))')
+        self.regex_status = compile(r'([a-zA-Z_0-9]+)( : active)[^:]*?([a-z]+) = ([0-9.]+(?=%))')
 
     def check(self):
         raw_data = self._get_raw_data()
@@ -29,11 +30,17 @@ class Service(SimpleService):
             md_list = [md[0] for md in self.regex_disks.findall(raw_data)]
             for md in md_list:
                 self.order.append(md)
+                self.order.append(''.join([md, '_status']))
                 self.definitions['agr_health']['lines'].append([''.join([md, '_health']), md, 'absolute'])
                 self.definitions[md] = {'options':
                                             [None, 'MD disks stats', 'disks', md, 'md.stats', 'stacked'],
                                         'lines': [[''.join([md, '_total']), 'total', 'absolute'],
                                                   [''.join([md, '_inuse']), 'inuse', 'absolute']]}
+                self.definitions[''.join([md, '_status'])] = {'options':
+                                            [None, 'MD current status', 'percent', md, 'md.status', 'line'],
+                                        'lines': [[''.join([md, '_resync']), 'resync', 'absolute'],
+                                                  [''.join([md, '_recovery']), 'recovery', 'absolute'],
+                                                  [''.join([md, '_check']), 'check', 'absolute']]}
             self.info('Plugin was started successfully. MDs to monitor %s' % (md_list))
 
             return True
@@ -58,12 +65,19 @@ class Service(SimpleService):
         :return: dict
         """
         raw_mdstat = self._get_raw_data()
-        mdstat = self.regex_disks.findall(raw_mdstat)
+        mdstat_disks = self.regex_disks.findall(raw_mdstat)
+        mdstat_status = self.regex_status.findall(raw_mdstat)
         to_netdata = {}
 
-        for md in mdstat:
+        for md in mdstat_disks:
             to_netdata[''.join([md[0], '_total'])] = int(md[1])
             to_netdata[''.join([md[0], '_inuse'])] = int(md[2])
             to_netdata[''.join([md[0], '_health'])] = int(md[1]) - int(md[2])
+            to_netdata[''.join([md[0], '_check'])] = 0
+            to_netdata[''.join([md[0], '_resync'])] = 0
+            to_netdata[''.join([md[0], '_recovery'])] = 0
+        
+        for md in mdstat_status:
+            to_netdata[''.join([md[0], '_' + md[2]])] = round(float(md[3]))
 
         return to_netdata