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.
mem-stat
Advanced tools
Readme
___ ___ _______ ___ ___ _______ _______ _______ _______
| Y | _ | Y | _ | | _ | |
|. |. 1___|. | 1___|.| | |. 1 |.| | |
|. \_/ |. __)_|. \_/ |____ `-|. |-|. _ `-|. |-'
|: | |: 1 |: | |: 1 | |: | |: | | |: |
|::.|:. |::.. . |::.|:. |::.. . | |::.| |::.|:. | |::.|
`--- ---`-------`--- ---`-------' `---' `--- ---' `---'
Note: This repo can be found on npm here: mem-stat
Note: This repo can be found on github here: node-mem-stat
Caveat: Works by parsing /proc/meminfo
, so will only work on nix OS.
npm install mem-stat
Require the module:
var memStat = require('mem-stat');
By default free()
returns values in bytes:
var free = memStat.free();
console.log(free);
Return free memory in GiB, see docs below for allowed values of units:
var free = memStat.free('GiB');
console.log(free);
usedPercent()
returns the percentage memory used eg. 13.359272
:
var usedPercent = memStat.usedPercent();
console.log(usedPercent);
Get all the calculated statistics, requiring only one read and parse of /proc/meminfo
:
var allStats = memStat.allStats();
console.log(allStats);
{
free: 1000,
total: 8000,
freePercent: 86.245977,
usedPercent: 13.754023,
}
Get all fields available from /proc/meminfo
formatted as an object, see docs below for example of all the fields:
var raw = memStat.raw();
console.log(raw);
``
``
//or use the callback style
memStat.raw(function(err, raw) {
if (err) {
return console.log(err);
}
console.log(raw);
});
Returns the amount of free memory in units
available on the system.
Option | Type | Default | Explanation |
---|---|---|---|
units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
Returns the amount of total memory in units
available on the system. It's basically the same as os.totalmem()
, but instead using /proc/meminfo
.
Option | Type | Default | Explanation |
---|---|---|---|
units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
Returns the amount of free memory as a percentage eg 83.9430437
.
Returns the amount of used memory as a percentage eg 13.9430437
.
Returns an object of all the stats, therefore only requiring one reading and parsing of /proc/meminfo
.
{
free: 1000,
total: 8000,
freePercent: 86.245977,
usedPercent: 13.754023,
}
Option | Type | Default | Explanation |
---|---|---|---|
units | String | 'bytes' | The units of the returned value, can be one of bytes , KiB , MiB or GiB . |
Returns an object representing the data in /proc/meminfo
.
Option | Type | Default | Explanation |
---|---|---|---|
cb | Function | If no callback is specified, uses sync file read | Gives the user the option of using a callback style interface. |
{
memTotal: 8114892,
memFree: 794140,
memAvailable: 5879036,
buffers: 385952,
cached: 4597408,
swapCached: 10992,
active: 4288952,
inactive: 2453264,
activeAnon: 1197680,
inactiveAnon: 592184,
activeFile: 3091272,
inactiveFile: 1861080,
unevictable: 32,
mlocked: 32,
swapTotal: 1951740,
swapFree: 1930036,
dirty: 212,
writeback: 0,
anonPages: 1748032,
mapped: 378400,
shmem: 31012,
slab: 418628,
sReclaimable: 385960,
sUnreclaim: 32668,
kernelStack: 6800,
pageTables: 32020,
nFSUnstable: 0,
bounce: 0,
writebackTmp: 0,
commitLimit: 6009184,
committedAS: 6138892,
vmallocTotal: 34359738367,
vmallocUsed: 120844,
vmallocChunk: 34359595004,
hardwareCorrupted: 0,
anonHugePages: 370688,
hugePagesTotal: 0,
hugePagesFree: 0,
hugePagesRsvd: 0,
hugePagesSurp: 0,
hugepagesize: 2048,
directMap4k: 237136,
directMap2M: 5992448,
directMap1G: 2097152
}
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
Memory statistics, not provided by `os` module.
The npm package mem-stat receives a total of 25 weekly downloads. As such, mem-stat popularity was classified as not popular.
We found that mem-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.