0

有人知道一个模块,它具有返回(例如 eth0 )下载速度的功能吗?

4

2 回答 2

2

使用监控程序:atop、iftop、ntop、dstat、icinga、munin、knemo、ksysguardd

于 2012-04-11T09:33:49.507 回答
0
#!/usr/bin/perl

use strict;
use warnings;
use Time::HiRes;
use LWP::Simple;

my $url = 'http://www.cnn.com/';
my $file = 'cnn.html';
my $start = [Time::HiRes::gettimeofday()];
getstore($url, $file);
my $time = Time::HiRes::tv_interval($start);
my $size = -s $file;

printf "Speed: %d kbps\n", $size/$time/1000;
于 2012-04-11T16:39:00.363 回答