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

58 lines
1.3 KiB
PHP
Raw Normal View History

2020-02-02 12:55:10 +01:00
<?php
2020-02-15 18:57:46 +01:00
require_once 'app/lib/system.php';
2020-02-02 12:55:10 +01:00
2021-08-03 16:18:36 +02:00
$system = new \RaspAP\System\Sysinfo;
2020-02-02 12:55:10 +01:00
$hostname = $system->hostname();
$uptime = $system->uptime();
$cores = $system->processorCount();
// mem used
$memused = $system->usedMemory();
$memused_status = "primary";
if ($memused > 90) {
2020-02-02 13:40:24 +01:00
$memused_status = "danger";
2020-02-03 10:32:16 +01:00
$memused_led = "service-status-down";
2020-02-02 12:55:10 +01:00
} elseif ($memused > 75) {
2020-02-02 13:40:24 +01:00
$memused_status = "warning";
2020-02-03 10:32:16 +01:00
$memused_led = "service-status-warn";
2020-02-02 12:55:10 +01:00
} elseif ($memused > 0) {
2020-02-02 13:40:24 +01:00
$memused_status = "success";
2020-02-03 10:32:16 +01:00
$memused_led = "service-status-up";
2020-02-02 12:55:10 +01:00
}
// cpu load
$cpuload = $system->systemLoadPercentage();
if ($cpuload > 90) {
2020-02-02 13:40:24 +01:00
$cpuload_status = "danger";
2020-02-02 12:55:10 +01:00
} elseif ($cpuload > 75) {
2020-02-02 13:40:24 +01:00
$cpuload_status = "warning";
2020-03-24 19:48:35 +01:00
} elseif ($cpuload >= 0) {
2020-02-02 13:40:24 +01:00
$cpuload_status = "success";
2020-02-02 12:55:10 +01:00
}
// cpu temp
$cputemp = $system->systemTemperature();
if ($cputemp > 70) {
2020-02-02 13:40:24 +01:00
$cputemp_status = "danger";
2020-02-03 10:32:16 +01:00
$cputemp_led = "service-status-down";
2020-02-02 12:55:10 +01:00
} elseif ($cputemp > 50) {
2020-02-02 13:40:24 +01:00
$cputemp_status = "warning";
2020-02-03 10:32:16 +01:00
$cputemp_led = "service-status-warn";
2020-02-02 12:55:10 +01:00
} else {
2020-02-02 13:40:24 +01:00
$cputemp_status = "success";
2020-02-03 10:32:16 +01:00
$cputemp_led = "service-status-up";
2020-02-02 12:55:10 +01:00
}
// hostapd status
$hostapd = $system->hostapdStatus();
2020-02-02 13:40:24 +01:00
if ($hostapd[0] ==1) {
$hostapd_status = "active";
$hostapd_led = "service-status-up";
2020-02-02 12:55:10 +01:00
} else {
2020-02-02 13:40:24 +01:00
$hostapd_status = "inactive";
$hostapd_led = "service-status-down";
2020-02-02 12:55:10 +01:00
}