sensu-plugins / sensu-plugins-sensu

This plugin provides monitoring and metrics for Sensu.
http://sensu-plugins.io
MIT License
12 stars 35 forks source link

api.json settings not found #58

Closed oddboy closed 6 years ago

oddboy commented 6 years ago

Hi,

I'm fairly new to sensu, and moving some checks over from nagios. I wanted to be able to purge stale check results so this plugin looked awesome.

However, when I run it, I get an error "Check failed to run: api.json settings not found.

Here's the complete text:

[root@linux4 bin]# ./check-stale-results.rb -c 10 -w 5 -s 1d Check failed to run: api.json settings not found., ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-3.0.0/bin/check-stale-results.rb:72:in api_request'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-3.0.0/bin/check-stale-results.rb:87:inresults'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-3.0.0/bin/check-stale-results.rb:52:in initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.5.0/lib/sensu-plugin/cli.rb:56:innew'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.5.0/lib/sensu-plugin/cli.rb:56:in `block in '"]

I'm thinking that I need a json file in /etc/sensu/conf.d, but I have no idea what should be in it. Google didn't help much.

I'm pretty handy, though ruby isn't my first language.

If anyone has some hints, I'd sure appreciate it!

Thanks!

J

majormoses commented 6 years ago

That sounds like you dont have a key anywhere defined with api.settings the error message is not great and should probably say something along the lines of:

unless settings.key?('api')
  raise 'api.json key in settings is not found. Define it in a json config `/etc/sensu/conf.d` or in any other config file that sensu imports'
end
majormoses commented 6 years ago

Its usually defined in /etc/sensu/config.json and should look something like this:

{
  "api": {
    "host": "localhost",
    "bind": "0.0.0.0",
    "port": 4567
  }
}

Documentation: https://docs.sensu.io/sensu-core/1.4/platforms/sensu-on-ubuntu-debian/#example-data-store-configuration

majormoses commented 6 years ago

I have opened #59 to improve the error message around this.

majormoses commented 6 years ago

released: https://rubygems.org/gems/sensu-plugins-sensu/versions/4.0.0