터치 패널 그래프와 상태 점멸 기준 추가
This commit is contained in:
1 parent
e99fe1021a
commit
209b587eac
2 files changed
+248
-27
No files matched your search
@@ -4,6 +4,29 @@ declare(strict_types=1);
|
||||
define('CONTROL_API_LIBRARY', true);
|
||||
require_once __DIR__ . '/../public/api.php';
|
||||
|
||||
function touch_panel_io_counters(): array
|
||||
{
|
||||
$reads = 0;
|
||||
$writes = 0;
|
||||
foreach (@file('/proc/diskstats', FILE_IGNORE_NEW_LINES) ?: [] as $line) {
|
||||
$parts = preg_split('/\s+/', trim($line));
|
||||
if (count($parts) < 14) {
|
||||
continue;
|
||||
}
|
||||
$name = (string)$parts[2];
|
||||
if (preg_match('/^(loop|ram|zram|dm-)/', $name)) {
|
||||
continue;
|
||||
}
|
||||
$reads += (int)$parts[3];
|
||||
$writes += (int)$parts[7];
|
||||
}
|
||||
|
||||
return [
|
||||
'reads' => $reads,
|
||||
'writes' => $writes,
|
||||
];
|
||||
}
|
||||
|
||||
function touch_panel_snapshot(array $snapshot): array
|
||||
{
|
||||
$network = is_array($snapshot['network'] ?? null) ? $snapshot['network'] : [];
|
||||
@@ -25,6 +48,10 @@ function touch_panel_snapshot(array $snapshot): array
|
||||
'tx_errors' => $row['tx_errors'] ?? 0,
|
||||
'rx_dropped' => $row['rx_dropped'] ?? 0,
|
||||
'tx_dropped' => $row['tx_dropped'] ?? 0,
|
||||
'rx_bytes' => $row['rx_bytes'] ?? 0,
|
||||
'tx_bytes' => $row['tx_bytes'] ?? 0,
|
||||
'rx_packets' => $row['rx_packets'] ?? 0,
|
||||
'tx_packets' => $row['tx_packets'] ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -63,6 +90,27 @@ function touch_panel_snapshot(array $snapshot): array
|
||||
'touch_display' => [
|
||||
'connected' => $touch['connected'] ?? false,
|
||||
],
|
||||
'io' => touch_panel_io_counters(),
|
||||
'history' => array_map(static function (array $row): array {
|
||||
return [
|
||||
'time' => $row['time'] ?? null,
|
||||
'temp_c' => $row['temp_c'] ?? null,
|
||||
'fan_rpm' => $row['fan_rpm'] ?? null,
|
||||
'fan_pwm' => $row['fan_pwm'] ?? null,
|
||||
'cpu_load_1' => $row['cpu_load_1'] ?? null,
|
||||
'mem_percent' => $row['mem_percent'] ?? null,
|
||||
];
|
||||
}, array_slice(array_values(array_filter($snapshot['history'] ?? [], 'is_array')), -80)),
|
||||
'network_history' => array_map(static function (array $row): array {
|
||||
return [
|
||||
'time' => $row['time'] ?? null,
|
||||
'iface' => $row['iface'] ?? null,
|
||||
'rx_mbps' => $row['rx_mbps'] ?? 0,
|
||||
'tx_mbps' => $row['tx_mbps'] ?? 0,
|
||||
'rx_pps' => $row['rx_pps'] ?? 0,
|
||||
'tx_pps' => $row['tx_pps'] ?? 0,
|
||||
];
|
||||
}, array_slice(array_values(array_filter($snapshot['network_history'] ?? [], 'is_array')), -240)),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user