\SystemHwInfo
Represents a class for retrieving system information.
Synopsis
class SystemHwInfo
{
- // members
- protected string $os = '';
- protected string $osRelease = '';
- protected string $osFullRelease = '';
- protected string $machineArch = '';
- protected string $hostname = '';
- protected string $phpVersion = '';
- protected string $cpuName = '';
- protected integer $cpuCores = 1;
- protected integer $memTotal = 0;
- protected integer $memFree = 0;
- protected integer $memUsed = 0;
- protected integer $uptimeSeconds = 0;
- protected array $loadAverage = ;
- protected integer $la1 = 0;
- protected integer $la5 = 0;
- protected integer $la15 = 0;
- protected integer $systemLoadPercent = 0;
- protected integer $loadPercent1 = 0;
- protected integer $loadPercent5 = 0;
- protected integer $loadPercent15 = 0;
- protected integer $loadAvgPercent = 0;
- protected array $mountPoints = ;
- protected array $diskStats = ;
- protected string $sysctlPath = '/sbin/sysctl';
- protected string $vmstatPath = '/usr/bin/vmstat';
- protected string $catPath = '/bin/cat';
- protected string $grepPath = '/usr/bin/grep';
- protected string $headPath = '/usr/bin/head';
- // methods
- public void __construct()
- protected string grabCmdOutput()
- protected void setOS()
- protected void setPaths()
- protected void setLoadAverage()
- protected void setCpuName()
- protected void setCpuCores()
- protected void setUptime()
- protected void setSystemLoadPercent()
- protected void setPhpVersion()
- protected void setMemory()
- public void setMountPoints()
- protected float calcPercentValue()
- public array getDiskStat()
- protected void setDiskStats()
- public array getAllDiskStats()
- public string getOs()
- public string getOsRelease()
- public string getOsFullRelease()
- public string getHostname()
- public string getPhpVersion()
- public string getCpuName()
- public int getCpuCores()
- public int getMemTotal()
- public int getMemFree()
- public int getMemUsed()
- public int getUptime()
- public array getLoadAverage()
- public float getLa1()
- public float getLa5()
- public float getLa15()
- public float getSystemLoadPercent()
- public float getLoadPercent1()
- public float getLoadPercent5()
- public float getLoadPercent15()
- public float getLoadAvgPercent()
- public array getMountPoints()
- public void getMachineArch()
Members
protected
- $catPath
- $cpuCores
—
int
This variable represents the number of CPU cores. - $cpuName
—
string
Property that holds the name of the CPU. - $diskStats
—
array
Contains loaded all mountpoints stats - $grepPath
- $headPath
- $hostname
—
string
This variable represents the hostname of the system. - $la1
—
float
This variable represents the load average of the system in 1 minute - $la15
—
float
This variable represents the load average of the system in 15 minutes - $la5
—
float
This variable represents the load average of the system in 5 minute - $loadAverage
—
array
This variable represents the load average of the system. - $loadAvgPercent
—
float
This variable represents the average system resources load percent depends on cores count - $loadPercent1
—
float
This variable represents the system resources load percent depends on cores count in 1 minute - $loadPercent15
—
float
This variable represents the system resources load percent depends on cores count in 15 minutes - $loadPercent5
—
float
This variable represents the system resources load percent depends on cores count in 5 minutes - $machineArch
—
string
Contains type of the current hardware platform - $memFree
—
int
This variable represents the free memory in bytes. - $memTotal
—
int
This variable represents the total memory available in bytes. - $memUsed
—
int
This variable represents the used memory in bytes. - $mountPoints
—
array
Contains mountpoints to load disk stats - $os
—
string
This variable represents the operating system name of the system. - $osFullRelease
—
string
Represents the full system OS information. - $osRelease
—
string
This variable represents the operating system release of the system. - $phpVersion
—
string
This variable represents the PHP version used in the system. like 7.4.29. - $sysctlPath
—
string
The paths for some of system executable binaries - $systemLoadPercent
—
float
This variable represents the latest system resources load percent depends on cores count. - $uptimeSeconds
—
int
This variable represents the number of seconds the system has been running. - $vmstatPath
Methods
protected
- calcPercentValue() — Counts percentage between two values
- grabCmdOutput() — Retrieves the output of a command execution.
- setCpuCores() — Sets the number of CPU cores.
- setCpuName() — Sets the CPU name.
- setDiskStats() — Sets the disk statistics property dewpends on preset mountpoints
- setLoadAverage() — Sets the load average.
- setMemory() — Sets the memory stats for the system.
- setOS() — Sets the operating system information.
- setPaths() — Sets the paths for some binaries
- setPhpVersion() — Sets the PHP version prop.
- setSystemLoadPercent() — Sets the system load percentages.
- setUptime() — Sets the uptime proterty for the system.
public
- __construct()
- getAllDiskStats() — Retrieves all disk statistics.
- getCpuCores() — Gets the number of CPU cores.
- getCpuName() — Gets the name of the CPU.
- getDiskStat() — Retrieves disk statistics for a given mount point. Returns An array containing disk statistics including mount point, total space, free space, used space, used percentage, and free percentage.
- getHostname() — Gets the hostname of the system.
- getLa1() — Gets the system's load average over 1 minute.
- getLa15() — Gets the system's load average over 15 minutes.
- getLa5() — Gets the system's load average over 5 minutes.
- getLoadAverage() — Gets the system's load average over 1, 5, and 15 minutes.
- getLoadAvgPercent() — Gets the average system load percentage.
- getLoadPercent1() — Gets the system's load percentage over 1 minute.
- getLoadPercent15() — Gets the system's load percentage over 15 minutes.
- getLoadPercent5() — Gets the system's load percentage over 5 minutes.
- getMachineArch() — Returns type of the current hardware platform e.g. amd64, arm64, x86_64 etc
- getMemFree() — Gets the free memory in bytes.
- getMemTotal() — Gets the total memory available in bytes.
- getMemUsed() — Gets the used memory in bytes.
- getMountPoints() — Gets the mount points used for disk statistics.
- getOs() — Gets the operating system name.
- getOsFullRelease() — Gets the full release of the operating system.
- getOsRelease() — Gets the release of the operating system.
- getPhpVersion() — Gets the PHP version used in the system.
- getSystemLoadPercent() — Gets the system's load percentage based on the number of CPU cores.
- getUptime() — Gets the number of seconds the system has been running.
- setMountPoints() — Sets the mount points for the system hardware information.