check_sensors: Allow hex sensor ids
Signed-off-by: Sven Velt <sven@velt.de>
This commit is contained in:
parent
d76966cca8
commit
ff3b795663
|
@ -8,7 +8,7 @@ import time
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
plugin = MonitoringPlugin(pluginname='check_tl500', tagforstatusline='TL500', description='Check TL500 environment sensors', version='0.1')
|
plugin = MonitoringPlugin(pluginname='check_sensors', tagforstatusline='Sensors', description='Check environment sensors', version='0.2')
|
||||||
|
|
||||||
plugin.add_cmdlineoption('-s', '', 'sensorid', '(comma separated list of) sensor id(s), no spaces', default=None)
|
plugin.add_cmdlineoption('-s', '', 'sensorid', '(comma separated list of) sensor id(s), no spaces', default=None)
|
||||||
plugin.add_cmdlineoption('-m', '', 'maxage', 'maximum age of data files (default: 600 seconds/10 minutes)', type="int", default=600)
|
plugin.add_cmdlineoption('-m', '', 'maxage', 'maximum age of data files (default: 600 seconds/10 minutes)', type="int", default=600)
|
||||||
|
@ -31,14 +31,12 @@ if ',' in plugin.options.sensorid:
|
||||||
else:
|
else:
|
||||||
plugin.options.sensorid = [plugin.options.sensorid,]
|
plugin.options.sensorid = [plugin.options.sensorid,]
|
||||||
|
|
||||||
# Convert all sensor ids to long
|
# Check all sensor ids are hex
|
||||||
for idx in xrange(len(plugin.options.sensorid)):
|
re_hex = re.compile('^[0-9A-Fa-f]+$')
|
||||||
try:
|
for sid in plugin.options.sensorid:
|
||||||
plugin.options.sensorid[idx] = long(plugin.options.sensorid[idx])
|
if not re_hex.search(sid):
|
||||||
except ValueError:
|
plugin.back2nagios(3, 'Sensor id "%s" must be integer or hex!' % sid)
|
||||||
plugin.back2nagios(3, 'Sensor id "%s" must be numeric!' % plugin.options.sensorid[idx])
|
|
||||||
|
|
||||||
plugin.options.sensorid.sort()
|
|
||||||
plugin.verbose(1, 'Sensor id(s): ' + ' - '.join([str(s) for s in plugin.options.sensorid]))
|
plugin.verbose(1, 'Sensor id(s): ' + ' - '.join([str(s) for s in plugin.options.sensorid]))
|
||||||
|
|
||||||
searchpattern = re.compile(r'(\d+)\s+Sensor:\s*([0-9A-Za-z]+)\s+Raw:\s*(-?[0-9\.]+)?\s+Value:\s*(-?[0-9\.]+)\s+Unit:\s*(\S+)\b')
|
searchpattern = re.compile(r'(\d+)\s+Sensor:\s*([0-9A-Za-z]+)\s+Raw:\s*(-?[0-9\.]+)?\s+Value:\s*(-?[0-9\.]+)\s+Unit:\s*(\S+)\b')
|
||||||
|
|
Loading…
Reference in a new issue