Browse Source

monitoringplugin: Added seconds_to_hms() method.

This method converts seconds to H:MM:SS representation (as a string).
Sebastian Harl 14 years ago
parent
commit
264b0f5f21
1 changed files with 9 additions and 0 deletions
  1. 9 0
      monitoringplugin.py

+ 9 - 0
monitoringplugin.py

@@ -287,6 +287,15 @@ class MonitoringPlugin(object):
 			return value
 			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):
 	def human_to_number(self, value, total=None):
 		if total:
 		if total:
 			if not self.is_float(total):
 			if not self.is_float(total):