server.hardware
The hardware library, reports CPU and memory usage of the server machine and process.
Requires gmsv_serverstat, all functions return zeros without it.
Fields
| Name | Type | Description |
|---|---|---|
available | boolean | true if gmsv_serverstat is installed, false otherwise. READ-ONLY = false |
physical_cores | integer | The number of physical CPU cores, 1 if unknown. READ-ONLY = 1 |
logical_cores | integer | The number of logical CPU cores ( hardware threads ), 1 if unknown. READ-ONLY = 1 |
total_memory | integer | The total system memory in bytes, 0 if unknown. READ-ONLY = 0 |
Functions
server.hardware.getCPUUsage | Returns the CPU usage of the server process or the whole system. |
server.hardware.getMemoryUsage | Returns the memory usage of the server process ( resident set size ) or the whole system. |
#server.hardware.getCPUUsage
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
| Name | Type | Description |
|---|---|---|
system_wideoptional | boolean | true to get the usage of the whole system, false by default. |
Returns
| Type | Name | Description |
|---|---|---|
number | usage | The 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
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
| Name | Type | Description |
|---|---|---|
system_wideoptional | boolean | true to get the used memory of the whole system, false by default. |
Returns
| Type | Name | Description |
|---|---|---|
integer | used | The used memory in bytes. |
integer | available | The available system memory in bytes. |