Git Product home page Git Product logo

node-getrusage's Introduction

getrusage for Node

Simple wrapper around the unix method getrusage for reporting CPU Time and other process information

Installation

npm install getrusage

Or:

git clone git://github.com/davglass/node-getrusage.git
cd node-getrusage
npm install

Usage

var proc = require('getrusage');
console.log(proc.usage());          # Run "man getrusage" for fields.
console.log(proc.getcputime());     # User time + system time.
console.log(proc.getsystemtime());  # System time.

Tests

npm install && npm test

Build Status

Build Status

node-getrusage's People

Contributors

darrachequesne avatar davglass avatar jhaynie avatar sethml avatar temsa avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-getrusage's Issues

npm package fails to build due to inclusion of build/.wafpickle-7

Hi, there was a bug in npm causing it to include dotfiles in ignored directories: https://github.com/isaacs/npm/issues/2144

As a result, the node-getrusage tarball currently in npm (http://registry.npmjs.org/getrusage/-/getrusage-0.3.0.tgz) includes the file build/.wafpickle-7, which causes the build to fail (because that pickle file caches paths on the packager's machine, e.g. '/Users/yui/src/node-getrusage/build').

Could you repackage node-getrusage using a recent version of npm so as to exclude the file build/.wafpickle-7?

higher level api

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?

Symbol getrusage_module not found issue with node 0.10.0

Yesterday the node 0.10.0 was released and I was trying to update my mini project to 0.10.0.

I found that I was getting this error at require statement.

Error: Symbol getrusage_module not found.
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)

node-gyp clean
node-gyp configure
node-gyp build

doesn't help.

After updating to 0.10.0 I even removed node_modules from my project.

getusertime seems to return 2*systemtime (by code review)

double getusertime(void) {
    struct timeval tim;
    struct rusage ru;

    getrusage(RUSAGE_SELF, &ru);

    tim = ru.ru_stime;
    double t=(double)tim.tv_sec + (double)tim.tv_usec / 1000000.0;
    tim=ru.ru_stime;        
    t+=(double)tim.tv_sec + (double)tim.tv_usec / 1000000.0;        
    return t;
}

shouldn't that be u time and not duplicated:

    tim = ru.ru_utime;
    double t=(double)tim.tv_sec + (double)tim.tv_usec / 1000000.0;
    return t;

Referred to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html
The <sys/resource.h> header shall define the rusage structure that includes at least the following members:
struct timeval ru_utime User time used.
struct timeval ru_stime System time used.

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.