summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2012-06-26 23:27:49 +0200
committerPaul Buetow <paul@buetow.org>2012-06-26 23:27:49 +0200
commit3cb86d60de05cfa94790f5b822ba25b742c090a1 (patch)
tree5b6f3072f78a86ec1d49ceecdae62e6e80c2be00
parentcfc4f47dff63d62d0c2255f7c1416205986b6242 (diff)
add gbit link speed for netstats. add --netint param to specify the network interface
-rw-r--r--lib/Loadbars/Constants.pm2
-rw-r--r--lib/Loadbars/HelpDispatch.pm7
-rw-r--r--lib/Loadbars/Main.pm13
-rw-r--r--lib/Loadbars/Shared.pm3
4 files changed, 18 insertions, 7 deletions
diff --git a/lib/Loadbars/Constants.pm b/lib/Loadbars/Constants.pm
index 5685c81..c9913ae 100644
--- a/lib/Loadbars/Constants.pm
+++ b/lib/Loadbars/Constants.pm
@@ -34,6 +34,8 @@ use constant {
INTERVAL_MEM => 1.0,
INTERVAL_SDL => 0.14,
INTERVAL_SDL_WARN => 1.0,
+ BYTES_MBIT => 125000,
+ BYTES_GBIT => 125000000,
SUCCESS => 0,
E_UNKNOWN => 1,
E_NOHOST => 2,
diff --git a/lib/Loadbars/HelpDispatch.pm b/lib/Loadbars/HelpDispatch.pm
index 69878ed..03a8c44 100644
--- a/lib/Loadbars/HelpDispatch.pm
+++ b/lib/Loadbars/HelpDispatch.pm
@@ -97,6 +97,13 @@ END
mode => 1
},
+ netint => {
+ menupos => 6,
+ help => 'Interface to show netstats for (default: eth0)',
+ mode => 6,
+ type => 's'
+ },
+
barwidth => {
menupos => 9,
help => 'Set bar width',
diff --git a/lib/Loadbars/Main.pm b/lib/Loadbars/Main.pm
index cc30c82..df04c39 100644
--- a/lib/Loadbars/Main.pm
+++ b/lib/Loadbars/Main.pm
@@ -402,8 +402,7 @@ sub loop ($@) {
my %net_history;
- my $net_max_bytes = 0;
- my $net_max_packets = 0;
+ my $net_max_bytes = Loadbars::Constants->BYTES_GBIT;
my $sdl_redraw_background = 0;
my $sdl_font_height = 14;
@@ -745,7 +744,7 @@ sub loop ($@) {
if ( $C{shownet} && exists $NETSTATS_HAS{$host}) {
$add_x += $width + 1;
- my $int = 'wlan0';
+ my $int = $C{netint};
my $key = "$host;$int";
$net_history{$key} = [net_parse \$NETSTATS{$key}]
@@ -757,13 +756,15 @@ sub loop ($@) {
push @{$net_history{$key}}, $now_stat_r;
shift @{$net_history{$key}} while $C{netaverage} < @{$net_history{$key}};
- my $diff_stat_r = net_diff $now_stat_r->[0], $prev_stat_r->[0];
+ #my $diff_stat_r = net_diff $now_stat_r->[0], $prev_stat_r->[0];
- $net_max_bytes = $diff_stat_r->{b} if $diff_stat_r->{b} > $net_max_bytes;
- $net_max_bytes = $diff_stat_r->{tb} if $diff_stat_r->{tb} > $net_max_bytes;
+ #$net_max_bytes = $diff_stat_r->{b} if $diff_stat_r->{b} > $net_max_bytes;
+ #$net_max_bytes = $diff_stat_r->{tb} if $diff_stat_r->{tb} > $net_max_bytes;
my $net_per = percentage $net_max_bytes, $diff_stat_r->{b};
my $tnet_per = percentage $net_max_bytes, $diff_stat_r->{tb};
+ my $net_per = percentage $net_max_bytes, $diff_stat_r->{b};
+ my $tnet_per = percentage $net_max_bytes, $diff_stat_r->{tb};
#use Data::Dumper;
# print "$net_max_bytes $diff_stat_r->{b} $net_per ; $net_max_bytes $diff_stat_r->{tb} $tnet_per\n";
diff --git a/lib/Loadbars/Shared.pm b/lib/Loadbars/Shared.pm
index d1c737f..d049800 100644
--- a/lib/Loadbars/Shared.pm
+++ b/lib/Loadbars/Shared.pm
@@ -48,13 +48,14 @@ our %I : shared;
factor => 1,
hasagent => 0,
height => 230,
- maxwidth => 1280,
+ maxwidth => 1250,
showcores => 0,
showmem => 0,
shownet => 0,
showtext => 1,
showtexthost => 0,
sshopts => '',
+ netint => 'eth0',
);
%I = (