分布式監控系統:Watchy
Watchy 是一個分布式的系統,用于監控應用程序和服務器。該系統非常簡單和易于管理。Watchy 提供一個分布式的架構和每個服務器之間守護進程的通訊,通過 UDP 獲取不懂服務器上的數據并在同一個面板上顯示。
工作原理
Watchy 使用應用/事件驅動模型,如下圖所示:
而且整個系統是腳本化的,可通過 Python 或者 C/C++ 來進行操作。但首先要啟動服務器:
$ /usr/local/bin/watchy.py --help Usage: 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:7878 WATCHY INFO - Starting Async Backend handler WATCHY 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
這些操作都是實時而動態的.
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!