本文整理汇总了Python中monitor.Monitor类的典型用法代码示例。如果您正苦于以下问题:Python Monitor类的具体用法?Python Monitor怎么用?Python Monitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Monitor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
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(" ")
开发者ID:NightyLive,项目名称:simplemonitor,代码行数:7,代码来源:service.py
示例2: __init__
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
开发者ID:Nexedi,项目名称:cloudooo,代码行数:7,代码来源:request.py
示例3: __init__
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)
开发者ID:arunsingh,项目名称:simplemonitor,代码行数:33,代码来源:service.py
示例4: test_stop_personal_cloud
def test_stop_personal_cloud(self):
monitor = Monitor(self.personal_cloud)
print "try stop stop"
monitor.start()
# time.sleep(5)
monitor.stop()
开发者ID:2XL,项目名称:rmq_monitor,代码行数:7,代码来源:monitor_test.py
示例5: __init__
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
开发者ID:Seb182,项目名称:cloudooo,代码行数:7,代码来源:memory.py
示例6: __init__
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
开发者ID:NightyLive,项目名称:simplemonitor,代码行数:35,代码来源:network.py
示例7: poll
def poll(self):
"""
Measure current stats value and return new stats.
"""
Monitor.poll(self)
# create new, empty event
#
current = {
# the UTC timestamp when measurement was taken
u'timestamp': utcnow(),
# the effective last period in secods
u'last_period': self._last_period,
}
# FIXME: add ratio of ram usage
with open("/proc/meminfo") as f:
res = f.read()
new = res.split()
new_clean = [x.replace(":", "") for x in new if x != 'kB']
for i in range(0, len(new_clean), 2):
k = u'{}'.format(new_clean[i])
current[k] = int( new_clean[i + 1])
self._last_value = current
return succeed(self._last_value)
开发者ID:oberstet,项目名称:scratchbox,代码行数:29,代码来源:rammonitor.py
示例8: __init__
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
开发者ID:minektur,项目名称:simplemonitor,代码行数:28,代码来源:network.py
示例9: main
def main():
# sleep(5) #added a sleep to avoid "Connection refused" or "404" errors
parser = argparse.ArgumentParser()
parser.add_argument('dir', help='the directory of the example')
args = parser.parse_args()
# locate config file
base_path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)),"..","examples",args.dir,"config"))
config_file = os.path.join(base_path, "sdx_global.cfg")
# locate the monitor's flows configuration file
monitor_flows_file = os.path.join(base_path, "monitor_flows.cfg")
config = Config(config_file)
# start umbrella fabric manager
logger = util.log.getLogger('monitor')
logger.info('init')
try:
with file(monitor_flows_file) as f:
flows = json.load(f)
except IOError:
flows = None
logger.info("No file specified for initial flows.")
logger.info('REFMON client: ' + str(config.refmon["IP"]) + ' ' + str(config.refmon["Port"]))
client = RefMonClient(config.refmon["IP"], config.refmon["Port"], config.refmon["key"])
controller = Monitor(config, flows, client, logger)
logger.info('start')
controller.start()
开发者ID:h2020-endeavour,项目名称:endeavour,代码行数:31,代码来源:mctrl.py
示例10: random_tester
def random_tester():
monitor = Monitor()
while True:
user = random.randint(1,30)
if not monitor.check(str(user)):
print "malicious user detected"
time.sleep(0.05)
开发者ID:lxhuang,项目名称:fetch_url,代码行数:7,代码来源:monitor_test.py
示例11: setup
def setup():
Monitor.get().start();
screen = Gdk.Screen.get_default();
for i in xrange(0, screen.get_n_monitors()):
# setup for each monitor
rect = screen.get_monitor_geometry(i);
config.config_monitor(i, rect);
开发者ID:xinhaoyuan,项目名称:rmdock,代码行数:7,代码来源:entry.py
示例12: __init__
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')
开发者ID:slune,项目名称:server_health,代码行数:7,代码来源:factcheck.py
示例13: update_NET_DESKTOP_GEOMETRY
def update_NET_DESKTOP_GEOMETRY(force=False):
global properties, xinerama
old_geom = properties["_NET_DESKTOP_GEOMETRY"]
old_xinerama = xinerama
time.sleep(1)
properties["_NET_DESKTOP_GEOMETRY"] = ptxcb.XROOT.get_desktop_geometry()
xinerama = ptxcb.connection.xinerama_get_screens()
if old_xinerama != xinerama or force:
if not force and len(old_xinerama) == len(xinerama):
for mon in Workspace.iter_all_monitors():
mid = mon.id
mon.refresh_bounds(
xinerama[mid]["x"], xinerama[mid]["y"], xinerama[mid]["width"], xinerama[mid]["height"]
)
mon.calculate_workarea()
else:
for mon in Workspace.iter_all_monitors():
for tiler in mon.tilers:
tiler.destroy()
for wid in Window.WINDOWS.keys():
Window.remove(wid)
for wsid in Workspace.WORKSPACES.keys():
Monitor.remove(wsid)
Workspace.remove(wsid)
reset_properties()
load_properties()
开发者ID:Excedrin,项目名称:pytyle2,代码行数:33,代码来源:state.py
示例14: __init__
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()
开发者ID:Nexedi,项目名称:cloudooo,代码行数:8,代码来源:sleeping_time.py
示例15: monitor_torrent
def monitor_torrent():
"""
Monitoring remote transmission status
"""
print (green('Monitoring remote transmission status.'))
monitor = Monitor()
monitor.start()
monitor.join()
开发者ID:tim-tang,项目名称:bittorrent-robot,代码行数:8,代码来源:fabfile.py
示例16: callback
def callback(self, ch, method, properties, body):
json_message = self.string_to_json(body)
if int(json_message['heart_rate']) > 110:
monitor = Monitor()
monitor.print_notification(json_message['datetime'], json_message['id'], json_message[
'heart_rate'], 'latidos del corazón', json_message['model'])
time.sleep(1)
ch.basic_ack(delivery_tag=method.delivery_tag)
开发者ID:AlexMtz,项目名称:Estilos-De-Arquitectura-De-Software,代码行数:8,代码来源:procesador_de_ritmo_cardiaco.py
示例17: __init__
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")
开发者ID:arunsingh,项目名称:simplemonitor,代码行数:9,代码来源:host.py
示例18: __init__
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="")
开发者ID:slune,项目名称:server_health,代码行数:10,代码来源:ansiblerun.py
示例19: Bot
class Bot(object):
def __init__(self):
self.settings = config.get()
self.skype = Skype4Py.Skype(Events=self)
self.skype.Attach()
logging.info("Skype Attached.")
self.monitor = Monitor(self.skype, config)
# start the monitor
self.monitor.create()
def generateHelp(self):
msgList = []
msgList.append("{:<15}{:<30}".format("Command", "Description"))
msgList.append("{:-<30}".format(""))
for c in commands.commands:
c = commands.commands[c]
if hasattr(c, 'permissions') and c.permissions == 'admin':
continue
msgList.append("{:<15} {:<30}".format(c.aliases[0], c.doc))
return msgList
def MessageStatus(self, msg, status):
if status in (Skype4Py.cmsSent, Skype4Py.cmsReceived) or len(msg.Body) < 2: return
# ignore itself
# if (msg.FromHandle == self.skype.CurrentUser.Handle): return
# check if it's a command
if msg.Body[0] not in self.settings['prefixes']: return
# get command
cmd = msg.Body.split()[0][1:].lower()
# split args into array
args = [] if len(msg.Body.split()) < 2 else msg.Body.split()[1:]
# generate help
if cmd == 'help':
help = self.generateHelp()
if help:
msg.Chat.SendMessage("\n".join(help))
elif cmd in commands.aliases:
thread = threading.Thread(target=commands.aliases[cmd].execute, args=(msg, self.settings, args))
thread.start()
return
开发者ID:briantanner,项目名称:Grepobot.py,代码行数:53,代码来源:bot.py
示例20: __init__
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
开发者ID:oberstet,项目名称:scratchbox,代码行数:52,代码来源:cpumonitor.py
注:本文中的monitor.Monitor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论