本文整理汇总了Python中monitor.Monitor.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.__init__方法的具体用法?Python Monitor.__init__怎么用?Python Monitor.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
Monitor.__init__(self, name, config_options)
try:
self.path = config_options["path"]
except:
raise RuntimeError("Required configuration fields missing")
self.params = ("svok %s" % self.path).split(" ")
示例2: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
"""Initialise the class.
Change script path to /etc/rc.d/ to monitor base system services. If the
script path ends with /, the service name is appended."""
Monitor.__init__(self, name, config_options)
try:
service_name = config_options["service"]
except:
raise RuntimeError("Required configuration fields missing")
if 'path' in config_options:
script_path = config_options["path"]
else:
script_path = "/usr/local/etc/rc.d/"
if 'return_code' in config_options:
want_return_code = int(config_options["return_code"])
else:
want_return_code = 0
if service_name == "":
raise RuntimeError("missing service name")
if script_path == "":
raise RuntimeError("missing script path")
if script_path.endswith("/"):
script_path = script_path + service_name
self.script_path = script_path
self.service_name = service_name
self.want_return_code = want_return_code
# Check if we need a .sh (old-style RC scripts in FreeBSD)
if not os.path.isfile(self.script_path):
if os.path.isfile(self.script_path + ".sh"):
self.script_path = self.script_path + ".sh"
else:
raise RuntimeError("Script %s(.sh) does not exist" % self.script_path)
示例3: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, openoffice, interval, limit_memory_usage):
"""Expects to receive an object that implements the interfaces IApplication
and ILockable, the limit of memory usage that the openoffice can use and
the interval to check the object."""
Monitor.__init__(self, openoffice, interval)
Process.__init__(self)
self.limit = limit_memory_usage
示例4: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
"""
Note: We use -w/-t on Windows/POSIX to limit the amount of time we wait to 5 seconds.
This is to stop ping holding things up too much. A machine that can't ping back in <5s is
a machine in trouble anyway, so should probably count as a failure.
"""
Monitor.__init__(self, name, config_options)
try:
ping_ttl = config_options["ping_ttl"]
except:
ping_ttl = "5"
ping_ms = ping_ttl * 1000
platform = sys.platform
if platform in ['win32', 'cygwin']:
self.ping_command = "ping -n 1 -w " + ping_ms + " %s"
self.ping_regexp = "Reply from "
self.time_regexp = "Average = (?P<ms>\d+)ms"
elif platform.startswith('freebsd') or platform.startswith('darwin'):
self.ping_command = "ping -c1 -t" + ping_ttl + " %s"
self.ping_regexp = "bytes from"
self.time_regexp = "min/avg/max/stddev = [\d.]+/(?P<ms>[\d.]+)/"
elif platform.startswith('linux'):
self.ping_command = "ping -c1 -W" + ping_ttl + " %s"
self.ping_regexp = "bytes from"
self.time_regexp = "min/avg/max/stddev = [\d.]+/(?P<ms>[\d.]+)/"
else:
RuntimeError("Don't know how to run ping on this platform, help!")
try:
host = config_options["host"]
except:
raise RuntimeError("Required configuration fields missing")
if host == "":
raise RuntimeError("missing hostname")
self.host = host
示例5: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, openoffice, interval, request_limit):
"""Expects to receive an object that implements the interfaces IApplication
and ILockable, the limit of request that the openoffice can receive and the
interval to check the object."""
Monitor.__init__(self, openoffice, interval)
Thread.__init__(self)
self.request_limit = request_limit
示例6: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
"""
Note: We use -w/-t on Windows/POSIX to limit the amount of time we wait to 5 seconds.
This is to stop ping holding things up too much. A machine that can't ping back in <5s is
a machine in trouble anyway, so should probably count as a failure.
"""
Monitor.__init__(self, name, config_options)
if self.is_windows(allow_cygwin=True):
self.ping_command = "ping -n 1 -w 5000 %s"
self.ping_regexp = "Reply from "
self.time_regexp = "Average = (?P<ms>\d+)ms"
else:
try:
ping_ttl = config_options["ping_ttl"]
except:
ping_ttl = "5"
self.ping_command = "ping -c1 -W2 -t"+ ping_ttl + " %s 2> /dev/null"
self.ping_regexp = "bytes from"
#XXX this regexp is only for freebsd at the moment; not sure about other platforms
#XXX looks like Linux uses this format too
self.time_regexp = "min/avg/max/stddev = [\d.]+/(?P<ms>[\d.]+)/"
try:
host = config_options["host"]
except:
raise RuntimeError("Required configuration fields missing")
if host == "":
raise RuntimeError("missing hostname")
self.host = host
示例7: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, config, **args):
Monitor.__init__(self, config, **args)
self.critical = self.getconfig("critical")
self.warning = self.getconfig("warning")
self.ignoremissing = self.getconfig("ignoremissing", False)
self.func = self.getconfig("function", 'and')
示例8: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, openoffice, interval, sleeping_time):
"""Expects to receive an object that implements the interfaces IApplication
and ILockable, the limit of memory usage that the openoffice can use and
the interval to check the object."""
Monitor.__init__(self, openoffice, interval)
Thread.__init__(self)
self.sleeping_time = sleeping_time
self._touched_at = time()
示例9: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
Monitor.__init__(self, name, config_options)
if 'span' in config_options:
try:
self.span = int(config_options["span"])
except:
raise RuntimeError("span parameter must be an integer")
if self.span < 1:
raise RuntimeError("span parameter must be > 0")
示例10: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, config, **args):
Monitor.__init__(self, config, **args)
self.command = self.getconfig("command", default="")
self.hosts = self.getconfig("anshosts", default=[])
self.user = self.getconfig("user", default="root")
self.forks = self.getconfig("forks", default=5)
self.ansmod = self.getconfig("ansmod", default="shell")
self.blacklist = self.getconfig("blacklist", default="")
self.sshkey = self.getconfig("sshkey", default="")
self.savetofile = self.getconfig("savetofile", default="")
示例11: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, config=None):
Monitor.__init__(self, config)
self._cpu_last = None
self._processors = {}
self._sockets = []
self._physid_to_id = {}
self._id_to_physid = {}
sockets = {}
with open('/proc/cpuinfo', 'r') as fd:
processor_id = None
physical_socket_id = None
physical_core_id = None
for line in fd.readlines():
line = line.strip()
if line == "":
self._processors[processor_id] = (physical_socket_id, physical_core_id)
if physical_socket_id not in sockets:
sockets[physical_socket_id] = []
sockets[physical_socket_id].append(physical_core_id)
else:
key, value = line.split(':')
key = key.strip()
value = value.strip()
if key == "processor":
processor_id = int(value)
elif key == "physical id":
physical_socket_id = int(value)
elif key == "core id":
physical_core_id = int(value)
i = 0
for pi in sorted(sockets.keys()):
cores = []
j = 0
for pj in sorted(sockets[i]):
cores.append(pj)
self._physid_to_id[(pi, pj)] = (i, j)
self._id_to_physid[(i, j)] = (pi, pj)
j += 1
self._sockets.append((pi, cores))
i += 1
示例12: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, config, **args):
Monitor.__init__(self, config, **args)
self.command = self.getconfig("command", default="")
self.setenv = self.getconfig("setenv", default=False)
self.arguments = self.getconfig("arguments", default=[])
if self.arguments:
sd = SearchDict(Monitor.facts)
for arg in self.arguments:
results = sd.resolcheck(arg)
for res in results['checks']:
self.command = "{0} {1}".format(self.command, res['value'])
示例13: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
Monitor.__init__(self, name, config_options)
monitors=[]
try:
monitors = [ele.strip() for ele in config_options["monitors"].split(",")]
except:
raise RuntimeError("Required configuration fields missing")
min_fail = len(monitors)
try:
min_fail = int(config_options["min_fail"])
except:
pass
self.min_fail = min_fail
self.monitors = monitors
self.m = -1
self.mt = None
示例14: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, rootdir):
Monitor.__init__(self, rootdir)
self.remaproot = rootdir
self.broker_address = "unknown"
self.brokerChanged = False
self.bsub = None
self.bpub = None
self.bonjour = BonjourResolver("_remap._tcp", self.cb_broker_changed)
self.bonjour.start()
self.jobid = None
self.refreshed = 0
self.job_status = "waiting"
self.rejectedtasks = {}
self.completedtasks = {}
self.tasks = {}
self.allocatedtasks = {}
self.jobtype = "not_started"
self.priority = 0
self.parallellism = 1
self.manager = None
self.last_check = time.time()
示例15: __init__
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import __init__ [as 别名]
def __init__(self, name, config_options):
Monitor.__init__(self, name, config_options)
try:
url = config_options["url"]
except:
raise RuntimeError("Required configuration fields missing")
if 'regexp' in config_options:
regexp = config_options["regexp"]
else:
regexp = ""
if 'allowed_codes' in config_options:
allowed_codes = [int(x.strip()) for x in config_options["allowed_codes"].split(",")]
else:
allowed_codes = []
# optionnal - for HTTPS client authentication only
# in this case, certfile is required
if 'certfile' in config_options:
certfile = config_options["certfile"]
# if keyfile not given, it is assumed key is in certfile
if 'keyfile' in config_options:
keyfile = config_options["keyfile"]
else:
# default: key
keyfile = certfile
self.url = url
if regexp != "":
self.regexp = re.compile(regexp)
self.regexp_text = regexp
self.allowed_codes = allowed_codes
self.certfile = certfile
self.keyfile = keyfile