raspap-webgui-mirror/includes/sysstats.php

58 lines
1.3 KiB
PHP
Raw Normal View History

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