monitoringplugin: Added seconds_to_hms() method.

This method converts seconds to H:MM:SS representation (as a string).
This commit is contained in:
Sebastian Harl 2011-05-04 14:07:55 +02:00
parent 2904249055
commit 264b0f5f21

View file

@ -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):