def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) try: self.path = config_options['record'] except: raise RuntimeError("Required configuration fields missing") if self.path == '': raise RuntimeError("Required configuration fields missing") if 'desired_val' in config_options: self.desired_val = config_options['desired_val'] else: self.desired_val = None if 'server' in config_options: self.server = config_options['server'] else: self.server = None self.params = [self.command] if self.server: self.params.append("@%s" % self.server) if 'record_type' in config_options: self.params.append('-t') self.params.append(config_options['record_type']) self.rectype = config_options['record_type'] else: self.rectype = None self.params.append(self.path) self.params.append('+short')
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
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)
def __init__(self, prefs={}): Monitor.__init__(self) self._input_dir = os.path.join(get_cache_dir(), "mi2log") # ??? getCacheDir() self._input_dir = "/sdcard/mtklog" self._type_names = [] self._filename_sort_key = None self._read_latency = [] libs_path = os.path.join(get_files_dir(), "data") ws_dissector_path = os.path.join(libs_path, "android_pie_ws_dissector") self.libs_path = libs_path self.ws_dissector_path = ws_dissector_path self._executable_path = os.path.join(self.libs_path, "diag_revealer_mtk") self._log_path = os.path.join(self._input_dir, "mdlog1") self._filter_src_path = os.path.join(self.libs_path, "MTK-filter") self._filter_dest_path = os.path.join(self._input_dir, "mdlog1_config") prefs = { "ws_dissect_executable_path": os.path.join(libs_path, "android_pie_ws_dissector"), "libwireshark_path": libs_path } DMLogPacket.init(prefs)
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
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)
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')
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(" ")
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 -t" + ping_ttl + " %s 2> /dev/null" self.ping_regexp = "bytes from" # TODO this regexp is only for freebsd at the moment; not sure about other platforms # TODO 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
def __init__(self, location, caller): Monitor.__init__(self, location, caller) # create data lists self.rainData = [] self.tempData = [] self.timeData = [] # set up window and main plot self.graphRoot = Tk() self.graphRoot.title('Weather Information Graph for ' + self.location.getName()) self.fig = Figure(figsize=(5, 5), dpi=100) self.fig.suptitle('Weather Information Graph for ' + self.location.getName()) # create axis self.axis = self.fig.add_subplot(111) # add plot lines to the axis self.tempLine = self.axis.plot(self.timeData, self.tempData) self.rainLine = self.axis.plot(self.timeData, self.rainData) # create canvas object self.canvas = FigureCanvasTkAgg(self.fig, self.graphRoot) self.formatAxis() self.showCanvas()
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(" ")
def __init__(self): Monitor.__init__(self) self.is_android = False self.service_context = None self.__test_android() # self.ws_dissector_path = "ws_dissector" self.ws_dissector_path = None self.libs_path = None if self.is_android: libs_path = self.__get_libs_path() ws_dissector_path = os.path.join(libs_path, "android_pie_ws_dissector") self.libs_path = libs_path self.ws_dissector_path = ws_dissector_path prefs = { "ws_dissect_executable_path": os.path.join( libs_path, "android_pie_ws_dissector"), "libwireshark_path": libs_path} else: prefs = {} print prefs DMLogPacket.init(prefs) self._type_names = []
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
def __init__(self): """ Configure this class with user preferences. This method should be called before any actual decoding. """ Monitor.__init__(self) self._fifo_path = self.TMP_FIFO_FILE self._input_dir = os.path.join(get_cache_dir(), "mi2log") self._log_cut_size = 0.5 # change size to 1.0 M # self._skip_decoding = False self._type_names = [] self._last_diag_revealer_ts = None """ Exec/lib initialization path """ # self._executable_path = "/system/bin/diag_revealer" # prefs={"ws_dissect_executable_path": "/system/bin/android_pie_ws_dissector", # "libwireshark_path": "/system/lib"} libs_path = os.path.join(get_files_dir(), "data") # libs_path = "./data" self._executable_path = os.path.join(libs_path, "diag_revealer") prefs = { "ws_dissect_executable_path": os.path.join(libs_path, "android_pie_ws_dissector"), "libwireshark_path": libs_path } DMLogPacket.init(prefs) # Initialize Wireshark dissector
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
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
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) self.result_regexp_text = "" self.result_regexp = None self.result_max = None self.description = None self.command_output = "" if 'result_regexp' in config_options: self.result_regexp_text = config_options["result_regexp"] self.result_regexp = re.compile(self.result_regexp_text) elif 'result_max' in config_options: self.result_max = int(config_options["result_max"]) elif 'description' in config_options: self.description = config_options['description'] else: raise RuntimeError("Required configuration fields missing") try: command = config_options["command"].split(" ") except: raise RuntimeError("Required configuration fields missing") if command == "": raise RuntimeError("missing command") self.command = command
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()
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()
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")
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="")
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) try: self.max_length = int(config_options["max_length"]) except: raise RuntimeError("Required configuration field 'max_length' missing or not an integer") if not (self.max_length > 0): raise RuntimeError("'max_length' must be >= 1") if "path" in config_options: self.path = config_options["path"]
def __init__(self, location, root, caller): Monitor.__init__(self, location, caller) self.frame = Frame(root) self.frame.pack(side=TOP, anchor=NW) # 'declare' all text information (labels) self.temperatureLabel = None self.rainfallLabel = None self.datetimestampLabel = None self.packData()
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) try: self.max_length = int(config_options["max_length"]) except: raise RuntimeError( "Required configuration field 'max_length' missing or not an integer" ) if not (self.max_length > 0): raise RuntimeError("'max_length' must be >= 1") if "path" in config_options: self.path = config_options["path"]
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
def __init__(self, config=None): Monitor.__init__(self, config) # Map of process types. self._ptypes = self._config.get(u'process_types', {}) # Process type to map otherwise unmapped processes to. self._ptype_unassigned = self._config.get(u'process_type_unassigned', u'unassigned') # Filter processes by these types. filter_ptypes = self._config.get(u'filter_process_types', None) self._filter_ptypes = set(filter_ptypes) if filter_ptypes else None
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'])
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.certfile = certfile self.keyfile = keyfile if not https_handler_available: print "Warning: HTTPS client options specified but urllib2.HTTPSHandler is not available!" print "Are you missing SSL support?" raise RuntimeError('Cannot continue without SSL support') # optional - for HTTPS hostname verification (self signed certificates) self.verify_hostname = True if 'verify_hostname' in config_options: if config_options["verify_hostname"].lower() == "false": self.verify_hostname = False self.url = url if regexp != "": self.regexp = re.compile(regexp) self.regexp_text = regexp self.allowed_codes = allowed_codes self.username = config_options.get('username') self.password = config_options.get('password')
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.certfile = certfile self.keyfile = keyfile if not https_handler_available: print "Warning: HTTPS client options specified but urllib2.HTTPSHandler is not available!" print "Are you missing SSL support?" raise RuntimeError('Cannot continue without SSL support') # optional - for HTTPS hostname verification (self signed certificates) self.verify_hostname = True if 'verify_hostname' in config_options: if config_options["verify_hostname"].lower() == "false": self.verify_hostname = False self.url = url if regexp != "": self.regexp = re.compile(regexp) self.regexp_text = regexp self.allowed_codes = allowed_codes self.request_timeout = int(config_options.get('timeout')) if 'timeout' in config_options else 5 self.username = config_options.get('username') self.password = config_options.get('password')
def __init__(self, name, config_options): """Constructor""" Monitor.__init__(self, name, config_options) try: host = config_options["host"] port = int(config_options["port"]) except: raise RuntimeError("Required configuration fields missing") if host == "": raise RuntimeError("missing hostname") if port == "" or port <= 0: raise RuntimeError("missing or invalid port number") self.host = host self.port = port
def __init__(self, name, config_options): if not self.is_windows(True): raise RuntimeError("DHCPScope monitor requires a Windows platform.") Monitor.__init__(self, name, config_options) try: self.max_used = int(config_options["max_used"]) except: raise RuntimeError("Required configuration field 'max_used' missing or not an integer") if not (self.max_used > 0): raise RuntimeError("max_used must be >= 1") try: self.scope = config_options["scope"] except: raise RuntimeError("Required configuration field 'scope' missing")
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) if self.is_windows(allow_cygwin=False): self.use_statvfs = False if not win32_available: raise RuntimeError("win32api is not available, but is needed for DiskSpace monitor.") else: self.use_statvfs = True try: partition = config_options["partition"] limit = config_options["limit"] except: raise RuntimeError("Required configuration fields missing") self.partition = partition self.limit = self._size_string_to_bytes(limit)
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 = config_options["min_fail"] except: pass self.min_fail = min_fail self.monitors = monitors self.m = -1 self.mt = None
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
def __init__(self, name, config_options): if not self.is_windows(True): raise RuntimeError( "DHCPScope monitor requires a Windows platform.") Monitor.__init__(self, name, config_options) try: self.max_used = int(config_options["max_used"]) except: raise RuntimeError( "Required configuration field 'max_used' missing or not an integer" ) if not (self.max_used > 0): raise RuntimeError("max_used must be >= 1") try: self.scope = config_options["scope"] except: raise RuntimeError("Required configuration field 'scope' missing")
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 = max(int(config_options["min_fail"]), 1) except: print("could not parse min_fail. Ignoring...") pass self.min_fail = min_fail self.monitors = monitors self.m = -1 self.mt = None
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) self.result_regexp_text = "" self.result_regexp = None self.result_max = None if 'result_regexp' in config_options: self.result_regexp_text = config_options["result_regexp"] self.result_regexp = re.compile(self.result_regexp_text) elif 'result_max' in config_options: self.result_max = int(config_options["result_max"]) try: command = config_options["command"].split(" ") except: raise RuntimeError("Required configuration fields missing") if command == "": raise RuntimeError("missing command") self.command = command
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()
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 config_options.has_key("regexp"): regexp = config_options["regexp"] else: regexp = "" if config_options.has_key("allowed_codes"): allowed_codes = [int(x.strip()) for x in config_options["allowed_codes"].split(",")] else: allowed_codes = [] self.url = url if regexp != "": self.regexp = re.compile(regexp) self.regexp_text = regexp self.allowed_codes = allowed_codes
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) self.result_regexp_text = "" self.result_regexp = None self.result_max = None if 'result_regexp' in config_options: self.result_regexp_text = config_options["result_regexp"] self.result_regexp = re.compile(self.result_regexp_text) elif 'result_max' in config_options: self.result_max = int(config_options["result_max"]) try: # command = config_options["command"].split(" ") command = shlex.split(config_options["command"]) except: raise RuntimeError("Required configuration fields missing or invalid") if command is None or len(command) == 0: raise RuntimeError("missing command") self.command = command
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()
def __init__(self, config=None): Monitor.__init__(self, config) self._storage = self._config.get(u'storage', []) # flat list of block devices # self._devices = [] for subsystem in self._storage: for device, _ in subsystem['devices']: self._devices.append(device) # map indexed by device holding last raw (cumulative) values self._last = {} # map indexed by device holding last values (since previous sample) self._values = {} for device in self._devices: self._last[device] = None self._values[device] = None
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) try: if 'maxage' in config_options: maxage = int(config_options["maxage"]) self.maxage = maxage except: raise RuntimeError("Maxage missing or not an integer (number of seconds)") try: if 'minsize' in config_options: minsize = self._size_string_to_bytes(config_options["minsize"]) self.minsize = minsize except: raise RuntimeError("Minsize missing or not an integer (number of bytes") try: filename = config_options["filename"] except: raise RuntimeError("Filename missing") self.filename = filename
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) if self.is_windows(allow_cygwin=False): raise RuntimeError("loadavg monitor does not support Windows") if 'which' in config_options: try: which = int(config_options["which"]) except: raise RuntimeError("value of 'which' is not an int") if which < 0: raise RuntimeError("value of 'which' is too low") if which > 2: raise RuntimeError("value of 'which' is too high") self.which = which if 'max' in config_options: try: max = float(config_options["max"]) except: raise RuntimeError("value of 'max' is not a float") if max <= 0: raise RuntimeError("value of 'max' is too low") self.max = max
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 = [] self.url = url if regexp != "": self.regexp = re.compile(regexp) self.regexp_text = regexp self.allowed_codes = allowed_codes
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
def __init__(self, config, **args): mainrunpath = Monitor.mainrunpath Monitor.__init__(self, config, **args) self.defjmxport = 0 try: javahome = os.environ["JAVA_HOME"] except KeyError: javahome = "" self.javahome = self.getconfig("javahome", default=javahome) self.user = self.getconfig("user", default="root") self.xmx = self.getconfig("xmx", default="") self.MBean = self.getconfig("MBean", default="") self.service = self.getconfig("service", default="") self.jmxport = self.getconfig("jmxport", default=[]) metrics = self.getconfig("metrics", default="").split(",") self.metrics = [metric.strip() for metric in metrics] self.metrics = "|".join(self.metrics) self.jmx = os.path.join(mainrunpath, "external/jmx-1.0.jar")
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) try: service_name = config_options["service"] except: raise RuntimeError("Required configuration fields missing") if 'state' in config_options: want_state = config_options["state"] else: want_state = "RUNNING" if 'host' in config_options: host = config_options["host"] else: host = "." if service_name == "": raise RuntimeError("missing service name") if want_state not in ["RUNNING", "STOPPED"]: raise RuntimeError("invalid state") self.service_name = service_name self.want_state = want_state self.host = host
def __init__(self, config=None): Monitor.__init__(self, config)
def __init__(self, config, **args): Monitor.__init__(self, config, **args)
def __init__(self, name, config_options): Monitor.__init__(self, name, config_options) if 'path' in config_options: self.path = config_options["path"]