mperham / inspeqtor

Monitor your application infrastructure!
GNU General Public License v3.0
1.66k stars 72 forks source link

inspeqtor is trying to use upstart rather than systemd #135

Closed kernow closed 7 years ago

kernow commented 7 years ago

Hi,

I'm running ubuntu 16.04.1 LTS and want to monitor nginx just to ensure the process is running and a memory usage check. In my nginx.inq file I have:

check service nginx
  if memory:rss > 100m for 4 cycles then alert

The output of inspeqtorctl status is:

Inspeqtor 1.0.1, uptime: 9m1.955684371s, pid: 9654

Host: xxx
  cpu                                 0.4%           
  cpu:iowait                          0.2%           
  cpu:steal                           0.1%           
  cpu:system                          0.1%           
  cpu:user                            0.1%           
  disk:/                              30.0%           90%
  load:1                              0.00           
  load:15                             0.00           
  load:5                              0.00            10
  swap                                100.0%         

Service: nginx [Unknown/0]
  cpu:system                          0.0%           
  cpu:total_system                    0.0%           
  cpu:total_user                      0.0%           
  cpu:user                            0.0%           
  memory:rss                          -0.00m          100m

In the log file I can see:

Inspeqtor 1.0.1
Copyright © 2016 Contributed Systems LLC
Licensed under the GNU Public License 3.0
Want more? Upgrade to Inspeqtor Pro for more features and support.
See http://contribsys.com/inspeqtor for details.
I 2016-12-09T12:45:02.256621Z 9654 Detected upstart in /etc/init
I 2016-12-09T12:45:02.256890Z 9654 Detected systemd in /etc/systemd
I 2016-12-09T12:45:02.257138Z 9654 Detected init.d in /etc/init.d/
D 2016-12-09T12:45:02.258989Z 9654 Parsing config in /etc/inspeqtor/services.d
D 2016-12-09T12:45:02.259452Z 9654 Watching memory:rss
D 2016-12-09T12:45:02.259629Z 9654 Starting command socket
D 2016-12-09T12:45:02.266760Z 9654 Starting main run loop
I 2016-12-09T12:45:02.267135Z 9654 Expose now available at port 4677
D 2016-12-09T12:45:02.267392Z 9654 Executing initctl [initctl status nginx]
W 2016-12-09T12:45:02.267589Z 9654 upstart/nginx: exec: "initctl": executable file not found in $PATH
D 2016-12-09T12:45:02.268039Z 9654 Executing /bin/df [df -P]
D 2016-12-09T12:45:02.273911Z 9654 Collection complete in 6.18323ms
D 2016-12-09T12:45:02.274209Z 9654 nginx is Unknown, skipping...
D 2016-12-09T12:45:17.274895Z 9654 Executing /bin/df [df -P]
D 2016-12-09T12:45:17.276559Z 9654 Collection complete in 1.994799ms
D 2016-12-09T12:45:17.276812Z 9654 nginx is Unknown, skipping...
D 2016-12-09T12:45:32.277513Z 9654 Executing /bin/df [df -P]
D 2016-12-09T12:45:32.279272Z 9654 Collection complete in 2.077212ms
D 2016-12-09T12:45:32.279521Z 9654 nginx is Unknown, skipping...
D 2016-12-09T12:45:47.280220Z 9654 Executing /bin/df [df -P]
D 2016-12-09T12:45:47.281888Z 9654 Collection complete in 1.987775ms
D 2016-12-09T12:45:47.282125Z 9654 nginx is Unknown, skipping...

This shows that inspeqtor is trying to use upstart to monitor the nginx process. However upstart is not installed on the system and systemd is used. I couldn't find any way to configure inspeqtor to use systemd. Is there a way to do this, or some kind of workaround?

Also does inspeqtor need better detection, should the existence of /etc/init be an indicator that the system uses upstart or even has it installed? I should think lots of packages install startup scripts in all locations.

mperham commented 7 years ago

inspeqtor queries systemd to see if it knows of the service using systemctl show -p MainPID nginx. If that does not return a valid PID, you'll need to investigate and determine why.

mperham commented 7 years ago

Oh I see, if you have a service with the same name in both Upstart and Systemd, Inspeqtor has no way of telling which one to use. You'll need to remove the /etc/init/nginx.conf.

felixbuenemann commented 5 years ago

This is still an issue with Inspeqtor 2.0.0 and the official Passenger Ubuntu packages on Xenial.

I added a diversion to prevent the file from being restored by an update to the nginx-common package:

dpkg-divert --divert /etc/init/nginx.conf.disabled --rename /etc/init/nginx.conf