Code Monkey home page Code Monkey logo

Comments (3)

jcrugzz avatar jcrugzz commented on September 27, 2024

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.

jokesterfr avatar jokesterfr commented on September 27, 2024

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.

obazoud avatar obazoud commented on September 27, 2024

@jokesterfr If you are looking for procuders, have a look at https://github.com/godot-plugins.

from godot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.