네트워크 이력 차트 원본 선 표시
This commit is contained in:
+25
-5
@@ -1022,13 +1022,26 @@ function primary_network_interface(array $network): ?array
|
||||
return $rows[0] ?? null;
|
||||
}
|
||||
|
||||
function add_network_usage_log(array $network): void
|
||||
function network_log_interfaces(array $network): array
|
||||
{
|
||||
$iface = primary_network_interface($network);
|
||||
if (!$iface) {
|
||||
return;
|
||||
$targets = [];
|
||||
$primary = primary_network_interface($network);
|
||||
if ($primary) {
|
||||
$targets[(string)($primary['name'] ?? '')] = $primary;
|
||||
}
|
||||
|
||||
foreach ((array)($network['interfaces'] ?? []) as $row) {
|
||||
if (($row['name'] ?? '') === 'br0') {
|
||||
$targets['br0'] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
unset($targets['']);
|
||||
return array_values($targets);
|
||||
}
|
||||
|
||||
function add_network_usage_log_for_interface(array $iface): void
|
||||
{
|
||||
$name = (string)($iface['name'] ?? '');
|
||||
$rxBytes = isset($iface['rx_bytes']) ? (int)$iface['rx_bytes'] : -1;
|
||||
$txBytes = isset($iface['tx_bytes']) ? (int)$iface['tx_bytes'] : -1;
|
||||
@@ -1119,6 +1132,13 @@ function add_network_usage_log(array $network): void
|
||||
]);
|
||||
}
|
||||
|
||||
function add_network_usage_log(array $network): void
|
||||
{
|
||||
foreach (network_log_interfaces($network) as $iface) {
|
||||
add_network_usage_log_for_interface($iface);
|
||||
}
|
||||
}
|
||||
|
||||
function network_usage_history(int $limit = 240): array
|
||||
{
|
||||
$limit = max(1, min(1500, $limit));
|
||||
@@ -4530,7 +4550,7 @@ function collect_snapshot(bool $applyFan = true): array
|
||||
$fanSpike = fan_spike_analysis($history, $fan, $system, $processes);
|
||||
$network = network_info();
|
||||
add_network_usage_log($network);
|
||||
$networkHistory = network_usage_history(240);
|
||||
$networkHistory = network_usage_history(480);
|
||||
|
||||
$shouldLogNotice = !empty($fanSpike['alert_started'])
|
||||
|| (!empty($fanSpike['active']) && (bool)setting_value('notice.log_during_alert'));
|
||||
|
||||
Reference in New Issue
Block a user