procfs-stats
Advanced tools
Comparing version 0.0.4 to 0.0.5
31
index.js
@@ -143,3 +143,3 @@ | ||
var k = l.substr(0,p); | ||
var v = l.substr(p).trim(); | ||
var v = l.substr(p + 1).trim(); | ||
@@ -157,2 +157,26 @@ o[k] = v; | ||
module.exports.meminfo = function (cb){ | ||
var pp = _pp(arguments); | ||
var procPath = pp.procPath | ||
cb = pp.cb; | ||
fs.readFile(procPath+'meminfo',function(err,buf){ | ||
if(err) return cb(err); | ||
var lines = buf.toString().trim().split("\n"); | ||
var o = {}; | ||
lines.forEach(function(l){ | ||
var p = l.indexOf(':'); | ||
var k = l.substr(0,p); | ||
var v = l.substr(p).replace(/kB/,'').trim(); | ||
o[k] = v; | ||
}) | ||
cb(false,o); | ||
}); | ||
} | ||
// active tcp | ||
@@ -302,3 +326,2 @@ module.exports.tcp = function(cb){ | ||
var o = {}; | ||
var a = 0; | ||
values.forEach(function(v,i){ | ||
@@ -412,3 +435,3 @@ if(fields.length <= i) { | ||
function _pp(a,num){ | ||
num = num||0;// number of static args. | ||
num = num||0;// number of static args. | ||
// custom proc path is always before the cb. | ||
@@ -419,3 +442,3 @@ var args = [].slice.call(a); | ||
var cb = args.pop(); | ||
// shift off preceding args. | ||
@@ -422,0 +445,0 @@ for(var i=0;i<num;++i) args.shift(); |
{ | ||
"name": "procfs-stats", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "get detailed information (more than ps, top etc) about running process on linux machines from node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,2 +39,3 @@ procfs-stats | ||
* <a href="#cpu">procfs.cpu(cb)</a> | ||
* <a href="#meminfo">procfs.meminfo(cb)</a> | ||
* <a href="#fd">procfs.fd(cb)</a> | ||
@@ -78,3 +79,3 @@ * <a href="#tcp">procfs.tcp(cb)</a> | ||
``` | ||
<a name="pidstats-stat"></a> | ||
@@ -84,3 +85,3 @@ ### ps.stat(cb) | ||
- mixed detailed process stats | ||
- calls back with | ||
- calls back with | ||
@@ -209,3 +210,3 @@ ```js | ||
```js | ||
[ ... | ||
@@ -225,3 +226,3 @@ 'MANPATH=:/usr/local/avr/man:/usr/local/avr/man', | ||
- from /proc/pid/cwd | ||
- calls back with the working directory of the process when it was started | ||
- calls back with the working directory of the process when it was started | ||
@@ -249,3 +250,3 @@ ```js | ||
- from /proc/pid/fds | ||
- returns an array of paths to file descriptors in the procfs fds directory for this process. | ||
- returns an array of paths to file descriptors in the procfs fds directory for this process. | ||
@@ -292,3 +293,3 @@ ```js | ||
{ cpu: | ||
{ cpu: | ||
{ user: '22865094', | ||
@@ -304,3 +305,3 @@ nice: '8419', | ||
guest_nice: '0' }, | ||
cpu0: | ||
cpu0: | ||
{ user: '5417204', | ||
@@ -327,9 +328,61 @@ nice: '1535', | ||
<a name="meminfo"></a> | ||
### procfs.meminfo(cb) | ||
- from /proc/meminfo | ||
- calls back with an object like this | ||
```js | ||
{ MemTotal: '1019452', | ||
MemFree: '44328', | ||
MemAvailable: '438588', | ||
Buffers: '110444', | ||
Cached: '233468', | ||
SwapCached: '0', | ||
Active: '745748', | ||
Inactive: '136524', | ||
'Active(anon)': '538432', | ||
'Inactive(anon)': '64', | ||
'Active(file)': '207316', | ||
'Inactive(file)': '136460', | ||
Unevictable: '0', | ||
Mlocked: '0', | ||
SwapTotal: '0', | ||
SwapFree: '0', | ||
Dirty: '25788', | ||
Writeback: '0', | ||
AnonPages: '538432', | ||
Mapped: '76296', | ||
Shmem: '136', | ||
Slab: '75952', | ||
SReclaimable: '65052', | ||
SUnreclaim: '10900', | ||
KernelStack: '2880', | ||
PageTables: '5264', | ||
NFS_Unstable: '0', | ||
Bounce: '0', | ||
WritebackTmp: '0', | ||
CommitLimit: '509724', | ||
Committed_AS: '1070328', | ||
VmallocTotal: '34359738367', | ||
VmallocUsed: '2528', | ||
VmallocChunk: '34359729003', | ||
AnonHugePages: '0', | ||
HugePages_Total: '0', | ||
HugePages_Free: '0', | ||
HugePages_Rsvd: '0', | ||
HugePages_Surp: '0', | ||
Hugepagesize: '2048', | ||
DirectMap4k: '22528', | ||
DirectMap2M: '1026048' } | ||
``` | ||
<a name="fd"></a> | ||
### procfs.fd(fdPath,cb) | ||
- from /proc/pid/fds/fd and /proc/pid/fdinfo | ||
- fdPath is the full path | ||
- calls back with an object | ||
- fdPath is the full path | ||
- calls back with an object | ||
- stat is an fs.Stats object | ||
- full path to file. | ||
- full path to file. | ||
- in the case of a socket a string "socket[inode]" or some such will be returned. you can lookup the inode in the net.tcp||udp||unix table for even more info! | ||
@@ -342,3 +395,3 @@ | ||
info: { pos: '0', flags: '02100002' }, | ||
stat: | ||
stat: | ||
{ dev: 11, | ||
@@ -391,3 +444,3 @@ mode: 8576, | ||
inode: '12881', | ||
_: | ||
_: | ||
{ '12': '1', | ||
@@ -434,3 +487,3 @@ '13': '0000000000000000', | ||
- the unix socket table as an array | ||
```js | ||
@@ -483,3 +536,3 @@ [ { Num: '0000000000000000:', | ||
- from /proc/diskstats | ||
- calls back with an array of objects like this. | ||
- call back format: cb(false, data, buf), where data looks like below | ||
@@ -486,0 +539,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113935
24
587
590
20