sensu-plugin-python icon indicating copy to clipboard operation
sensu-plugin-python copied to clipboard

accessing custom plugin settings

Open sufiyanghori opened this issue 7 years ago • 2 comments

In ruby framework, I can create custom settings like,

{
  "my_custom_plugin": {
    "foo": true,
    "bar": false
  }
}

and access them in plugin,

def foo_enabled?
  settings['my_custom_plugin']['foo']
end

how can it be done in python framework?

sufiyanghori avatar Sep 17 '18 22:09 sufiyanghori

Found it in the code. for anyone interested,

import utils from sensu_plugin package,

from sensu_plugin import utils

and access settings using get_settings(),

utils.get_settings()['my_custom_plugin']['foo']

sufiyanghori avatar Sep 17 '18 22:09 sufiyanghori

I'm going to reopen this with the intention of replicating the way this works in Ruby and making the settings available in the plugin base class.

barryorourke avatar Sep 18 '18 07:09 barryorourke