diff options
| author | Paul Buetow <paul@buetow.org> | 2012-06-23 12:17:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2012-06-23 12:17:45 +0200 |
| commit | df544c6d247661daaa1002a32fb281bf453058ba (patch) | |
| tree | e5fd31f3ef41d332c0eb4ac581a33a3fbbd3beec /lib/Loadbars | |
| parent | 6d48029a215f90482777db4a9f169c404f26167a (diff) | |
set INTERVAL to 1.13
Diffstat (limited to 'lib/Loadbars')
| -rw-r--r-- | lib/Loadbars/Constants.pm | 2 | ||||
| -rw-r--r-- | lib/Loadbars/Main.pm | 21 | ||||
| -rw-r--r-- | lib/Loadbars/Shared.pm | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/Loadbars/Constants.pm b/lib/Loadbars/Constants.pm index 6d7b074..c32658b 100644 --- a/lib/Loadbars/Constants.pm +++ b/lib/Loadbars/Constants.pm @@ -27,7 +27,7 @@ use constant { SYSTEM_BLUE0 => 30, USER_ORANGE => 70, USER_YELLOW0 => 50, - INTERVAL => 0.125, + INTERVAL => 0.13, INTERVAL_WARN => 1.0, SUCCESS => 0, E_UNKNOWN => 1, diff --git a/lib/Loadbars/Main.pm b/lib/Loadbars/Main.pm index ab953f5..6314b07 100644 --- a/lib/Loadbars/Main.pm +++ b/lib/Loadbars/Main.pm @@ -91,6 +91,14 @@ sub stats_thread ($;$) { my ( $sigusr1, $sigterm ) = ( 0, 0 ); my $inter = Loadbars::Constants->INTERVAL; + # Precompile some regexp + my $loadavg_re = qr/^(\d+\.\d{2}) (\d+\.\d{2}) (\d+\.\d{2})/; + my $cpu_re = qr/$I{cpuregexp}/; + my @meminfo = + map { [$_, qr/^$_: *(\d+)/] } + (qw(MemTotal MemFree Buffers Cached SwapTotal SwapFree)); + my $whitespace_re = qr/ +/; + until ($sigterm) { my $bash = <<"BASH"; loadavg=/proc/loadavg @@ -126,13 +134,6 @@ BASH $SIG{USR1} = sub { $sigusr1 = 1 }; $SIG{TERM} = sub { $sigterm = 1 }; - # Precompile some regexp - my $loadavg_re = qr/^(\d+\.\d{2}) (\d+\.\d{2}) (\d+\.\d{2})/; - my $cpu_re = qr/$I{cpuregexp}/; - my @meminfo = - map { [$_, qr/^$_: *(\d+)/] } - (qw(MemTotal MemFree Buffers Cached SwapTotal SwapFree)); - # 0=cpu, 1=mem, 2=net my $mode = 0; @@ -164,8 +165,8 @@ BASH for my $meminfo (@meminfo) { if ($_ =~ $meminfo->[1]) { - $MEMSTATS_HAS{$host} = 1; $MEMSTATS{"$host;$meminfo->[0]"} = $1; + $MEMSTATS_HAS{$host} = 1 unless defined $MEMSTATS_HAS{$host}; } } } @@ -176,6 +177,10 @@ BASH } else { + my @split = split $whitespace_re, $_; + for (@split) { + } + $NETSTATS_HAS{$host} = 1 unless defined $NETSTATS_HAS{$host}; } } diff --git a/lib/Loadbars/Shared.pm b/lib/Loadbars/Shared.pm index 311367d..090a4a7 100644 --- a/lib/Loadbars/Shared.pm +++ b/lib/Loadbars/Shared.pm @@ -10,6 +10,8 @@ our @EXPORT = qw( %CPUSTATS %MEMSTATS %MEMSTATS_HAS + %NETSTATS + %NETSTATS_HAS %C %I ); |
