Skip to content

Instantly share code, notes, and snippets.

@Buzut Buzut/handlers.json
Last active Jun 30, 2017

Embed
What would you like to do?
Sensu handler for InfluxDB
{
"handlers": {
"influxdb": {
"type": "pipe",
"comman": "/etc/sensu/handlers/influx.js"
}
}
}
#!/usr/bin/nodejs
// to be put in /etc/sensu/handlers/influx.js
const influxPort = 8090;
const dgram = require('dgram');
const client = dgram.createSocket('udp4');
let raw = '';
process.stdin.on('readable', () => {
let chunk = process.stdin.read();
if (chunk !== null) {
raw += chunk;
}
});
process.stdin.on('end', () => {
let json = JSON.parse(raw);
let result = json.check.output;
client.send(result, influxPort, 'localhost', (err) => {
client.close();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.