From d697f904dcc0cb0aa983cd92fe332dae9dd76ae9 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 7 Dec 2014 16:21:26 -0800 Subject: [PATCH] More work on new system inf ofunction --- system-status/system_info.pl | 67 +++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/system-status/system_info.pl b/system-status/system_info.pl index b962282d0..11faca3c3 100644 --- a/system-status/system_info.pl +++ b/system-status/system_info.pl @@ -86,19 +86,78 @@ if (&foreign_check("proc")) { if (&foreign_available("proc")) { $pr = &ui_link('/proc/', $pr); } - push(@rv, { 'desc' => $text{'right_procs'}, - 'value' => $pr }); + push(@table, { 'desc' => $text{'right_procs'}, + 'value' => $pr }); } # Load averages if ($info->{'load'}) { my @c = @{$info->{'load'}}; if (@c) { - push(@rv, { 'desc' => $text{'right_cpu'}, - 'value' => &text('right_load', @c) }); + push(@table, { 'desc' => $text{'right_cpu'}, + 'value' => &text('right_load', @c) }); } } +# CPU usage +if ($info->{'cpu'}) { + my @c = @{$info->{'cpu'}}; + push(@table, { 'desc' => $text{'right_cpuuse'}, + 'value' => &text('right_cpustats', @c) }); + } + +# Memory usage +if ($info->{'mem'}) { + my @m = @{$info->{'mem'}}; + if (@m && $m[0]) { + push(@table, { 'desc' => $text{'right_real'}, + 'value' => &text('right_used', + &nice_size($m[0]*1024), + &nice_size(($m[0]-$m[1])*1024)), + 'chart' => [ $m[0], $m[0]-$m[1] ] }); + } + + if (@m && $m[2]) { + push(@table, { 'desc' => $text{'right_virt'}, + 'value' => &text('right_used', + &nice_size($m[2]*1024), + &nice_size(($m[2]-$m[3])*1024)), + 'chart' => [ $m[2], $m[2]-$m[3] ] }); + } + } + +# Disk space on local drives +if ($info->{'disk_total'}) { + my ($total, $free) = ($info->{'disk_total'}, $info->{'disk_free'}); + push(@table, { 'desc' => $text{'right_disk'}, + 'value' => &text('right_used', + &nice_size($total), + &nice_size($total-$free)), + 'chart' => [ $total, $total-$free ] }); + } + +# Package updates +if ($info->{'poss'}) { + print " $text{'right_updates'}\n"; + my @poss = @{$info->{'poss'}}; + my @secs = grep { $_->{'security'} } @poss; + my $msg; + if (@poss && @secs) { + $msg = &text('right_upsec', scalar(@poss), + scalar(@secs)); + } + elsif (@poss) { + $msg = &text('right_upneed', scalar(@poss)); + } + else { + $msg = $text{'right_upok'}; + } + if (&foreign_available("package-updates")) { + $msg = "$msg"; + } + print "$msg \n"; + } + return @rv; }