Giter Site home page Giter Site logo

node-psutil's Introduction

node-psutil

The start of a port of the pyhton library psutil.

Usage

var PSUtil = require('psutil').PSUtil;

var psUtil = new PSUtil();
psUtil.cpu_times(false, function(err, result) {
  test.equal(null, err);
  test.equal('number', typeof result.user);

  psUtil.cpu_times(true, function(err, result) {
    test.equal(null, err);
    test.equal('number', typeof result[0].user);
    test.done();
  });
});

node-psutil's People

Contributors

christkv 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

Watchers

 avatar  avatar  avatar

node-psutil's Issues

OSX support

Here is the console log when i tried to install on mac osx:

(vm)mr_chomps:Tools sean$ npm install psutil
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/psutil
npm http 200 https://registry.npmjs.org/psutil
npm http GET https://registry.npmjs.org/psutil/-/psutil-0.0.3.tgz
npm http 200 https://registry.npmjs.org/psutil/-/psutil-0.0.3.tgz

> [email protected] install /Users/sean/Tools/node_modules/psutil
> node-gyp rebuild

  CXX(target) Release/obj.target/psutil_lib_osx/lib/psutil_lib_osx.o
../lib/psutil_lib_osx.cc:92:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:115:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:135:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:155:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:175:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:193:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:213:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:239:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:260:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:287:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
../lib/psutil_lib_osx.cc:311:3: error: no matching function for call to 'uv_queue_work'
  uv_queue_work(uv_default_loop(), &worker->request, PSUtilLib::Process, PSUtilLib::After);
  ^~~~~~~~~~~~~
/Users/sean/.node-gyp/0.10.21/deps/uv/include/uv.h:1432:15: note: candidate function not viable: no known conversion from 'void (uv_work_t *)' to 'uv_after_work_cb'
      (aka 'void (*)(uv_work_t *, int)') for 4th argument
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
11 errors generated.
make: *** [Release/obj.target/psutil_lib_osx/lib/psutil_lib_osx.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/sean/anaconda/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.1.0
gyp ERR! command "node" "/Users/sean/anaconda/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/sean/Tools/node_modules/psutil
gyp ERR! node -v v0.10.21
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the psutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls psutil
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/Users/sean/anaconda/bin/npm" "install" "psutil"
npm ERR! cwd /Users/sean/Tools
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.4.6
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/sean/Tools/npm-debug.log
npm ERR! not ok code 0
(vm)mr_chomps:Tools sean$ npm --version
1.4.6
(vm)mr_chomps:Tools sean$ node --version
v0.10.21

psutils process methods

not really an issue, this module is great for node apps, but do you have plans of adding process methods like python psutils does? for example getting CPU and memory usage for a single process?

Installation failed

Hello,

The installation of node-psutil has failed on my Debian VM.

npm install psutil

[...]
/root/.node-gyp/0.10.30/deps/uv/include/uv.h:1438:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t_, uv_work_t_, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../lib/psutil_lib_osx.cc: In static member function ‘static v8::Handlev8::Value PSUtilLib::DiskPartitions(const v8::Arguments&)’:
../lib/psutil_lib_osx.cc:260:90: error: invalid conversion from ‘void ()(uv_work_t) {aka void ()(uv_work_s)}’ to ‘uv_after_work_cb {aka void ()(uv_work_s, int)}’ [-fpermissive]
In file included from /root/.node-gyp/0.10.30/src/node.h:61:0,
from ../lib/psutil_lib_osx.cc:8:
/root/.node-gyp/0.10.30/deps/uv/include/uv.h:1438:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t_, uv_work_t_, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../lib/psutil_lib_osx.cc: In static member function ‘static v8::Handlev8::Value PSUtilLib::DiskUsage(const v8::Arguments&)’:
../lib/psutil_lib_osx.cc:287:90: error: invalid conversion from ‘void ()(uv_work_t) {aka void ()(uv_work_s)}’ to ‘uv_after_work_cb {aka void ()(uv_work_s, int)}’ [-fpermissive]
In file included from /root/.node-gyp/0.10.30/src/node.h:61:0,
from ../lib/psutil_lib_osx.cc:8:
/root/.node-gyp/0.10.30/deps/uv/include/uv.h:1438:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t_, uv_work_t_, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../lib/psutil_lib_osx.cc: In static member function ‘static v8::Handlev8::Value PSUtilLib::SysConf(const v8::Arguments&)’:
../lib/psutil_lib_osx.cc:311:90: error: invalid conversion from ‘void ()(uv_work_t) {aka void ()(uv_work_s)}’ to ‘uv_after_work_cb {aka void ()(uv_work_s, int)}’ [-fpermissive]
In file included from /root/.node-gyp/0.10.30/src/node.h:61:0,
from ../lib/psutil_lib_osx.cc:8:
/root/.node-gyp/0.10.30/deps/uv/include/uv.h:1438:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t_, uv_work_t_, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
make: *** [Release/obj.target/psutil_lib_osx/lib/psutil_lib_osx.o] Erreur 1
make: quittant le répertoire « /var/www/myproject/webapps/client/project-daemon/nodejs/src/node_modules/psutil/build »
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.2.0-4-amd64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/myproject/webapps/client/project-daemon/nodejs/src/node_modules/psutil
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the psutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls psutil
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-4-amd64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "psutil"
npm ERR! cwd /var/www/myproject/webapps/client/project-daemon/nodejs/src
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/www/myproject/webapps/client/project-daemon/nodejs/src/npm-debug.log
npm ERR! not ok code 0

multi-cpu reports

You have a small typo in /lib/psutil.js, _cpu_times_linux function.
line 282. var values = lines[i] (instead of 0)
would have made it a pull request, but... you know how it goes.

great library btw,
using it in my project https://github.com/Zolmeister/ZMonitor

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.