本文整理汇总了Python中pynag.Plugins.PluginHelper.add_option方法的典型用法代码示例。如果您正苦于以下问题:Python PluginHelper.add_option方法的具体用法?Python PluginHelper.add_option怎么用?Python PluginHelper.add_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynag.Plugins.PluginHelper
的用法示例。
在下文中一共展示了PluginHelper.add_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginHelper
# 需要导入模块: from pynag.Plugins import PluginHelper [as 别名]
# 或者: from pynag.Plugins.PluginHelper import add_option [as 别名]
#!/usr/bin/env python
from pynag.Plugins import PluginHelper, ok, warning, critical, unknown
from pynag.Utils import runCommand
from collections import namedtuple
valid_queries = "lsarray lsdrive lsenclosurebattery lsenclosurecanister lsenclosurepsu lsenclosureslot lsenclosure lsmdiskgrp lsmdskgrp lsmgrp lsrcrelationship lsvdisk"
p = PluginHelper()
p.add_option("-H", "--hostname", '-M', help="Hostname or ip address", dest="hostname")
p.add_option("-U", "--user", help="Log in as this user to storwize", dest="user", default="nagios")
p.add_option("-Q", "--query", help="Query to send to storwize (see also -L)", dest="query", default="lsarray")
p.add_option("-L", "--list-queries", help="List of valid queries", dest="list_queries", action="store_true")
p.add_option("--test", help="Run this plugin in test mode", dest="test", action="store_true")
p.parse_arguments()
if p.options.list_queries is True:
p.parser.error("Valid Queries: %s" % valid_queries)
if not p.options.hostname:
p.parser.error("Required options -H is missing")
if p.options.query not in valid_queries.split():
p.parser.error("%s does not look like a valid query. Use -L for a list of valid queries" % p.options.query)
query = p.options.query
# Connect to remote storwize and run a connect
def run_query():
""" Connect to a remote storwize box and run query """
command = "ssh %[email protected]%s %s -delim ':'" % (p.options.user, p.options.hostname, p.options.query)