Explorar el Código

monitoringplugin: Added seconds_to_hms() method.

This method converts seconds to H:MM:SS representation (as a string).
Sebastian Harl hace 14 años
padre
commit
264b0f5f21
Se han modificado 1 ficheros con 9 adiciones y 0 borrados
  1. 9 0
      monitoringplugin.py

+ 9 - 0
monitoringplugin.py

@@ -287,6 +287,15 @@ class MonitoringPlugin(object):
 			return value
 
 
+	def seconds_to_hms(self, seconds):
+		seconds = int(seconds)
+		hours = int(seconds / 3600)
+		seconds -= (hours * 3600)
+		minutes = seconds / 60
+		seconds -= (minutes * 60)
+		return '%i:%02i:%02i' % (hours, minutes, seconds)
+
+
 	def human_to_number(self, value, total=None):
 		if total:
 			if not self.is_float(total):