本文整理匯總了Python中pynag.Plugins.PluginHelper.set_timeout方法的典型用法代碼示例。如果您正苦於以下問題:Python PluginHelper.set_timeout方法的具體用法?Python PluginHelper.set_timeout怎麽用?Python PluginHelper.set_timeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pynag.Plugins.PluginHelper
的用法示例。
在下文中一共展示了PluginHelper.set_timeout方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PluginHelper
# 需要導入模塊: from pynag.Plugins import PluginHelper [as 別名]
# 或者: from pynag.Plugins.PluginHelper import set_timeout [as 別名]
#.........這裏部分代碼省略.........
self.run_expect(case, '-23', 2)
def test_number_18(self):
case = '--th=metric=fakedata,warn=1..9,crit=^0..10'
self.run_expect(case, '0', 0)
def test_number_19(self):
case = '--th=metric=fakedata,warn=1..9,crit=^0..10'
self.run_expect(case, '7', 1)
def test_number_20(self):
case = '--th=metric=fakedata,warn=1..9,crit=^0..10'
self.run_expect(case, '23', 2)
# The only noncritical range is 5:6
def test_number_21(self):
case = '--th=metric=fakedata,ok=5..6'
self.run_expect(case, '-23', 2)
def test_number_22(self):
case = '--th=metric=fakedata,ok=5..6'
self.run_expect(case, '0', 2)
def test_number_23(self):
case = '--th=metric=fakedata,ok=5..6'
self.run_expect(case, '2', 2)
def test_number_24(self):
case = '--th=metric=fakedata,ok=5..6'
self.run_expect(case, '5', 0)
def test_number_25(self):
case = '--th=metric=fakedata,ok=5..6'
self.run_expect(case, '6', 0)
def test_number_26(self):
case = '--th=metric=fakedata,ok=5..6'
self.run_expect(case, '7', 2)
# Critical if "stuff" is 10 to 20
def test_number_27(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '-23', 0)
def test_number_28(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '0', 0)
def test_number_29(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '2', 0)
def test_number_30(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '10', 2)
def test_number_31(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '15', 2)
def test_number_32(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '20', 2)
def test_number_33(self):
case = '--th=metric=fakedata,ok=^10..20'
self.run_expect(case, '23', 0)
# Cmdline thresholds pass but we insert a "hardcoded" metric with thresholds
# which will also be evaluated
def test_number_34(self):
# Extra case with hardcoded thresholds
self.my_plugin.add_metric('fakedata2', value='15',
warn='0..10', crit='10..inf')
case = '--th=metric=fakedata,ok=0..10,warn=10..20'
self.run_expect(case, 3, 2)
def test_number_35(self):
# Extra case with hardcoded thresholds
self.my_plugin.add_metric('fakedata2', value='9',
warn='0..10', crit='10..inf')
case = '--th=metric=fakedata,ok=0..10,warn=10..20'
self.run_expect(case, 3, 1)
def test_number_36(self):
# Extra case with hardcoded thresholds
self.my_plugin.add_metric('fakedata2', value='-4',
warn='0..10', crit='10..inf')
case = '--th=metric=fakedata,ok=0..10,warn=10..20'
self.run_expect(case, 3, 0)
def testTimeout(self):
try:
self.my_plugin.set_timeout(1)
time.sleep(1)
self.assertTrue(False, "Code should have timed out by now")
except SystemExit as e:
self.assertEquals(type(e), type(SystemExit()))
self.assertEquals(e.code, pynag.Plugins.unknown)
self.assertTrue(True, "Timeout occured in plugin, just like expected.")