基于python的分布式扫描器_基于python的watchy分布式系统

Watchy 是一个分布式的系统,用于监控应用程序和服务器。该系统非常简单和易于管理。Watchy 提供一个分布式的架构和每个服务器之间守护进程的通讯,通过 UDP 获取不同服务器上的数据并在同一个面板上显示。

工作原理

Watchy 使用应用/事件驱动模型,如下图所示:

而且整个系统是脚本化的,可通过 Python 或者 C/C++ 来进行操作。但首先要启动服务器:

$ /usr/local/bin/watchy.py --helpUsage: watchy.py [options]Options: -h, --help show this help message and exit -v, --version Print version -c CONFIG, --config=CONFIG Config file location -F, --fork Fork as daemon

然后通过下列命令运行服务器

$ /usr/local/bin/watchy.py -c /etc/watchy/example-watchy.cfg WATCHY INFO - Starting StatsAggregator on 0.0.0.0:7878WATCHY INFO - Starting Async Backend handlerWATCHY INFO - WSGIServer:[gevent] starting http://0.0.0.0:8787/...

现在可以启动监控成员

>>> import pywatchy# hostname and port of watchy server>>> daemon = pywatchy.WatchyDaemon ('localhost', 7878) # Creates or attaches to existing daemon on the server >>> daemon.watchHost ('hostname')# tell the daemon to watch the host server for statistics and post under specified key ('hostname')

启动和停止进程:

>>> daemon.watchPid ('watchyserver', 14293) # watch the python web app>>> daemon.postMessage ('test', 'Hello World')>>> daemon.stopWatchPid (14293) # stop watching in

这些操作都是实时而动态的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值