summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2010-11-07 11:14:54 +0000
committerPaul Buetow <paul@buetow.org>2010-11-07 11:14:54 +0000
commit8616ce2871f0dff62a9bb240cd070c8c7a3db504 (patch)
tree03b20edd467b4710e23433f14ab05696d920a2fd
parentcfec4e811b14dfebdb6883c8c743d170fcfc40d5 (diff)
added null function
-rwxr-xr-xcpuload.pl8
1 files changed, 7 insertions, 1 deletions
diff --git a/cpuload.pl b/cpuload.pl
index ef45c35..3ebfc25 100755
--- a/cpuload.pl
+++ b/cpuload.pl
@@ -129,6 +129,11 @@ sub draw_background ($$$) {
$app->update($rect);
}
+sub null ($) {
+ my $arg = shift;
+ return defined $arg ? $arg : 0;
+}
+
sub graph_stats ($$) {
my ($app, $colors) = @_;
@@ -155,6 +160,7 @@ sub graph_stats ($$) {
if ($new_num_stats != $num_stats) {
%prev_stats = ();
%last_loads = ();
+
$num_stats = $new_num_stats;
$width = WIDTH / $num_stats - 1;
draw_background $app, $colors, $rect_bg;
@@ -170,7 +176,7 @@ sub graph_stats ($$) {
}
my $prev_stat = $prev_stats{$key};
- my %loads = $stat{TOTAL} == $prev_stat->{TOTAL} ? %stat : map { $_ => $stat{$_} - $prev_stat->{$_} } keys %stat;
+ my %loads = null $stat{TOTAL} == null $prev_stat->{TOTAL} ? %stat : map { $_ => $stat{$_} - $prev_stat->{$_} } keys %stat;
$prev_stats{$key} = \%stat;
%loads = normalize_loads %loads;