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:
cpuUsage.setHighWaterMark(90.0);
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?
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:
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?