Sensu handler written in nodejs to get notified by mail and slack
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
notify.js

README.md

sensu-notify

Sensu handler written in nodejs to get notified by mail and slack when an event occurs.

Usage

Set the required constants in notify.js and place it in the handlers directory.

// ttl sets the time before next notification for the same event
// without it, if a given check runs every 30 sec and subsequently re-generates the same event
// because the issue isn't resolved, you'd be notified every 30sec…
const ttl = 7200;
const email = 'your@email.com';
const slackPath = '/services/xxx/xxx/xxx';

Don't forget to make it executable by sensu chmod 744 notify.js && chown sensu:sensu notify.js

Then declare it as a handler in handlers.json and make it the default handler if needed:

{
    "handlers": {
        "default": {
            "type": "set",
            "handlers": ["notify"]
        },
        "notify": {
           "type": "pipe",
           "command": "/etc/sensu/handlers/notify.js"
       }
    }
}

Finally, set it as the default handler for the desired checks:

"checks": {
    "reboot": {
        "type": "metric",
        "command": "rebootRequired.sh",
        "interval": 30,
        "handlers": ["notify"],
        "subscribers": ["default"]
    },
    "raid": {
        "command": "raid.sh",
        "interval": 86400,
        "handlers": ["notify"],
        "subscribers": ["raid"]
    }
}