【问题标题】:Is there a way to list process arguments as well using monit有没有办法使用monit列出进程参数
【发布时间】:2017-10-07 22:47:16
【问题描述】:

我在 Ubuntu 16.04 上设置了监视器。

sudo monit --version
This is Monit version 5.16
Built with ssl, with pam and with large files

对于给定的进程,它目前在下面列出:

  status                            Running
  monitoring status                 Monitored
  pid                               8724
  parent pid                        8691
  uid                               0
  effective uid                     0
  gid                               0
  uptime                            6d 23h 36m 
  threads                           7
  children                          0
  memory                            190.6 MB
  memory total                      190.6 MB
  memory percent                    19.2%
  memory percent total              19.2%
  cpu percent                       6.8%
  cpu percent total                 6.8%
  data collected                    Sat, 07 Oct 2017 22:41:49

我的问题是,有没有办法也可以在此列表中列出流程参数?基本上,我不仅想监控正常运行时间、负载等矩阵,还想监控进程调用和运行的参数是什么?是否有任何其他替代方法可以提供类似的基于 json 的响应?

谢谢。

【问题讨论】:

标签: linux process monit


【解决方案1】:

有一种方法可以做你想做的事。在任何基于 Linux 的系统上,您都可以使用:

xargs -0 < /proc/<pid>/cmdline

确保将 &lt;pid&gt; 替换为您的进程 pid。该命令将显示启动您插入该路径的pid 的命令,以及args 和all。您甚至可以制作一个 shell 脚本来运行 monit 并从输出中解析 pid 部分并将其用于 xargs。

【讨论】:

  • 我知道我什至可以使用ps -ef。我的问题是特定于 monit 和类似工具的。基本上,我不想每次都登录机器。只需通过外部 API 进行监控。
  • 我可以为你写一个 monit 的包装器,如果你愿意,它会显示带有常规 monit 内容的启动命令。它可能在 python 中。
  • 需要什么?
  • 不需要太多。它可以接收 pid 参数,也可以解析 pid 的 monit 输出,或两者兼而有之,标志覆盖解析。它还可以将任何其他非 pid 参数/标志传递给 monit 命令。
  • 那么,monit http 页面上的输出是否可以作为 xml 使用? (端口 2812)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-23
  • 2014-05-17
  • 1970-01-01
  • 2011-01-03
  • 2010-12-10
  • 1970-01-01
  • 2016-11-06
相关资源
最近更新 更多