Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
node-os-utils
Advanced tools
monitor vital signs of your server :
An operating system utility library. Some methods are wrappers of node libraries and others are calculations made by the module.
os-utils extended
One line installation with npm.
$ npm install node-os-utils --save
Then in your code
var osu = require('node-os-utils')
var cpu = osu.cpu
var count = cpu.count() // 8
cpu.usage()
.then(cpuPercentage => {
console.log(cpuPercentage) // 10.38
})
var osCmd = osu.osCmd
osCmd.whoami()
.then(userName => {
console.log(userName) // admin
})
require('node-os-utils').options
Default settings:
NOT_SUPPORTED_VALUE
is not supported
. os not supported, return value.INTERVAL
is 1000
millisecond. Represents the refresh of the cpu and network workers.:warning: If this module uses too much CPU, set the INTERVAL
value to 10000 or more.
If you have not supported
in some categories, your OS configuration is not supported for this option.
You can use require('node-os-utils').isNotSupported()
to decide not supported
.
var osu = require('node-os-utils')
var osCmd = osu.osCmd
osCmd
.topCpu()
.then(function(res){
if(osu.isNotSupported(res)){
// Handle 'not supported'
}else{
// Things to do...
}
})
The following methods are available:
CPU average
var osu = require('node-os-utils')
var cpu = osu.cpu
var info = cpu.average()
console.log(info)
{ totalIdle: 33526410,
totalTick: 37460330,
avgIdle: 4190801.25,
avgTotal: 4682541.25 }
CPU average usage
var osu = require('node-os-utils')
var cpu = osu.cpu
cpu.usage()
.then(info => {
console.log(info)
})
10.06
cpu free percentage
var osu = require('node-os-utils')
var cpu = osu.cpu
cpu.free()
.then(info => {
console.log(info)
})
89.26
drive info
var osu = require('node-os-utils')
var drive = osu.drive
drive.info()
.then(info => {
console.log(info)
})
{ totalGb: '464.8',
usedGb: '147.7',
freeGb: '316.9',
usedPercentage: '31.8',
freePercentage: '68.2' }
{ totalGb: '464.8', freeGb: '316.9', freePercentage: '68.2' }
{ totalGb: '464.8', usedGb: '316.9', usedPercentage: '68.2' }
memory info
var osu = require('node-os-utils')
var mem = osu.mem
mem.info()
.then(info => {
console.log(info)
})
{ totalMemMb: 16384,
usedMemMb: 13403.41,
freeMemMb: 2980.59,
freeMemPercentage: 18.19 }
{ totalMemMb: 16384, freeMemMb: 3033.63 }
{ totalMemMb: 16384, usedMemMb: 13421.15 }
17179869184
var osu = require('node-os-utils')
var netstat = osu.netstat
netstat.stats()
.then(info => {
console.log(info)
})
[ { interface: 'lo',
inputBytes: '731508412',
outputBytes: '731508412' },
{ interface: 'eth0',
inputBytes: '1356471479',
outputBytes: '26631036763' } ]
var osu = require('node-os-utils')
var netstat = osu.netstat
netstat.inOut()
.then(info => {
console.log(info)
})
{ total: { inputMb: 0.02, outputMb: 1.22 },
eth0: { inputMb: 0.02, outputMb: 1.22 } }
Total opened files
1088
original operating system
Mac OS X 10.12.5
Red Hat 7.3
TTY/SSH opened
......
var bucket = require('./bucket')
var exec = require('./exec')
var wrapExec = exec.wrapExec
bucket.osCmd = {
topCpu: wrapExec('ps -eo pcpu,user,args --no-headers | sort -k 1 -n | tail -n 10 | sort -k 1 -nr | cut -c 1-70'),
topMem: wrapExec('ps -eo pmem,pid,cmd | sort -k 1 -n | tail -n 10 | sort -k 1 -nr | cut -c 1-70'),
vmstats: wrapExec('vmstat -S m'),
processesUsers: wrapExec('ps hax -o user | sort | uniq -c'),
diskUsage: wrapExec('df -h'),
who: wrapExec('who'),
whoami: wrapExec('whoami'),
openPorts: wrapExec('lsof -Pni4 | grep ESTABLISHED'),
ifconfig: wrapExec('ifconfig')
}
MIT. Copyright (c).
FAQs
An operating system utility library.
We found that node-os-utils 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.