Perl的。连接速度检查

时间:2016-12-01 06:28:53

标签: perl

我是perl的新手,我有一个功能可以检查网址是否可用。 我还需要测量该函数中的连接速度。 谁能告诉我怎么做?

sub CheckLink
{
    syslog('info', "Checking link state");
    $last_check = time;
    syslog('err', "Impossible to check link: OpenVPN have not connected yet") and return 1 unless $state eq 'online';
    my $http = HTTP::Lite->new;
    $http->local_addr($loc_ip);
    my $req = $http->request(CHECK_URL_1);
    unless ($req) {
        syslog('err', "Link check WARN: Unable to fetch CHECK_URL_1 ".CHECK_URL_1);
        $req = $http->request(CHECK_URL_2);
    }
    syslog('info', "Link check is succesful") and return 1 if $req;
    syslog('err', "Link check FAILED: Unable to fetch CHECK_URL_2 ".CHECK_URL_2);
    return 0;
}

0 个答案:

没有答案