1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00
raspap-webgui/app/lib/system.php

91 lines
2.2 KiB
PHP
Raw Normal View History

2019-10-08 20:07:38 +02:00
<?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()
{
2020-03-24 19:48:35 +01:00
return shell_exec("hostname -f");
}
public function uptime()
{
2020-03-24 19:48:35 +01:00
$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 ':' ');
2020-03-24 19:48:35 +01:00
}
if ($hours != 0) {
$uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
2020-03-24 19:48:35 +01:00
}
if ($minutes != 0) {
$uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
}
return $uptime;
}
public function usedMemory()
{
$used = shell_exec("free -m | awk 'NR==2{ total=$2 ; used=$3 } END { print used/total*100}'");
2020-03-24 19:48:35 +01:00
return floor($used);
}
public function processorCount()
{
2020-03-24 19:48:35 +01:00
$procs = shell_exec("nproc --all");
return intval($procs);
}
public function loadAvg1Min()
{
2020-03-24 19:48:35 +01:00
$load = exec("awk '{print $1}' /proc/loadavg");
return floatval($load);
}
public function systemLoadPercentage()
{
2020-03-24 19:48:35 +01:00
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
}
public function systemTemperature()
{
2020-03-24 19:48:35 +01:00
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
return number_format((float)$cpuTemp/1000, 1);
}
public function hostapdStatus()
{
2020-03-24 19:48:35 +01:00
exec('pidof hostapd | wc -l', $status);
return $status;
}
2020-02-01 12:06:41 +01:00
2022-06-08 19:21:50 +02:00
public function operatingSystem()
{
$os_desc = shell_exec("lsb_release -sd");
return $os_desc;
}
public function kernelVersion()
{
$kernel = shell_exec("uname -r");
return $kernel;
}
2020-02-01 12:06:41 +01:00
}