diff options
-rw-r--r-- | python.d/mdstat.chart.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/python.d/mdstat.chart.py b/python.d/mdstat.chart.py index 5a51660d29..e9a041dfe9 100644 --- a/python.d/mdstat.chart.py +++ b/python.d/mdstat.chart.py @@ -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 |