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 这些操作都是实时而动态的. |