Ver código fonte

monitoringplugin: Don't output warn/crit as 1.23e+45...

Signed-off-by: Sven Velt <sven@velt.de>
Sven Velt 14 anos atrás
pai
commit
fa6dc16dc4
1 arquivos alterados com 4 adições e 2 exclusões
  1. 4 2
      monitoringplugin.py

+ 4 - 2
monitoringplugin.py

@@ -1,3 +1,5 @@
+# -*- encoding: utf-8 -*-
+
 __version__ = '0.0.100802'
 __all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin']
 
@@ -288,10 +290,10 @@ class MonitoringPlugin(object):
 				range = range[1:]
 
 			parts = range.split(':')
-			newrange += str(self.human_to_number(parts[0], total))
+			newrange += ('%f' % self.human_to_number(parts[0], total)).rstrip('0').rstrip('.')
 			
 			if len(parts) > 1:
-				newrange += ':' + str(self.human_to_number(parts[1], total))
+				newrange += ':' + ('%f' % self.human_to_number(parts[1], total)).rstrip('0').rstrip('.')
 
 			if range != newrange:
 				self.verbose(3, 'Changed range/thresold from "' + range + '" to "' + newrange + '"')