当前位置: 首页>>代码示例>>Python>>正文


Python PluginHelper.set_timeout方法代码示例

本文整理汇总了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.")
开发者ID:AccelerationNet,项目名称:pynag,代码行数:104,代码来源:test_plugins.py


注:本文中的pynag.Plugins.PluginHelper.set_timeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。