Skip to content

Instantly share code, notes, and snippets.

@Buzut
Last active June 30, 2017 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Buzut/dd49ee9c9b589f1035296ef96e63698e to your computer and use it in GitHub Desktop.
Save Buzut/dd49ee9c9b589f1035296ef96e63698e to your computer and use it in GitHub Desktop.
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