sensu-plugins / sensu-plugin

A framework for writing Sensu plugins & handlers with Ruby.
http://sensuapp.org
MIT License
126 stars 117 forks source link

Default API host and port to 127.0.0.1:4567 #139

Closed cwjohnston closed 8 years ago

cwjohnston commented 8 years ago

Description

This change defaults the configuration for the API to { "host": "127.0.0.1", "port": 4567 } when neither the SENSU_API_URL environment variable is set nor an api configuration scope is defined in the loaded Sensu settings. Prior to this change, undefined api host and port attributes would raise an exception when a plugin attempts to make requests against the Sensu API.

Motivation and Context

This change is intended as a convenience for users running the API on same compute instance as their Sensu server (as is the behavior under Sensu Enterprise). Closes #95.

How Has This Been Tested?

Manually tested in local environment.

Types of changes

With this change, configurations which previously reported the error "api.json settings not found" will now attempt to connect to the api on 127.0.0.1:4567. If the API is not listening on this ip and port combination, connection errors will bubble up from Net::HTTP instead. This will likely take longer than simply raising an exception.

cwjohnston commented 8 years ago

I believe this may close #90 as well.

portertech commented 8 years ago

Let's clean up api_settings(), perhaps we should do something like https://gist.github.com/portertech/77ecd66f88925d163576c9da593a0013

cwjohnston commented 8 years ago

@portertech I've updated the PR per your suggestion

cwjohnston commented 8 years ago

@portertech ready again

portertech commented 8 years ago

1397