Embedded Ruby and Gems for Plugins and other questions


#1

I’m to the point now where I have a sensu master and several client nodes all communicating properly.

I’d like to start using some plugins from the sensu-community-plugins repo to get some checks going. Here’s my questions.

  1. I’ve set sensu to use embedded ruby from the omnibus package, if I need to install a gem how do I do so on the system since gem and ruby are not globally available? ie. ruby lives at
    /opt/sensu/embedded/bin/ruby and the sensu user has no shell (/bin/false). So how would I install/utilize ruby scripts with gem dependencies and install those gems so that the sensu user can use them on the server/client.

  2. I’m having a hard time wrapping my mind around checks/plugins. For instance I setup the basic memory-check.sh on sensu master and configured the options for -w and -c, I copied the script over to each node and setup a check_memory.json to subscribe to the check. My question is, does the script get run locally on each client and the output sent to master for updating? Or does the script get run on master against each node? I know when I used nagios I had to have the script on the master node and client node and used NRPE to run the script locally on the client node. Does sensu operate similarly?

  3. Handlers. Eventually we are going to integrate pagerduty for all of our alerts, but for now I want to write (or use an existing) simple handler that pipes information to the unit mailtools (mail program). Is there a script for this handler already in the repos? I’d like to start testing out alerts and what not and get notified at least via email until we have pagerduty in play.

Anyways, sorry for all the newb questions, I’m super new to Sensu and while I love it so far the docs are not as detailed as something like Icinga2 or Nagios. Are there any good videos/tutorials/etc that could help me wrap my head around Sensu better?

Thanks for your help in advance!

-James


#2

I'm to the point now where I have a sensu master and several client nodes
all communicating properly.

I'd like to start using some plugins from the sensu-community-plugins repo
to get some checks going. Here's my questions.

I've set sensu to use embedded ruby from the omnibus package, if I need to
install a gem how do I do so on the system since gem and ruby are not
globally available? ie. ruby lives at

/opt/sensu/embedded/bin/ruby and the sensu user has no shell (/bin/false).
So how would I install/utilize ruby scripts with gem dependencies and
install those gems so that the sensu user can use them on the server/client.

In puppet the puppet module provides a sensu-rubygem provider to make
it easy to install gems:

Even though the sensu user has no shell, you will find that it the
system package has all its files owned by root, so just use root?
In other occasions I've used a special fpm to go from sensu-rubygem =>
deb and distribute it that way. Whatever works.

I'm having a hard time wrapping my mind around checks/plugins. For instance
I setup the basic memory-check.sh on sensu master and configured the options
for -w and -c, I copied the script over to each node and setup a
check_memory.json to subscribe to the check. My question is, does the
script get run locally on each client and the output sent to master for
updating? Or does the script get run on master against each node? I know
when I used nagios I had to have the script on the master node and client
node and used NRPE to run the script locally on the client node. Does sensu
operate similarly?

The scripts always run on the client. See the cron example from the docs:
https://sensuapp.org/docs/0.20/getting-started-with-checks#create-the-check-definition-for-cron

The check can be scheduled by the client (a standalone check) or the
master can schedule it (subscription check)

In some sense the Sensu Client *is* the remote execution agent, so it
is kinda like nrpe. But the method of interaction is over a message
bus instead of tcp 5666.

Handlers. Eventually we are going to integrate pagerduty for all of our
alerts, but for now I want to write (or use an existing) simple handler that
pipes information to the unit mailtools (mail program). Is there a script
for this handler already in the repos? I'd like to start testing out alerts
and what not and get notified at least via email until we have pagerduty in
play.

You do not have to re-invent the wheel. There are plenty of handlers
(plugins as a catchall) here:

Anyways, sorry for all the newb questions, I'm super new to Sensu and while
I love it so far the docs are not as detailed as something like Icinga2 or
Nagios. Are there any good videos/tutorials/etc that could help me wrap my
head around Sensu better?

I'm in the process of making some video tutorials, but don't hold your
breath. :frowning:

···

On Mon, Jul 20, 2015 at 3:39 PM, James Jelinek <jelinek@gmail.com> wrote:

Thanks for your help in advance!
-James