sensu / sensu-chef

Sensu Chef cookbook.
https://supermarket.chef.io/cookbooks/sensu
Apache License 2.0
221 stars 280 forks source link

Add SENSU_LOADED_TEMPFILE_DIR to Sensu config. #487

Closed sean-kang closed 8 years ago

sean-kang commented 8 years ago

This adds "export SENSU_LOADED_TEMPFILE_DIR=some_dir" to /etc/default/sensu.

Description

In some linux distros and hardened systems, /tmp directory is regularly cleaned. When Sensu loses files such as "sensu_server_loaded_files" in /tmp directory, its handlers will fail with the following error.

{"timestamp":"2016-08-21T11:38:46.043506+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-hipchat.rb","name":"hipchat"},"output":["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/utils.rb:7:in read': No such file or directory @ rb_sysopen - /tmp/sensu_server_loaded_files (Errno::ENOENT)\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/utils.rb:7:inconfig_files'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/utils.rb:20:in settings'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-handler.rb:104:infilter_repeated'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-handler.rb:30:in filter'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-handler.rb:54:inblock in class:Handler'\n"]}

To resolve the problem, an environment variable SENSU_LOADED_TEMPFILE_DIR was introduced to Sensu by the following commit.

https://github.com/sensu/sensu-settings/commit/c21d471a40ce9c1991f8a38d19bfe28efd387703

This pull request is to add a new attribute that sets up the environment variable in Sensu config file.

Motivation and Context

https://github.com/sensu/sensu-chef/issues/486

How Has This Been Tested?

I have tested the following suites in test-kitchen.

majormoses commented 8 years ago

does the package defaults write this out or does it rely on something internal in sensu to have /tmp as default? if not thee default is already going to /tmp and I think that the template should only include it if the chef attribute is specified.

amdprophet commented 8 years ago

@majormoses is correct - it's best if the template only sets the option if the attribute is set. We may be changing the default tempfile directory in one of the upcoming releases. It's a possibility that the location may differ depending on the host platform.

Aside from adjusting that, 👍 on this change.

majormoses commented 8 years ago

LGTM

cwjohnston commented 8 years ago

My only question here is whether the export is necessary. I think we can accept this change and then remove the export later if needed.

cwjohnston commented 8 years ago

Closes #486