Skip to content

Commit

Permalink
Add facility to return CPU and fans data in live stats 1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Oct 25, 2024
1 parent 700ad90 commit 851f348
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions stats-lib-funcs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 => []}]
}
};
}
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 851f348

Please sign in to comment.