os
The os module provides Node.js-compatible operating system information APIs for JSH applications.
arch()
Returns CPU architecture.
Syntax
arch()Usage example
| |
platform()
Returns platform name such as darwin, linux, or windows.
Syntax
platform()type()
Returns OS type such as Darwin, Linux, or Windows_NT.
Syntax
type()release()
Returns kernel release/version string.
Syntax
release()hostname()
Returns host name.
Syntax
hostname()homedir()
Returns current user home directory.
Syntax
homedir()tmpdir()
Returns the default temporary directory path.
Syntax
tmpdir()endianness()
Returns CPU endianness: BE or LE.
Syntax
endianness()EOL
Platform-specific end-of-line marker.
- POSIX:
\n - Windows:
\r\n
Usage example
| |
totalmem(), freemem()
Returns total/free memory in bytes.
Syntax
totalmem()
freemem()Usage example
| |
uptime()
Returns system uptime in seconds.
Syntax
uptime()bootTime()
Returns system boot time as Unix timestamp.
Syntax
bootTime()loadavg()
Returns load averages as [1min, 5min, 15min].
Syntax
loadavg()cpus()
Returns per-CPU information array.
Each item includes fields like:
model,speed,coresvendor,family,model,steppingtimes.user,times.nice,times.sys,times.idle,times.irq(milliseconds)
Syntax
cpus()Usage example
| |
cpuCounts()
Returns CPU count.
true: logical CPU countfalse: physical CPU count
Syntax
cpuCounts(logical)cpuPercent()
Returns CPU usage percentages.
intervalSec: sampling interval in seconds (0for immediate)perCPU: return per-core values whentrue
Syntax
cpuPercent(intervalSec, perCPU)Usage example
| |
networkInterfaces()
Returns network interface information object.
The object shape is:
- key: interface name
- value: array of address objects
addressfamily(IPv4/IPv6)internal(boolean)
Syntax
networkInterfaces()hostInfo()
Returns host information object.
Common fields include:
hostname,uptime,bootTime,procsos,platform,platformFamily,platformVersionkernelVersion,kernelArchvirtualizationSystem,virtualizationRole,hostId
Syntax
hostInfo()userInfo()
Returns current user information.
Returned fields include:
username,homedir,shelluid,gid
Syntax
userInfo([options])diskPartitions()
Returns disk partition list.
Syntax
diskPartitions([all])Usage example
| |
diskUsage()
Returns disk usage for the given path.
Typical fields include total, used, free, usedPercent.
Syntax
diskUsage(path)diskIOCounters()
Returns disk I/O counters.
namesomitted or empty: all devicesnamesspecified: selected devices
Syntax
diskIOCounters([names])netProtoCounters()
Returns network protocol counters.
Syntax
netProtoCounters([proto])constants
OS constants object.
Main fields
constants.signalsSIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGABRT,SIGBUS,SIGFPE,SIGKILL,SIGUSR1,SIGSEGV,SIGUSR2,SIGPIPE,SIGALRM,SIGTERM
constants.priorityPRIORITY_LOW,PRIORITY_BELOW_NORMAL,PRIORITY_NORMAL,PRIORITY_ABOVE_NORMAL,PRIORITY_HIGH,PRIORITY_HIGHEST
Usage example
| |