Description
monitor vital signs of your server :
- CPU average usage
- Free and used drive space
- Free and used memory space
- Operating System
- All processes running
- TTY/SSH opened
- Total opened files
- Network speed (input and output)
async-os-utils
An operating system utility library. Some methods are wrappers of node libraries and others are calculations made by the module.
os-utils extended node-os-utils extended
Installation
One line installation with npm.
$ npm install async-os-utils --save
Then in your code
Example
var osu = var cpu = osucpu var count = cpu // 8 cpu var osCmd = osuosCmd osCmd
Configuration
require('async-os-utils').options
Default settings:
NOT_SUPPORTED_VALUE
isnot supported
. os not supported, return value.INTERVAL
is1000
millisecond. Represents the refresh of the cpu and network workers.
⚠️ If this module uses too much CPU, set the INTERVAL
value to 10000 or more.
Info
If you have not supported
in some categories, your OS configuration is not supported for this option.
Usage
The following methods are available:
require('async-os-utils').cpu
cpu.average():object
CPU average
var osu = var cpu = osucpu var info = cpu console
{ totalIdle: 33526410,
totalTick: 37460330,
avgIdle: 4190801.25,
avgTotal: 4682541.25 }
cpu.usage(interval):Promise(number)
CPU average usage
var osu = var cpu = osucpu cpu
10.06
cpu.free(interval):Promise(number)
cpu free percentage
var osu = var cpu = osucpu cpu
89.26
cpu.count():number
cpu.model():string
cpu.loadavg():Array[number]
cpu.loadavgTime(time):number
- time: number - 1, 5 or 15 minutes, defaulta: 1
require('async-os-utils').drive
drive.info():Promise(Object)
drive info
var osu = var drive = osudrive drive
{ totalGb: '464.8',
usedGb: '147.7',
freeGb: '316.9',
usedPercentage: '31.8',
freePercentage: '68.2' }
drive.free():Promise(Object)
{ totalGb: '464.8', freeGb: '316.9', freePercentage: '68.2' }
drive.used():Promise(Object)
{ totalGb: '464.8', usedGb: '316.9', usedPercentage: '68.2' }
require('async-os-utils').mem
mem.info():Promise(Object)
memory info
var osu = var mem = osumem mem
{ totalMemMb: 16384,
usedMemMb: 13403.41,
freeMemMb: 2980.59,
freeMemPercentage: 18.19 }
mem.free():Promise(Object)
{ totalMemMb: 16384, freeMemMb: 3033.63 }
mem.used():Promise(Object)
{ totalMemMb: 16384, usedMemMb: 13421.15 }
mem.totalMem():number
17179869184
require('async-os-utils').netstat
netstat.stats():Promise(Array[Object])
var osu = var netstat = osunetstat netstat
[ { interface: 'lo',
inputBytes: '731508412',
outputBytes: '731508412' },
{ interface: 'eth0',
inputBytes: '1356471479',
outputBytes: '26631036763' } ]
netstat.inOut(interval):Promise(Object)
var osu = var netstat = osunetstat netstat
{ total: { inputMb: 0.02, outputMb: 1.22 },
eth0: { inputMb: 0.02, outputMb: 1.22 } }
require('async-os-utils').openfiles
openfiles.openFd():Promise(number)
Total opened files
1088
require('async-os-utils').os
os.oos():Promise(string)
original operating system
Mac OS X 10.12.5
Red Hat 7.3
os.platform():string
os.uptime():number - (seconds)
os.ip():string
os.hostname():string
os.type():string
os.arch():string
require('async-os-utils').proc
proc.totalProcesses():Promise(number)
proc.zombieProcesses():Promise(number)
require('async-os-utils').users
users.openedCount():Promise(number)
TTY/SSH opened
require('async-os-utils').osCmd
osCmd.topCpu():Promise(string)
osCmd.topMem():Promise(string)
osCmd.vmstats():Promise(string)
......
var bucket = bucketosCmd = topCpu: bucket topMem: bucket vmstats: bucket processesUsers: bucket diskUsage: bucket who: bucket whoami: bucket openPorts: bucket ifconfig: bucket
License
MIT. Copyright (c).