单个服务的正常运行时间

单个服务的正常运行时间

我在生产服务器上运行多个 unicorn 进程。现在我想检查我的服务的单个服务正常运行时间。例如,如果任何 unicorn 进程自动重新启动,它应该开始记录其正常运行时间。通过这种方式,我想计算自上次服务以来的正常运行时间。注意:这里我不是在谈论服务器正常运行时间,可以使用以下命令start/restart/reload 了解服务器正常运行时间。uptime

$ uptime
 19:11:25 up 2 days, 21:28,  1 user,  load average: 0.11, 0.09, 0.11

我想知道单个服务的正常运行时间,例如 nginx 的正常运行时间

有可能通过某种方式知道吗?

答案1

监控非常适合这个。

monit status命令清楚地显示了这些信息:

Process 'ssh'
  status                            Running
  monitoring status                 Monitored
  pid                               11239
  parent pid                        1
  uid                               0
  effective uid                     0
  gid                               0
  uptime                            32d 5h 1m
  children                          230
  memory                            1.2 MB
  memory total                      2.0 GB
  memory percent                    0.0%
  memory percent total              0.6%
  cpu percent                       0.0%
  cpu percent total                 0.1%
  data collected                    Mon, 09 Jan 2017 11:34:08

Process 'cron'
  status                            Running
  monitoring status                 Monitored
  pid                               669744
  parent pid                        1
  uid                               0
  effective uid                     0
  gid                               0
  uptime                            1m
  children                          0
  memory                            1.2 MB
  memory total                      1.2 MB
  memory percent                    0.0%
  memory percent total              0.0%
  cpu percent                       0.0%
  cpu percent total                 0.0%
  data collected                    Mon, 09 Jan 2017 11:34:08

Process 'newrelic'
  status                            Running
  monitoring status                 Monitored
  pid                               11377
  parent pid                        1
  uid                               495
  effective uid                     495
  gid                               495
  uptime                            32d 5h 1m
  children                          1
  memory                            500.0 kB
  memory total                      8.3 MB
  memory percent                    0.0%
  memory percent total              0.0%
  cpu percent                       0.0%
  cpu percent total                 0.0%
  data collected                    Mon, 09 Jan 2017 11:34:08

相关内容