nagios
nagios copied to clipboard
systemd service should match configured command_file location
Cookbook version
Latest
Platform Details
CentOS 7
Scenario:
The nagios command_file is partially managed via the packaged systemd service
> grep cmd /usr/lib/systemd/system/nagios.service
ExecStopPost=/usr/bin/rm -f /var/spool/nagios/cmd/nagios.cmd
When a different command_file location is specified in the cookbook this management will break. Resulting in a broken command_file after a nagios restart.
Steps to Reproduce:
echo '{ "nagios": { "conf": { "command_file": "/var/log/nagios/rw/nagios.cmd" } } }' | sudo chef-client -j /dev/stdin
systemctl restart nagios
/usr/lib64/nagios/plugins/eventhandlers/nagios_command STOP_EXECUTING_SVC_CHECKS
Expected Result:
A command arriving at the running nagios server
Actual Result:
Write blocks, because the command_file is broken
Possible solution
directory '/etc/systemd/system/nagios.service.d/'
file '/etc/systemd/system/nagios.service.d/command_file.conf' do
content "[Service]\nExecStopPost=/usr/bin/rm -f #{node['nagios']['conf']['command_file']}"
mode 0644
notifies :run, 'execute[reload_systemd_nagios]', :immediately
end
execute 'reload_systemd_nagios' do
command <<-EOF
systemctl daemon-reload
EOF
action :nothing
end
Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.