{"_id":"pm2-usage","_rev":"2772383","name":"pm2-usage","description":"simple way to lookup linux process usage","dist-tags":{"latest":"0.3.9"},"maintainers":[{"name":"npm:tknew","email":""},{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"time":{"modified":"2022-05-23T09:41:17.000Z","created":"2014-05-09T12:28:17.451Z","0.3.9":"2014-05-09T12:28:17.451Z"},"users":{},"author":{"name":"Arunoda Susiripala","email":"arunoda.susiripala@gmail.com"},"repository":{"type":"git","url":"git://github.com/arunoda/node-usage.git"},"versions":{"0.3.9":{"name":"pm2-usage","version":"0.3.9","description":"simple way to lookup linux process usage","keywords":["usage","ps","cpu","ram","memory"],"author":{"name":"Arunoda Susiripala","email":"arunoda.susiripala@gmail.com"},"repository":{"type":"git","url":"git://github.com/arunoda/node-usage.git"},"main":"./lib/usage.js","scripts":{"test":"test/index.js"},"engines":{"node":">= 0.8.x"},"devDependencies":{"mocha":"1.8.x"},"bugs":{"url":"https://github.com/arunoda/node-usage/issues"},"homepage":"https://github.com/arunoda/node-usage","_id":"pm2-usage@0.3.9","dist":{"shasum":"7f9757cb0dc2839d73bcb684a628167c48d149b1","size":4773,"noattachment":false,"key":"/pm2-usage/-/pm2-usage-0.3.9.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-usage/download/pm2-usage-0.3.9.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"npm:tknew","email":""},{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1399638497451,"_hasShrinkwrap":false,"_cnpm_publish_time":1399638497451,"_cnpmcore_publish_time":"2021-12-17T00:32:19.114Z"}},"readme":"# node-usage [![Build Status](https://travis-ci.org/arunoda/node-usage.png?branch=master)](https://travis-ci.org/arunoda/node-usage)\n\n### process usage lookup with nodejs\n\n* Simple interface to lookup cpu and memory usage of any accessible process on the system.\n* Works on OSX, Linux, SmartOS and Solaris\n* Tested on Heroku and Nodejitsu\n\n## Example\n\n### Code\n~~~js\nvar usage = require('usage');\n\nvar pid = process.pid // you can use any valid PID instead\nusage.lookup(pid, function(err, result) {\n\t\n});\n~~~\n\n### Result Object\n~~~js\n{ \n\tcpu: 10.6, //in percentage\n\tmemory: 100065280 //in no of bytes\n}\n~~~\n\n## Average CPU usage vs Current CPU usage\n>This is only applicable for Linux\n\nBy default CPU Percentage provided is an average from the starting time of the process. It does not correctly reflect the current CPU usage. (this is also a problem with linux `ps` utility)\n\nBut If you call `usage.lookup()` continuously for a given pid, you can turn on **keepHistory** flag and you'll get the CPU usage since last time you track the usage. This reflects the current CPU usage. \n\nsee following example to enable keepHistory flag\n\n~~~js\nvar pid = process.pid;\nvar options = { keepHistory: true }\nusage.lookup(pid, options, function(err, result) {\n\t\n});\n~~~\n\nyou can clear history cache too\n~~~js\nusage.clearHistory(pid); //clear history for the given pid\nusage.clearHistory(); //clean history for all pids\n~~~\n\n## Motivation\n\n* Some of the NodeJS PAAS providers do not expose an interface to monitor CPU and Memory usage.\n* They asks us to go for somewhere else for that which I don't want to go (or simply I cannot go)\n* So `node-usage` was born to tackle on this.\n","_attachments":{},"homepage":"https://github.com/arunoda/node-usage","bugs":{"url":"https://github.com/arunoda/node-usage/issues"}}