잔여 시간 차트 최신값 동기화

This commit is contained in:
seo
2026-06-26 02:41:54 +09:00
parent 68079e7ff4
commit b0714f9ff2
2 changed files with 50 additions and 3 deletions
+43
View File
@@ -1211,6 +1211,26 @@ function add_battery_remaining_history(array $history): array
return $history;
}
function sync_current_battery_remaining_history(array $history, array $currentRow, mixed $remainingSeconds): array
{
$currentRow['battery_remaining_seconds'] = is_numeric($remainingSeconds)
? (int)round((float)$remainingSeconds)
: null;
$now = strtotime((string)($currentRow['time'] ?? ''));
$lastIndex = count($history) - 1;
if ($lastIndex >= 0) {
$lastTime = strtotime((string)($history[$lastIndex]['time'] ?? ''));
if ($now > 0 && $lastTime > 0 && abs($now - $lastTime) <= 5) {
$history[$lastIndex] = array_merge($history[$lastIndex], $currentRow);
return $history;
}
}
$history[] = $currentRow;
return array_slice($history, -240);
}
function process_service_name(int $pid): string
{
$cgroup = @file('/proc/' . $pid . '/cgroup', FILE_IGNORE_NEW_LINES) ?: [];
@@ -2709,6 +2729,29 @@ function collect_snapshot(bool $applyFan = true): array
$batteryTrend = battery_trend_history(24);
$batteryProfile = battery_profile_history(45);
$battery['remaining'] = battery_remaining_estimate($battery, $history, $batteryTrend, $batteryProfile);
$history = sync_current_battery_remaining_history($history, [
'time' => date('Y-m-d H:i:s'),
'temp_c' => $temp,
'fan_rpm' => $rpm,
'fan_efficiency' => fan_efficiency($rpm, $temp, $cpuPower['watts'] ?? null),
'rp1_temp_c' => rp1_temp_c(),
'cpu_voltage' => $cpuPower['voltage'],
'cpu_watts' => $cpuPower['watts'],
'battery_voltage' => $battery['voltage'],
'battery_percent' => $battery['percent'],
'fan_pwm' => $pwm,
'pwm_percent' => round($pwm / 255 * 100, 2),
'pwm_mode' => $policy['mode'],
'cpu_load_1' => round((float)$load[0], 2),
'cpu_load_5' => round((float)$load[1], 2),
'cpu_load_15' => round((float)$load[2], 2),
'disk_total_kb' => $disk['total_kb'],
'disk_used_kb' => $disk['used_kb'],
'disk_free_kb' => $disk['free_kb'],
'mem_total_mb' => $mem['total_mb'],
'mem_used_mb' => $mem['used_mb'],
'mem_percent' => $mem['total_mb'] > 0 ? round($mem['used_mb'] / $mem['total_mb'] * 100, 1) : 0,
], $battery['remaining']['seconds'] ?? null);
$processes = process_resource_data(6);
$fanSpike = fan_spike_analysis($history, $fan, $system, $processes);