higher level api #9

lloyd opened this Issue Nov 15, 2012 · 2 comments


None yet

3 participants

lloyd commented Nov 15, 2012

I'm interested in a node.js module that does what this does, but is a bit higher level. I want to know when my application hits a "high water mark" that I can define in terms of percentage processor usage.

maybe the api looks like this:

var cpuUsage = require('cpu-usage');
cpuUsage.on('busy', function(stats) {
    logger.warn("process is overloaded, using " + stats.percentCPU + "% cpu\n"); 
}).on('normal', function(stats) {
    logger.info("process is back to normal, using " + stats.percentCPU + "% cpu\n"); 

maybe if you want to override the default (80%?) you can say:


This suggests that upon registration for the event, the module would start polling getrusage() every second and fire events, and there are some implementation challenges (like not keeping the using process from exiting cleanly).

Is this within the scope of getrusage, or should it be a separate library?


@lloyd did You found any solution for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment