Kaynağa Gözat

sensors: Show file age if sensor file is too old

Signed-off-by: Sven Velt <sven@velt.de>
Sven Velt 13 yıl önce
ebeveyn
işleme
d715b13e03
1 değiştirilmiş dosya ile 3 ekleme ve 1 silme
  1. 3 1
      check_sensors.py

+ 3 - 1
check_sensors.py

@@ -93,8 +93,10 @@ for sensorid in plugin.options.sensorid:
 	plugin.verbose(2, 'Checking age of file')
 	fileage = time.time() - os.path.getmtime(filename)
 	if fileage > plugin.options.maxage:
+		returncode = 3
 		plugin.add_output('Data of sensor "%s" to old' % sensorid)
-		plugin.add_returncode(3)
+		plugin.add_multilineoutput('%s %s because of file age: %s, limit: %s' % (sensorid, plugin.RETURNSTRINGS[returncode], plugin.seconds_to_timedelta(fileage), plugin.seconds_to_timedelta(plugin.options.maxage)))
+		plugin.add_returncode(returncode)
 		plugin.verbose(2, 'File to old, age: %s but only %s seconds allowed'% (long(fileage), plugin.options.maxage))
 	else:
 		plugin.verbose(2, 'File age OK, age: %s and %s seconds are allowed'% (long(fileage), plugin.options.maxage))