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


Python simple.check_messages方法代码示例

本文整理汇总了Python中pynag.Plugins.simple.check_messages方法的典型用法代码示例。如果您正苦于以下问题:Python simple.check_messages方法的具体用法?Python simple.check_messages怎么用?Python simple.check_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynag.Plugins.simple的用法示例。


在下文中一共展示了simple.check_messages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pynag.Plugins import simple [as 别名]
# 或者: from pynag.Plugins.simple import check_messages [as 别名]
def main():
    global plugin

    plugin = Plugin(must_threshold=False)
    plugin.add_arg("l", "logical-volume",
                   "Comma seperated list of VG/LV, eg vg00/data,vg00/snap",
                   required=False)
    plugin.add_arg("V", "volume-group",
                   "Comma seperated list of VG, eg vg00,vg01",
                   required=False)
    plugin.add_arg("a", "check-all", "Check all LVs", required=False,
                   action="store_true")
    plugin.activate()

    lvs = plugin["logical-volume"] and plugin["logical-volume"].split(
        ",") or []
    vgs = plugin["volume-group"] and plugin["volume-group"].split(",") or []

    if not lvs and not vgs and not plugin['check-all']:
        plugin.parser.error(
            "Either logical-volume or volume-group must be specified")
    elif plugin['check-all'] and ( lvs or vgs ):
        plugin.parser.error(
            "Mixing check-all and logical-volume or volume-group does not make sense")

    check_mirror(lvs, vgs, plugin['check-all'], plugin['host'])

    (code, message) = (plugin.check_messages(joinallstr="\n"))
    plugin.nagios_exit(code, message)
开发者ID:carriercomm,项目名称:nagios-plugins,代码行数:31,代码来源:check_lvm_mirror.py

示例2: main

# 需要导入模块: from pynag.Plugins import simple [as 别名]
# 或者: from pynag.Plugins.simple import check_messages [as 别名]
def main():
    global np
    np = Plugin(must_threshold=False)

    np.add_arg('w', 
               'warning', 
               'Warn when X days until certificate expires', 
               required=None)
    np.add_arg('c', 
               'critical', 
               'Critical when X days until certificate expires', 
               required=None)

    np.activate()

    if np['warning'] is None:
        np['warning'] = "14"
    if np['critical'] is None:
        np['critical'] = "2"

    for t in ['warning', 'critical']:
        if np[t] and np[t].isdigit() is False:
            print "%s threshold must be a positive number" % t.capitalize()
            sys.exit(3)

    certs = getcert_list()

    for cert in certs:
        if cert['stuck'] != "no":
            np.add_message(
                   WARNING, 
                   "Certificate %s from certdb %s is stuck=%s" % (
                       cert['certificate']['nickname'], 
                       cert['certificate']['location'],
                       cert['stuck']))

        expires_diff = cert['expires'] - datetime.datetime.now()
        if expires_diff.days < 0:
            np.add_message(
                   CRITICAL,
                   "Certificate %s from certdb %s has EXPIRED %i days ago" % (
                       cert['certificate']['nickname'], 
                       cert['certificate']['location'],
                       expires_diff.days*-1))

        elif expires_diff.days < int(np['critical']):
            np.add_message(
                   CRITICAL,
                   "Certificate %s from certdb %s expires in %i days" % (
                       cert['certificate']['nickname'], 
                       cert['certificate']['location'],
                       expires_diff.days))

        elif expires_diff.days < int(np['warning']):
            np.add_message(
                   WARNING,
                   "Certificate %s from certdb %s expires in %i days" % (
                       cert['certificate']['nickname'], 
                       cert['certificate']['location'],
                       expires_diff.days))

        else:
            np.add_message(
                   OK,
                   "Certificate %s from certdb %s expires in %i days" % (
                       cert['certificate']['nickname'], 
                       cert['certificate']['location'],
                       expires_diff.days))

    code, messages = np.check_messages(joinallstr="\n")
    np.nagios_exit(code, messages)
开发者ID:tomas-edwardsson,项目名称:check_certmonger,代码行数:73,代码来源:check_certmonger.py

示例3: Disque

# 需要导入模块: from pynag.Plugins import simple [as 别名]
# 或者: from pynag.Plugins.simple import check_messages [as 别名]
        for k, v in self.__info.iteritems():
            self.__dict__[k] = v

disque = Disque()

info_properties = [
    "used_memory_rate",
    "connected_clients",
    "client_longest_output_list",
    "client_biggest_input_buf",
    "client_biggest_input_buf",
    "rejected_connections",
    "total_commands_processed",
    "total_connections_received",
    "used_memory_human",
    "used_memory_peak_human",
    "mem_fragmentation_ratio",
    "instantaneous_ops_per_sec",
]

for info_property in info_properties:
    np.add_perfdata(info_propert, getattr(disque, info_property))

code, messages = np.check_messages()

np.nagios_exit(
    code,
    messages,
)

开发者ID:nabetama,项目名称:disque-info-nagios-plugin,代码行数:31,代码来源:check_disq.py


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