-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Producer event emiting #56
Comments
Hey @jokesterfr, I am glad you are interested in godot! The docs I've written so far are a decent reference for reactors, but on the producer end of things, I'd check out Let me know if you have any other questions! |
I ended up overriding the /*
* A godot probe to retrieve the memory state
* of a Linux system.
*/
var fs = require('fs')
, godot = require('godot');
//
// Get a proper producer instance
//
var linuxSysCPU = godot.producer({
host: 'monitor.foo.bar',
service: 'server/health/cpu',
description: 'CPU usage',
tags: ['CPU','server'],
ttl: 1000 * 30,
});
//
// Override data emission
//
linuxSysCPU.produce = function () {
/**
* Read a file and extract the last minute load average.
*
* /proc/loadavg may contain some datas like `0.43 0.62 0.52 1/519 7418`
* first value is the load average of last minute, second val stand for 5mn,
* and third val for 15mn.
*/
fs.readFile('/proc/loadavg', 'ascii', function(err, data) {
if (err) throw err;
var m = data.match(/^([\w\.]*)\s/);
// Measure in %
var measure = {
cpuload: parseFloat(m[1], 10)
};
// Get current state
var state = 'ok';
if (measure.mem > 70 || measure.swap > 70) state = 'warning'
else if (measure.mem > 90 || measure.swap > 90) state = 'critical'
// Emit the event to reactor server
this.emit('data', {
host: this.values.host,
service: this.values.service,
state: state,
time: Date.now(),
description: this.values.description,
tags: this.values.tags,
meta: measure,
metric: this.values.metric,
ttl: this.values.ttl
});
});
}; But surely, I will have a look on @jesusabdullah work. Moreover, I feel the need to make my own sms service, to get something free internationally (Twilio cannot send sms from any European phone number, + it's expensive). I was thinking about porting gcsms from Python to NodeJS. |
@jokesterfr If you are looking for procuders, have a look at https://github.com/godot-plugins. |
Hi there,
I've been trying some tests with Godot, while it's really handy to get it working with the standard examples (heartbeat case), I could not find any mention of customized events sent by a Godot producer.
Moar docs branch is helpful but lacks references in this domain, whereas the godot introducing entry on Nodejistu mention the
('service', 'cpu')
.Could you please paste here some quick draft example ?
I could then try to fill the documentation, if you guys do not have time for now.
Many thanks
The text was updated successfully, but these errors were encountered: