monitoringplugin: Add seconds_to_timedelta()

Signed-off-by: Sven Velt <sven@velt.de>
This commit is contained in:
Sven Velt 2011-07-15 11:55:33 +02:00
parent 9f17c3c838
commit 1a7b38f6f6

View file

@ -22,10 +22,10 @@
# along with this file. If not, see <http://www.gnu.org/licenses/>. # # along with this file. If not, see <http://www.gnu.org/licenses/>. #
##################################################################### #####################################################################
__version__ = '0.0.100802' __version__ = '0.0.110715'
__all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin'] __all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin']
import optparse, os, re, sys import datetime, optparse, os, re, sys
try: try:
import netsnmp import netsnmp
@ -296,6 +296,10 @@ class MonitoringPlugin(object):
return '%i:%02i:%02i' % (hours, minutes, seconds) return '%i:%02i:%02i' % (hours, minutes, seconds)
def seconds_to_timedelta(self, seconds):
return datetime.timedelta(seconds=long(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):