'smartd_log' fixes
lgz committed
Oct 19, 2017 at 00:10 UTC
f00185384828c3a1afc98de46acee0569f2c1f09
2 files changed
+12
-6
conf.d/python.d/smartd_log.conf
+4
-3
@@ -56,9 +56,10 @@
56
#
57
# Additionally to the above, smartd_log also supports the following:
58
#
59
-# log_path: '/path/to/smartdlogs' # path to smartd log files. Default is /var/log/smartd
60
-# raw_values: no # raw or normalized values on charts. Default is normalized.
61
-# smart_attributes: '1 2 3 4 44' # smart attributes charts. Default are ['1', '4', '5', '7', '9', '12', '193', '194', '197', '198', '200'].
59
+# log_path: '/path/to/smartdlogs' # path to smartd log files. Default is /var/log/smartd
60
+# raw_values: no # raw or normalized values on charts. Default is normalized.
61
+# smart_attributes: '1 2 3 4 44' # smart attributes charts. Default are ['1', '4', '5', '7', '9', '12', '193', '194', '197', '198', '200'].
62
+# exclude_disks: 'PATTERN1 PATTERN2' # space separated patterns. If the pattern is in the drive name, the module will not collect data for it.
63
#
64
# ----------------------------------------------------------------------
65
# Additional information
python.d/smartd_log.chart.py
+8
-3
@@ -101,12 +101,18 @@ class Service(SimpleService):
101
self.log_path = self.configuration.get('log_path', '/var/log/smartd')
102
self.raw_values = self.configuration.get('raw_values')
103
self.attr = self.configuration.get('smart_attributes', [])
104
+ self.exclude_disks = self.configuration.get('exclude_disks', str()).split()
105
self.order = list()
106
self.definitions = dict()
107
self.disks = list()
108
109
for path_to_disk in find_disks_in_log_path(self.log_path):
109
- self.disks.append(Disk(name=os.path.basename(path_to_disk), path=path_to_disk))
110
+ disk_name = os.path.basename(path_to_disk).split('.')[-3]
111
+ for pattern in self.exclude_disks:
112
+ if pattern in disk_name:
113
+ break
114
+ else:
115
+ self.disks.append(Disk(name=disk_name, path=path_to_disk))
116
117
def check(self):
118
if not self.disks:
@@ -141,8 +147,7 @@ class Service(SimpleService):
147
def create_lines(attr_id):
148
result = list()
149
for disk in self.disks:
144
- name = disk.name
145
- result.append(['_'.join([name, attr_id]), name[:name.index('.')], 'absolute'])
150
+ result.append(['_'.join([disk.name, attr_id]), disk.name, 'absolute'])
151
return result
152
153
try: