Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put nrpe pidfile dirctly into the usual run directory - Fixes #7 #41

Closed
wants to merge 1 commit into from

Conversation

5c077yP
Copy link
Contributor

@5c077yP 5c077yP commented Jul 23, 2015

Hey,

this PR tries to fix #7 . As described there , the nrpe daemon can't be reloaded properly, because the pid file was not created. It seems nrpe is not creating the pid file if the directory does not exist. Unfortunately the init script does not fail and so it's not properly reported to the chef run. With this PR the pid file is put directly into the usual run dir (which should always exist) and not in a separated pid directory.

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

Well, the pidfile needs to point to path that appropriate system initscript uses.

Also, in my system, i found that i needed separate dir, because daemon runs as nagios user and that user can not write to /var/run, so i created /var/run/nrpe dir in that system.

@5c077yP
Copy link
Contributor Author

5c077yP commented Aug 5, 2015

which os/distro are you using? i'm using ubuntu 12.04 and only root can write to /var/run. Also nrpe runs as nagios user, but i think it creates the pid file still as root and afterwards does the daemon fork magic.

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

i run pld linux, but no, it fails to reload if using /var/run. the change itself is very old, so i do not have log. but i'm very sure it was during shutdown it was unable to remove pidfile with nagios user

pld-linux/nagios-nrpe@ce845d3
pld-linux/nagios-nrpe@3c30292
pld-linux/nagios-nrpe@6d1e064

@5c077yP
Copy link
Contributor Author

5c077yP commented Aug 5, 2015

ok, maybe it would make sense if the pid_dir is created within the init script? this script at least should run as root, so it will have the privileges to do so?

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

not knowing your system, but seeing the diff, i would say if you stay with /var/run/nagios dir, it should work fine.

because:

  1. /var/run/nagios dir seems to exist, and is likely writable for nagios user
  2. recipe creates nrpe.conf which specifies where nrpe daemon writes the pid

also, recipe may add 'directory "/var/run/nagios"' resource (with proper nagios-writable permissions) if the dir does not exist.

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

looked the PR diff again. you shouldn't modify 'freebsd' case, if you don't know or can test that system!

@5c077yP
Copy link
Contributor Author

5c077yP commented Aug 5, 2015

ahh ok, i'm running this cookbook with the source install method, then the /var/run/nagios does not exist for me. also after any reboot the /var/run directory is cleaned again. so even if chef creates the directory , i must ensure it runs after a reboot, which is not the case for me.

ok with the freebsd a totally agree

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

and for the fix for #7, are you sure debian initscript has "reload" action? maybe you need :restart instead?

# service nrpe reload
Usage: /etc/rc.d/init.d/nrpe {start|stop|restart|try-restart|force-reload|status}
# echo $?
3

this is from my system and it lacks reload, because nrpe daemon itself does not handle any signals

@5c077yP
Copy link
Contributor Author

5c077yP commented Aug 5, 2015

hmm so this cookbook provides an init script ... and it also supports the reload command https://github.com/schubergphilis/nrpe/blob/master/templates/default/nagios-nrpe-server.erb#L54

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

i assume you run /var/run as tmpfs and systemd? so you need systemd-tmpfiles configuration so the dir is created at boot.

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

if initscript comes from recipe, you can then mkdir in initscript in 'start' action. more universal than systemd config, i guess.

install -o nagios -g nagios -d /var/run/nagios

@glensc
Copy link
Contributor

glensc commented Aug 5, 2015

oo, it has signals support indeed. but test whether it actually reloads configuration?

# kill -HUP `cat /var/run/nrpe/nrpe.pid`
Aug  5 18:28:04 wintersunset nrpe[6463]: Caught SIGHUP - restarting...
Aug  5 18:28:04 wintersunset nrpe[6463]: Could not open config directory '/etc/nagios/nrpe.d/CVS' for reading.
Aug  5 18:28:04 wintersunset nrpe[6463]: Continuing with errors...
Aug  5 18:28:04 wintersunset nrpe[6463]: Server listening on 192.168.2.23 port 5666.
Aug  5 18:28:04 wintersunset nrpe[6463]: Listening for connections on port 0
Aug  5 18:28:04 wintersunset nrpe[6463]: Allowing connections from: 127.0.0.1

@snkutlu
Copy link
Contributor

snkutlu commented Jul 21, 2016

Hi @5c077yP I am trying to fix the travis issues in this cookbook and going over all open PRs either failed in travis CI or did not even run Travis.

Do you think that this PR is still valid and required?

@5c077yP
Copy link
Contributor Author

5c077yP commented Jul 21, 2016

@snkutlu hmm, this PR is quite some time ago, let me think that through again

@damacus damacus closed this Feb 27, 2018
@damacus
Copy link
Member

damacus commented Feb 27, 2018

If you want to pick this up again, just raise a new PR. 👍

@lock
Copy link

lock bot commented Feb 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

notifying the nrpe service to reload itself does not work correctly
4 participants