Comments (3)
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 godot-producer
by @jesusabdullah. I totally agree the doc coverage isn't there yet, I'm looking to fix that soon. Any help would greatly appreciated :).
Let me know if you have any other questions!
from godot.
I ended up overriding the produce
method, which is for me, less ugly than expected:
/*
* 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.
from godot.
@jokesterfr If you are looking for procuders, have a look at https://github.com/godot-plugins.
from godot.
Related Issues (20)
- Make it possible to listen on UNIX sockets HOT 1
- client.close() does not clear producer intervals HOT 2
- .by(<key>, reactor()) HOT 1
- .diff() HOT 1
- Client reconnect and backoff HOT 1
- How to set sendgrid details ? HOT 4
- Add configuration for emitter.setMaxListeners HOT 3
- Add tests to ensure errors are handled correctly in the reactor pipe chain HOT 1
- [needs investigation] Error listener is only called once. HOT 1
- Scaling rollup HOT 1
- Should work on node 0.10 HOT 4
- Error propagation can stall stream HOT 2
- Replace `node-backoff` with a simpler module, `back`
- Add a reactor::error event
- godot needs a new API HOT 3
- .connect(callback) fails
- Do we want buffering? HOT 19
- Is this project still alive ?
- Perhaps rename HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot.