1

I have created a shell script. I want sensu to run that script on the selected node that are identified using the chef roles. I want to create a sensu check to monitor this particular check using the shell script.

Verma15
  • 11
  • 3

2 Answers2

2

Sensu can make use of any script which uses these exist statuses:

  • 0 = OK
  • 1 = Warning
  • 2 = Critical

Write your shell script to run whichever tests you want, and exit with the correct value.

Next, configure your check to be called in a checks configuration file:

{
  "checks": {
    "<check_name>": {
      "command": "<path_to_script> <arguments>",
      ... other check definitions here...
    }
  }
}

Lastly, make sure that the check is implemented as a standalone or subscription check.

Hope that helps :)

Marc Gouw
  • 108
  • 4
1

Just to add to the other answer, you can use this as a template. Is a very simple check in bash but it returns the correct outputs for sensu.

#!/bin/bash

CHECK="your check goes here"

if [CHECK something]; then
  echo "WARNING!"
  exit 1
else
  echo "OK!"
  exit 0
fi

echo "Unknown Error"
exit 3
Marc Gouw
  • 108
  • 4
Rebeca Maia
  • 438
  • 4
  • 16