2

I am running multiple unicorn processes on my production server. Now I want to check the individual service uptime of my services. For instance if any unicorn process restart automatically, it should start recording its uptime. By this means I want to calculate what is the uptime of the service since its last start/restart/reload Note: Here I am not talking about the server uptime which can be known by using uptime command like below.

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

I would like to know the uptime of individual service like uptime of nginx

Is it possible to know it somehow?

  • is there a reason this solution will not work? just grep the results for the name of the service you are looking for or the related daemon. stackoverflow.com/questions/5731234/… – Matt Jan 9 '17 at 19:30
  • Check the creation times of the process-id named entries in /proc/. – EEAA Jan 9 '17 at 19:53
3

Monit works great for this.

The monit status command shows this information clearly:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.