-
-
Notifications
You must be signed in to change notification settings - Fork 793
/
system.php
96 lines (81 loc) · 2.26 KB
/
system.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* Sytem info class
*
* @description System info class for RaspAP
* @author Bill Zimmerman <billzimmerman@gmail.com>
* @license https://github.com/raspap/raspap-webgui/blob/master/LICENSE
*/
namespace RaspAP\System;
class Sysinfo
{
public function hostname()
{
return shell_exec("hostname -f");
}
public function uptime()
{
$uparray = explode(" ", exec("cat /proc/uptime"));
$seconds = round($uparray[0], 0);
$minutes = $seconds / 60;
$hours = $minutes / 60;
$days = floor($hours / 24);
$hours = floor($hours - ($days * 24));
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
$uptime= '';
if ($days != 0) {
$uptime .= $days . ' day' . (($days > 1)? 's ':' ');
}
if ($hours != 0) {
$uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
}
if ($minutes != 0) {
$uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
}
return $uptime;
}
public function systime()
{
$systime = exec("date");
return $systime;
}
public function usedMemory()
{
$used = shell_exec("free -m | awk 'NR==2{ total=$2 ; used=$3 } END { print used/total*100}'");
return floor($used);
}
public function processorCount()
{
$procs = shell_exec("nproc --all");
return intval($procs);
}
public function loadAvg1Min()
{
$load = exec("awk '{print $1}' /proc/loadavg");
return floatval($load);
}
public function systemLoadPercentage()
{
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
}
public function systemTemperature()
{
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
return number_format((float)$cpuTemp/1000, 1);
}
public function hostapdStatus()
{
exec('pidof hostapd | wc -l', $status);
return $status;
}
public function operatingSystem()
{
$os_desc = shell_exec("lsb_release -sd");
return $os_desc;
}
public function kernelVersion()
{
$kernel = shell_exec("uname -r");
return $kernel;
}
}