Can not take jstat metrics using bash as Sensu plugin Can not take jstat metrics using bash as Sensu plugin shell shell

Can not take jstat metrics using bash as Sensu plugin


I'm not a Java or Sensu user, but I can guess what happens.

Most likely, sensu-client runs your script as a user different from the one you use when testing manually, which doesn't have permissions to "attach" (whatever that means) to your jvm instances.

To verify this you can add invocation of "whoami" to your script, run it from sensu-client again, see what user it runs your script under and, if it is different, try to run your script as that user.


Yes you're right sensu runs all script as sensu user. To use jstat you have to add sensu to a sudoers.

just add file /etc/sudoers.d/sensu

Example:

Defaults:sensu !requiretty

Defaults:sensu secure_path = /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

sensu ALL = NOPASSWD: /etc/sensu/plugins/jsat-metrics.rb