Sensu-install missing on docker image

I’m trying to install a required sensu classic plugin that has no corresponding asset in bonsai.

My understanding from the scant documentation is that I should be able to do this with the sensu-install command. Unfortunately that command doesn’t seem to exist on the sensu/sensu:latest docker image.

The docs suggest that I install the sensu-plugins-ruby package, but this also doesn’t seem to exist for alpine. Am I just dead in the water here?

This is the plugin I require:


thx

1 Like

Alright well after 2 (or more) days of messing with this, I’ve packed my sensu “classic” plugin as an asset. In fact I’ve tried 2 different ruby plugins packaged as assets. I’m able to load and attempt to run them but in both cases I get the error below.

kernel_require.rb:55:in `require’: cannot load such file – sensu-handler (LoadError)\n\tfrom /var/cache/sensu/sensu-backend

Hi @billm,

I can definitely appreciate the pain. I’ve been trying to fork that repo and update the code myself, and am planning on doing a bit more on it today to see what I get. I’ll note that with that plugin being a community plugin, there’s a bit that has to happen here to make it work. Sadly, it’s not just enough to repackage it–it’s a 4 year old plugin with no real updates, so there are naturally going to be things that need some attention on it. If I can get it working today, I’d be happy to chat a bit more about what I ended up doing. In the mean time, we’ve seen plenty of other plugins make the leap to be used with Sensu Go–take a look at the plugins on https://bonsai.sensu.io and you’ll see quite a few ruby plugins that have the capability. I’ll keep you updated with what I find.

Thanks dude. Just saw this when I went back to edit out the whiney part of my comment.

Can you recommend a similar go based asset that I might use as a template for re-writing this in go?

I’ve tried adding sensu-plugins/sensu-plugin to the runtime assets and that doesn’t seem to help.

I’m sorry but I’m not particularly clear on the architecture here, but it seems to me that that’s the plugin which containers the sensu-handler.rb that’s missing.

Hmmmmm…So I wrote a Twilio handler, which may serve as some inspiration https://bonsai.sensu.io/assets/asachs01/sensu-go-twilio-handler . It’s bare bones, but it does the trick.

Oh, and it looks like they have a Golang SDK: https://github.com/plivo/plivo-go

git clone https://github.com/asachs01/sensu-go-twilio-handler.git

ty. I just copy/pasted from the bonsai pg.

it appears that sensu-handler.rb exists in this git repo, but there’s no corresponding bonsai asset?

Yeah, there’s a couple of bits that have to change in the gemspec + a travis config change + adding the bonsai config. It’s honestly not a lot, but there are tests that have to pass before Travis will upload things, and that’s what I’m working through now.

oh cool. on the sensu-plugin repo?

They’re Rubocop stuff. So bundle exec rake default inside the repo will spit out a bunch of stuff and that’s part of what Travis runs when it is building the gem.

Which gem are we talking about here?

Any luck?

I know absolutely nothing about go so I’m going to be way in the weeds here trying to rewrite the handler in go. I’m loath to go down that path at this point. I might have been willing on Monday, but I’ve already wasted 2+ days trying to get the ruby handler to work.

I’m still confused about what needs to happen here. It appears that my new “asset” requires sensu-plugins/sensu-plugin gem but no such asset exists in bonsai? You’re trying to package the existing sensu-plugins/sensu-plugin gem as a bonsai asset, but rubocop is throwing errors and the travis build fails?

Despite the naming, it seems that sensu-plugins/sensu-plugin is not “official”? Is it uncommon? It seems like as a framework for writing custom plugins it must be in use in a number of them.

I’ve tried maybe a dozen different ways of force-including the gem into my project and I get the same error (above) every single time.

Howdy. So I got it packaged up and working via https://bonsai.sensu.io/assets/asachs01/sensu-plugins-plivo. Can you give it a shot? I believe the config files should be able to live in /var/lib/sensu/ and they should get picked up. You can also compare what you’ve done on your fork with what I’ve done in mine, which should give you a better idea of what went into getting the plugin to work.

Thanks for trying, but:

"component":"pipelined","handler":"plivo","level":"info","msg":"event pipe handler executed","namespace":"default","output":"/var/cache/sensu/sensu-backend/a07bcfa3cca17c108e77e00a79d78a2d604ce3a5f1595b6bb535ceb6c7a244add6e0e62b81977be86eac2b94d214e0833fe3c0f0901f9a437efdd12f3e2d2da4/lib/ruby/2.4.0/bundler/gems/sensu-plugins-plivo-4b0b9839c685/bin/handler-plivosms.rb:66:in `handle': undefined method `[]' for nil:NilClass (NoMethodError)\n\tfrom /var/cache/sensu/sensu-backend/a07bcfa3cca17c108e77e00a79d78a2d604ce3a5f1595b6bb535ceb6c7a244add6e0e62b81977be86eac2b94d214e0833fe3c0f0901f9a437efdd12f3e2d2da4/lib/ruby/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-handler.rb:91:in `block in \u003cclass:Handler\u003e'\n","status":1,"time":"2020-01-08T23:32:02Z"}

I put the config in /var/lib/sensu/plivosms_handler.json:

/var/lib/sensu # cat plivosms_handler.json

  "plivosms":{
    "id":"xxxxx",               // auth id
    "token":"xxxxx",     // auth token
    "number":"xxxxx",             // the sms will be sent from this number, include country code
    "recipients":{
      "xxxxx": {
        "subscriptions":[ "web" ],      // subscriptions that should trigger sms
        "checks":[],                    // checks that should trigger sms
        "cutoff": 1                     // 1 for warning, 2 for critical alerts (default is 2)
      },
      "xxxxxx": {
        "subscriptions":[ 'all' ],        // 'all' 
        "checks":[ "mysql-alive" ],
        "cutoff": 2
      },
      "xxxxx": {                    // not specifying "subscriptions" is same as 'all'
        "checks":[ "check_dns", "check_http" ]
      },
      "xxxxx": {                    
        "cutoff": 1                       // "subscriptions" and "checks" are optional, defaults 'all'
      }
    }
  }
}

Hmmmm. I can check it later tonight. Sitting down to dinner w/ the fam. There is one thing you might need to try and that’s appending a flag to your handler command --map_go_event_into_ruby. It’d also be helpful to see a redacted config

Hmm that error seems to indicate a problem with the ruby code itself. looks like we need to test and make sure this works with Sensu-go manually prior to using it as an asset.

Because this plugin exists outside of the sensu-plugins collective it might have some other outstanding issues we aren’t yet familiar with that need to be fixed.

put the config file in the /etc/sensu/conf.d/ and try again.

The default conf location as controlled by the sensu_plugin ruby gem that provides the boilerplate logic still defaults to /etc/sensu/conf.d/ according to my reading.

My reading of the handler-plivosms.rb line 66 in github suggests to me the configuration was not read in as expected. The error you are having reads as the handler code isn’t fault tolerant if the named config is missing from the parsed settings and tries to access attributes from the config object even though it does not exist.