juju / charm-helpers

Apache License 2.0
18 stars 127 forks source link

charmsupport nrpe #50

Open Boolman opened 6 years ago

Boolman commented 6 years ago

https://github.com/juju/charm-helpers/blob/v0.18.2/charmhelpers/contrib/charmsupport/nrpe.py#L164-L177

What is the purpose of this function? This is just weird.

what this does, is to force the user to add all files to one of the directories in search_path. If the file does not exist, check_cmd will be empty, nrpe will restart and break nrpe on this unit.

you cannot for example use 'sudo /usr/lib/nagios/plugins/check_something' as check_cmd, since sudo is not in the correct path. a workaround for this, is to create a wrapper which only function is to call 'sudo /usr/lib/nagios/plugins/check_something'

if one still need to micromanage the user, maybe extend the search_path to os.environ['PATH'] and if the command is not found, dont create the file with an empty check_cmd, which breaks nrpe. and be sure to log this action

tbaumann commented 6 years ago

I would suggest adding the use of sudo inside the check_something script.

And also keep in mind to keep a file /etc/sudoers.d/ in sync permitting the use of the used commands for user nagios.