From 851f34851614d287dc923ed2d55a7f15dc55b095 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 25 Oct 2024 20:57:56 +0300 Subject: [PATCH] Add facility to return CPU and fans data in live stats 1/2 --- stats-lib-funcs.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/stats-lib-funcs.pl b/stats-lib-funcs.pl index 0ccbab7fb..9f71253a2 100644 --- a/stats-lib-funcs.pl +++ b/stats-lib-funcs.pl @@ -37,6 +37,7 @@ disk => acl_system_status('disk'), net => acl_system_status('net'), virt => acl_system_status('virt'), + temp => acl_system_status('temp'), }; # Check if feature is enabled @@ -72,7 +73,8 @@ sub get_stats_empty virt => [{x => $time, y => 0}], proc => [{x => $time, y => 0}], disk => [{x => $time, y => [0, 0]}], - net => [{x => $time, y => [0, 0]}] + net => [{x => $time, y => [0, 0]}], + temp => [{x => $time, y => []}] } }; } @@ -162,6 +164,15 @@ sub get_stats_now undef($in); undef($out); } + # Temperature and fans + if ($acl_system_status->{'temp'}) { + my ($cpu, $fans) = defined(&proc::get_current_cpu_data) ? + proc::get_current_cpu_data() : (undef, undef); + if ($cpu || $fans) { + $data{'temp'} = [{c => $cpu, f => $fans}]; + # $gadd->('temp', [{c => $cpu, f => $fans}]); + } + } # Reverse output for LTR users if (get_text_ltr()) { my @watched = ('mem', 'virt', 'disk'); @@ -203,7 +214,8 @@ sub get_stats_history # Check if still avilable based on current ACLs my %map = (cpu => ['cpu', 'disk'], mem => ['mem', 'virt'], - load => ['proc', 'net']); + load => ['proc', 'net', + 'temp']); foreach my $key (keys %map) { my $feature = $acl_system_status->{$key}; unless ($feature) {