Socket
Socket
Sign inDemoInstall

procfs-stats

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

procfs-stats - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

88

index.js

@@ -1,2 +0,2 @@

var once = require('once')
var fs = require('fs');

@@ -82,2 +82,52 @@ var hexip = require('hexip');

},
net:function(cb){
cb = once(cb)
var c = 2
var tcp;
var fds;
module.exports.tcp(procPath,function(err,data){
if(err) return cb(err)
tcp = data
next()
})
this.fds(function(err,data){
if(err) return cb(err)
var fds = {}
var todo = data.length;
if(!todo) return next()
function work(){
if(!data.length) return;
var fd = data.shift()
fs.readlink(fd,function(err,path){
// the fd may not exist anymore.
if(err) return next();
fds[fd] = path;
if(!--todo) next()
})
}
var conc = 10
while(conc-- > 0) work()
})
function next(){
if(--c) return work()
// find socket fds in tcp nettable
console.log(nettable)
console.log(fds)
}
}
}

@@ -190,2 +240,3 @@

fs.readFile(procPath+"net/tcp",function(err,buf){
if(err) return cb(err);
var t = nettable(buf);

@@ -196,3 +247,3 @@ t.forEach(function(con){

});
cb(err,t,buf);
cb(null,t,buf);
});

@@ -209,2 +260,3 @@ }

fs.readFile(procPath+"net/udp",function(err,buf){
if(err) return cb(err);
var t = nettable(buf);

@@ -215,3 +267,3 @@ t.forEach(function(con){

});
cb(err,t,buf);
cb(null,t,buf);
});

@@ -227,2 +279,3 @@ }

fs.readFile(procPath+"net/unix",function(err,buf){
if(err) return cb(err);
var lines = buf.toString().trim().split("\n");

@@ -234,3 +287,3 @@ var keys = lines.shift().trim().split(/\s+/);

});
cb(err,out,buf);
cb(null,out,buf);
});

@@ -246,2 +299,3 @@ }

fs.readFile(procPath+"net/dev",function(err,buf){
if(err) return cb(err);
cb(err,sectiontable(buf),buf);

@@ -258,3 +312,4 @@ });

fs.readFile(procPath+"net/wireless",function(err,buf){
cb(err,sectiontable(buf),buf);
if(err) return cb(err);
cb(null,sectiontable(buf),buf);
});

@@ -357,25 +412,2 @@ }

module.exports._nettable = _nettable
function _nettable(data){
if(!data) return false;
var lines = data.toString().trim().split("\n");
var split = /\s+/g;
var keys = lines.shift().trim().split(split);
lines = lines.map(function(l){
var values = l.trim().split(split);
values.forEach(function(v,i){
if(keys[i] == 'tx_queue' || keys[i] == "tr") {
var parts = v.split(":");
values[i] = parts[0];
values.splice(i+1,0,parts[1]);
}
});
return assoc(keys,values);
})
return lines;
}
function sectiontable(buf){

@@ -382,0 +414,0 @@ if(!buf) return false;

{
"name": "procfs-stats",
"version": "1.0.1",
"version": "1.0.2",
"description": "get detailed information (more than ps, top etc) about running process on linux machines from node.",

@@ -16,3 +16,4 @@ "main": "index.js",

"hexip": "~1.0.1",
"lru-cache": "^4.0.0"
"lru-cache": "^4.0.0",
"once": "^1.3.3"
},

@@ -19,0 +20,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc