[英]Simple remote process monitoring with Python
I'd like to write a python script to perform some very simple "agentless" monitoring of remote processes running on linux servers. 我想编写一个python脚本来对linux服务器上运行的远程进程执行一些非常简单的“无代理”监视。
It would perform the following tasks, in psuedocode: 它将在伪代码中执行以下任务:
for each remoteIPAddress in listOfIPAddresses:
log into server@remoteIPAddress via ssh
execute the equivalent of a 'ps -ef' command
grep the result to make sure a particular process (by name) is still running
One way to do this is to have python call shell scripts in a subprocess and parse their output. 一种方法是在子进程中使用python调用shell脚本并解析它们的输出。 That seems pretty inefficient. 这似乎效率很低。 Is there a better way to do this via python libraries? 有没有更好的方法通过python库来做到这一点?
All I could find via research here and elsewhere was: 通过这里和其他地方的研究我能找到的是:
Thanks, and please go easy on me, it's my first question :-) 谢谢,请放轻松我,这是我的第一个问题:-)
Fabric库可能是您感兴趣的。
Taking cues from the answers above, I investigated Fabric and found the following presentation particularly interesting/helpful. 从上面的答案中提取线索,我调查了Fabric,发现以下介绍特别有趣/有帮助。 It is an overview of three libraries -- Fabric, Cuisine, and Watchdog -- for server monitoring and administration. 它概述了三个库 - Fabric,Cuisine和Watchdog - 用于服务器监视和管理。 For posterity: 后人:
Using Fabric, Cuisine, and Watchdog for server administration in Python 使用Fabric,Cuisine和Watchdog在Python中进行服务器管理
Why don't you use a dedicated monitoring tool like Nagios ? 你为什么不使用像Nagios这样的专用监控工具? Nagios has agent and agent less monitoring through NRPE plugins and SSH plugins etc. Try it out. Nagios通过NRPE插件和SSH插件等代理和代理监控较少。试试看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.