3 # Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
4 # Swiss federal institute of technology (ETH Zurich)
7 # apt-get install libcurses-ui-perl
15 my ($cui, $win, $widget);
25 opendir(LD
, "/proc/net/lana/") or die $!;
26 @files = grep(/ppe\d/, readdir(LD
));
28 if ($#files + 1 - $[ == 0) {
29 die "LANA not running?!";
35 foreach my $file (@files) {
40 open(LH
, "<", "/proc/net/lana/$file") or die $!;
42 if (/(packets|bytes|errors|drops):\s+(\d+)/) {
48 my $tmp = ${${$stats{$file}}{$_}}{new
};
49 ${${$stats{$file}}{$_}}{old
} = $tmp;
50 ${${$stats{$file}}{$_}}{new
} = $curr{$_};
59 $text = "LANA ppe top:\n\n";
60 foreach my $file (@files) {
61 my $pps = ${${$stats{$file}}{packets
}}{new
} -
62 ${${$stats{$file}}{packets
}}{old
};
63 my $mbs = int((${${$stats{$file}}{bytes
}}{new
} -
64 ${${$stats{$file}}{bytes
}}{old
}) /
66 my $eps = ${${$stats{$file}}{errors
}}{new
} -
67 ${${$stats{$file}}{errors
}}{old
};
68 my $dps = ${${$stats{$file}}{drops
}}{new
} -
69 ${${$stats{$file}}{drops
}}{old
};
71 $text .= "\t$pps\tpkts/s\n";
72 $text .= "\t$mbs\tMiB/s\n";
73 $text .= "\t$dps\tdrops/s\n";
74 $text .= "\t$eps\terr/s\n\n";
79 $text .= "\t$pps_total\tpkts/s\n";
80 $text .= "\t$mbs_total\tMiB/s\n";
98 $text = "Collecting statistics, please wait ...\n";
99 $cui = new Curses
::UI
(-color_support
=> 1);
100 $cui->set_binding(\
&exit_bind
, "\cQ", "\cC");
101 $win = $cui->add('screen', 'Window',
104 $widget = $win->add('ppetop', 'TextViewer',
108 $widget->clear_binding('loose_focus');
110 $cui->set_timer('ppetop_stats', \
&main_stats
, 1);
111 $cui->enable_timer('ppetop_stats');