aswen / nagios-plugins

Scripts and plugins for Nagios
32 stars 49 forks source link

last_run_summary.yaml not readable #28

Open Rocco83 opened 8 years ago

Rocco83 commented 8 years ago

Hi,

running the script in debug mode it fail with

nagios@x:~$ bash -x /usr/local/custom/nagios/nagios-plugins-aswen/check_puppet_agent -w 3600 -c 7200 -s /var/lib/puppet/state/last_run_summary.yaml -d 0
[...]
++ sudo /usr/bin/puppet config print agent_disabled_lockfile
+ agent_disabled_lockfile=/var/lib/puppet/state/agent_disabled.lock
+ '[' -f /var/lib/puppet/state/agent_disabled.lock ']'
+ '[' -z /var/lib/puppet/state/last_run_summary.yaml ']'
+ '[' -s /var/lib/puppet/state/last_run_summary.yaml -a -r /var/lib/puppet/state/last_run_summary.yaml ']'
+ result 1
+ case $1 in
+ echo 'UNKNOWN: last_run_summary.yaml not found, not readable or incomplete'
UNKNOWN: last_run_summary.yaml not found, not readable or incomplete
+ rc=3
+ exit 3
nagios@x:~$ 

The reason why: https://tickets.puppetlabs.com/browse/PUP-6936

The current stupid resolution: chmox +x /var/lib/puppet

Feel free to suggest way to close it... I think that this should be closed on puppet side, and suggest a workaround like the one above.

(Updated by @aswen: put console output in code block)

aswen commented 7 years ago

@Rocco83 Thanks for your feedback. I agree that bug should be fixed. In the meanwhile you can use Puppet to change the file to o+x (That's how I solved it). Another approach might be to use sudo to verify if the file exists, but that feels a bit 'heavy' too.

edrude commented 7 years ago

Using puppet agent 4.9.2 and for me the last_run_summary.yaml file is being created as world readable. Maybe they fixed this?

aswen commented 7 years ago

@erude1 Thanks for that headsup. https://tickets.puppetlabs.com/browse/PUP-6936 is still open though. So I don't know what's the reason you have a world readable last_run_summary.yaml file.

edrude commented 7 years ago

I think I misunderstood earlier. Looks like this issue is referencing /var/lib/puppet/ and /opt/puppetlabs/puppet/cache/ (my case) directories that are not world readable instead of the last_run_summary.yaml file.

I originally had this issue as well. My fix/workaround was to set "lastrunfile = /var/log/puppetlabs/last_run_summary.yaml" in the [agent] section of puppet.conf. Love the way your plugin automatically detects that by the way.

For me, Puppet 4.9.2 and CentOS7, /var/log/puppetlabs/ is world executable. I took this approach in favor of modifying /opt/puppetlabs/puppet/cache/ permissions because my puppet agent kept setting the permissions back on the cache directory.