當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。