dreamworkAPI
Ctrl K
GitHub
libraryDocs / server / hardware

server.hardware

libraryserversource

The hardware library, reports CPU and memory usage of the server machine and process.

Requires gmsv_serverstat, all functions return zeros without it.

Fields

NameTypeDescription
availablebooleantrue if gmsv_serverstat is installed, false otherwise. READ-ONLY = false
physical_coresintegerThe number of physical CPU cores, 1 if unknown. READ-ONLY = 1
logical_coresintegerThe number of logical CPU cores ( hardware threads ), 1 if unknown. READ-ONLY = 1
total_memoryintegerThe total system memory in bytes, 0 if unknown. READ-ONLY = 0

Functions

server.hardware.getCPUUsageReturns the CPU usage of the server process or the whole system.
server.hardware.getMemoryUsageReturns the memory usage of the server process ( resident set size ) or the whole system.

#server.hardware.getCPUUsage

servernodiscardsource
function server.hardware.getCPUUsage(system_wide?: boolean): number

Returns the CPU usage of the server process or the whole system.

The process usage is measured since the previous call ( made from any addon ), blocks for ~1ms, the first call returns 0, calls in the same frame return 0 and one spike to 1 was seen on an idle server, average a few samples for alerts.

The system usage is updated every 250ms in the background, the first call starts the updater and the first sample reports 1.

Parameters
NameTypeDescription
system_wideoptionalbooleantrue to get the usage of the whole system, false by default.
Returns
TypeNameDescription
numberusageThe CPU usage from 0 to 1 as a fraction of all logical cores, multiply by hardware.logical_cores to get it in cores.

#server.hardware.getMemoryUsage

servernodiscardsource
function server.hardware.getMemoryUsage(system_wide?: boolean): integer, integer

Returns the memory usage of the server process ( resident set size ) or the whole system.

Updated every 250ms in the background, the first call starts the updater.

Parameters
NameTypeDescription
system_wideoptionalbooleantrue to get the used memory of the whole system, false by default.
Returns
TypeNameDescription
integerusedThe used memory in bytes.
integeravailableThe available system memory in bytes.
Generated from the dreamwork meta branch.