使用Python进行简单的远程过程监控

toh*_*ter 5 python linux monitoring

我想编写一个python脚本来对linux服务器上运行的远程进程执行一些非常简单的"无代理"监视.

它将在伪代码中执行以下任务:

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
Run Code Online (Sandbox Code Playgroud)

一种方法是在子进程中使用python调用shell脚本并解析它们的输出.这似乎效率很低.有没有更好的方法通过python库来做到这一点?

通过这里和其他地方的研究我能找到的是:

  • psutil - 看起来它没有进行远程监控,因此我必须在远程计算机上运行代理以通过RPC报告统计信息.
  • pymeter - 我必须编写自己的插件来监控特定的远程服务.
  • stackoverflow#4546492 - 一些有用的链接,但海报正在寻找一个不同的解决方案.

谢谢,请放轻松我,这是我的第一个问题:-)