Sensu shell helper

I wrote this shell script to make it easier for me to add sensu checks for my cron jobs with minimal overhead:

I hope it might be useful to others too. Feel free to open issues / pull requests if it doesn’t work for you. (it is not production tested)

Example cron usage:

0 * * * * /usr/bin/sensu-shell-helper /usr/bin/apt-get update

No more cron spam, alerts when it fails, and clears when it resolves.

That’s pretty awesome. Thanks for posting.

···

On Sun, Dec 15, 2013 at 9:04 AM, Kyle Anderson kyle@xkyle.com wrote:

I wrote this shell script to make it easier for me to add sensu checks for my cron jobs with minimal overhead:
https://github.com/solarkennedy/sensu-shell-helper

I hope it might be useful to others too. Feel free to open issues / pull requests if it doesn’t work for you. (it is not production tested)

Example cron usage:

0 * * * * /usr/bin/sensu-shell-helper /usr/bin/apt-get update

No more cron spam, alerts when it fails, and clears when it resolves.

Agreed - this is really useful, Kyle.

I'd like to augment your script, if possible, with metrics.

For example, the target could optionally be run via time

(/usr/bin/time on Ubuntu) and it could return metrics for:

  • Length of real time the job took to run

  • Kernel-mode time

  • User-mode time

  • Maximum resident set size (memory) used

  • Number of swaps caused

  • Etc…

    This would certainly be very useful for my use-cases. What do you
    think?

    Kind regards,

    Mike

···

On 16/12/13 18:56, Joe Miller wrote:

That’s pretty awesome. Thanks for posting.

      On Sun, Dec 15, 2013 at 9:04 AM, Kyle

Anderson kyle@xkyle.com
wrote:

          I wrote this shell script to make it easier

for me to add sensu checks for my cron jobs with minimal
overhead:
https://github.com/solarkennedy/sensu-shell-helper

            I hope it might be useful to others too. Feel free to

open issues / pull requests if it doesn’t work for you.
(it is not production tested)

Example cron usage:

            0 * * * * /usr/bin/sensu-shell-helper

/usr/bin/apt-get update

            No more cron spam, alerts when it fails, and clears

when it resolves.

      Head of Technical Services

Direct: +44 2030 516134
Mobile: +44 7866 621320

The Old School House
Bridge Road, Hunton Bridge,
Kings Langley, WD4 8RQ
Switchboard: +44 1923 261166



      [www.clock.co.uk/email-disclaimer](http://www.clock.co.uk/email-disclaimer)

      clock.@ is a Registered Trademark of Clock Limited in the

European Community and other territories

mike@clock.co.uk

www.clock.co.uk

Hmm. I don’t know if parsing the output of these commands is inside the scope of the sensu-helper-script.

But, if the command you have in mind (or a filter script to mutate it) can output appropriately, you might be able to do something like this?

sensu-shell-helper -j ‘“metric”: true’ -H ‘[“graphite”]’ “/etc/sensu/plugins/vmstat-metrics.rb --scheme stats.:::name:::”

Produces:

{

“name”: “etc_sensu_plugins_vmstat-metrics.rb–scheme_stats.name”,

“output”: “bla”,

“metric”: true

“handlers”: [“graphite”],

“status”: 0

}

I don’t know. Probably will work? Use -d to debug the json output sensu-shell-helper is making until it works?

Pull requests welcome if you can modify it to handle metrics better, but I wouldn’t want to make assumptions about how peoples handlers are setup and stuff.

···

On Thu, Dec 19, 2013 at 10:45 AM, Michael Cronnelly mike@clock.co.uk wrote:

Agreed - this is really useful, Kyle.

I'd like to augment your script, if possible, with metrics.



For example, the target could optionally be run via time (/usr/bin/time on Ubuntu) and it could return metrics for:
  • Length of real time the job took to run

  • Kernel-mode time

  • User-mode time

  • Maximum resident set size (memory) used

  • Number of swaps caused

  • Etc…

    This would certainly be very useful for my use-cases. What do you think?

    Kind regards,

    Mike

On 16/12/13 18:56, Joe Miller wrote:

That’s pretty awesome. Thanks for posting.

      mike@clock.co.uk

      Head of Technical Services



      Direct: +44 2030 516134

      Mobile: +44 7866 621320



      --



      [](http://www.clock.co.uk)




      The Old School House

      Bridge Road, Hunton Bridge,

      Kings Langley, WD4 8RQ



      Switchboard: +44 1923 261166

      [www.clock.co.uk](http://www.clock.co.uk)




      [www.clock.co.uk/email-disclaimer](http://www.clock.co.uk/email-disclaimer)

      clock.@ is a Registered Trademark of Clock Limited in the European Community and other territories
      On Sun, Dec 15, 2013 at 9:04 AM, Kyle Anderson <kyle@xkyle.com>
      wrote:
          I wrote this shell script to make it easier for me to add sensu checks for my cron jobs with minimal overhead:

https://github.com/solarkennedy/sensu-shell-helper

            I hope it might be useful to others too. Feel free to open issues / pull requests if it doesn't work for you. (it is not production tested)

Example cron usage:

            0 * * * * /usr/bin/sensu-shell-helper /usr/bin/apt-get update
            No more cron spam, alerts when it fails, and clears when it resolves.