Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
net-stat
Advanced tools
Readme
______ _______ _______ _______ _______ _______ _______
| _ \| _ | | _ | | _ | |
|. | |. 1___|.| | | 1___|.| | |. 1 |.| | |
|. | |. __)_`-|. |-|____ `-|. |-|. _ `-|. |-'
|: | |: 1 | |: | |: 1 | |: | |: | | |: |
|::.| |::.. . | |::.| |::.. . | |::.| |::.|:. | |::.|
`--- ---`-------' `---' `-------' `---' `--- ---' `---'
Note: This repo can be found on npm here: net-stat
Note: This repo can be found on github here: node-net-stat
Caveat: Works by parsing /proc/net/dev
, so will only work on nix OS.
npm install net-stat
Require the module:
var netStat = require('net-stat');
By default totalRx()
returns total received bytes for interface lo
:
var totalrx = netStat.totalRx();
console.log(totalrx);
Return total received GiB on interface eth0
, see docs below for accepted values of units
and iface
:
var totalrx = netStat.totalRx({ iface: 'eth0', units: 'GiB' });
console.log(totalrx);
Display the transmitted KiB per second of eth0
over the next 2000ms:
setInterval(function() {
netStat.usageTx({
iface: 'eth0',
units: 'KiB',
sampleMs: 2000,
}, function(kbps) {
console.log('Transmitted ' + kbps + ' kb/s');
});
}, 2500);
Get all fields available from /proc/net/dev
, useful for finding accepted values of iface
:
var allStats = netStat.raw();
console.log(allStats);
Returns a number representing the number of units
received on iface
.
Option | Type | Default | Explanation |
---|---|---|---|
opts | Object | see below | Options object, specify what you need, the defaults will be filled in |
opts.iface | String | 'lo' | The name of the interface to be used. See the raw() function for a list of interfaces. |
opts.units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
Returns a number representing the number of units
transmitted on iface
.
Option | Type | Default | Explanation |
---|---|---|---|
opts | Object | see below | Options object, specify what you need, the defaults will be filled in |
opts.iface | String | 'lo' | The name of the interface to be used. See the raw() function for a list of interfaces. |
opts.units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
Async function which returns data
, the usage received per second in units
on iface
over sampleMs
Option | Type | Default | Explanation |
---|---|---|---|
opts | Object | see below | Options object, specify what you need, the defaults will be filled in |
opts.iface | String | 'lo' | The name of the interface to be used. See the raw() function for a list of interfaces. |
opts.units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
opts.sampleMs | Number | 1000 | The number of milliseconds to take a usage sample over. |
cb | Function | none | A callback function with signature cb(data) where data is the usage received per second in units on iface over sampleMs . |
Async function which returns data
, the usage transmitted per second in units
on iface
over sampleMs
Option | Type | Default | Explanation |
---|---|---|---|
opts | Object | see below | Options object, specify what you need, the defaults will be filled in |
opts.iface | String | 'lo' | The name of the interface to be used. See the raw() function for a list of interfaces. |
opts.units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
opts.sampleMs | Number | 1000 | The number of milliseconds to take a usage sample over. |
cb | Function | none | A callback function with signature cb(data) where data is the usage transmitted per second in units on iface over sampleMs . |
Returns an object representing the data in /proc/net/dev
.
{
eth0: {
bytes: { receive: '2085477580', transmit: '187911353' },
packets: { receive: '1782197', transmit: '1353772' },
errs: { receive: '0', transmit: '0' },
drop: { receive: '42', transmit: '0' },
fifo: { receive: '0', transmit: '0' },
frame: { receive: '0' },
compressed: { receive: '0', transmit: '0' },
multicast: { receive: '7923' },
colls: { transmit: '0' },
carrier: { transmit: '0' }
},
lo: {
bytes: { receive: '52720310', transmit: '52720310' },
packets: { receive: '443962', transmit: '443962' },
errs: { receive: '0', transmit: '0' },
drop: { receive: '0', transmit: '0' },
fifo: { receive: '0', transmit: '0' },
frame: { receive: '0' },
compressed: { receive: '0', transmit: '0' },
multicast: { receive: '0' },
colls: { transmit: '0' },
carrier: { transmit: '0' }
},
}
Just send a PR, or create an issue if you are not sure.
Areas ripe for contribution:
Note: net-stat
, disk-stat
, mem-stat
only work on nix platforms.
MIT
FAQs
Network statistics
The npm package net-stat receives a total of 73 weekly downloads. As such, net-stat popularity was classified as not popular.
We found that net-stat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.