Commit 2bc81fac authored by Mike Hibler's avatar Mike Hibler

The technique of grabbing the last 20 records and picking the latest

non-NULL latency/BW from those was too simplistic.  With latency measurements
much more frequent than BW measurements, we often never got a valid BW
because we didn't go back far enough.

So now just do two queries for the most recent non-NULL value of each.
This could probably be done in a single query by joining the table with
itself...
parent ddbfb376
......@@ -323,49 +323,49 @@ sub get_plabinfo($@)
}
#
# BW and latency records are separate so we just grab the last 20
# and hope we get a legit value for both.
# BW and latency records are separate and there are, in general,
# a lot more latency measurements than BW measurements. So we
# make two queries grabbing the latest of each.
# Note that there are no loss measurements right now.
#
my ($del,$plr,$bw);
my ($del_stamp,$plr_stamp,$bw_stamp);
my $query_result =
DBQueryFatal("select latency,loss,bw,unixstamp from pair_data ".
DBQueryFatal("select latency,unixstamp from pair_data ".
" where ".
" srcsite_idx='$src_site' and ".
" dstsite_idx='$dst_site' and ".
" (latency is not null or ".
" loss is not null or bw is not null) ".
" latency is not null ".
$dateclause .
" order by unixstamp desc limit 20");
" order by unixstamp desc limit 1");
if (!$query_result->numrows) {
warn("*** Could not get pair data for ".
warn("*** Could not get latency data for ".
"$me ($src_site) --> $dstvnode ($dst_site)\n".
" defaulting to ".
"${DEF_BW}bps, ${DEF_DEL}ms, ${DEF_PLR}plr\n");
($del,$plr,$bw) = ($DEF_DEL, $DEF_PLR, $DEF_BW);
$del_stamp = $plr_stamp = $bw_stamp = time();
" defaulting to ${DEF_DEL}ms\n");
($del, $del_stamp) = ($DEF_DEL, time());
} else {
print "$src_ename ($me=$src_site) -> $dst_ename ($dstvnode=$dst_site):\n"
if ($showonly || $debug);
while (my ($_del,$_plr,$_bw,$_stamp) =
$query_result->fetchrow_array()) {
print " ($_del, $_plr, $_bw, $_stamp)\n"
if ($showonly || $debug);
if (!defined($del) && defined($_del)) {
$del = $_del;
$del_stamp = $_stamp;
($del, $del_stamp) = $query_result->fetchrow_array();
}
if (!defined($plr) && defined($_plr)) {
$plr = $_plr;
$plr_stamp = $_stamp;
}
if (!defined($bw) && defined($_bw)) {
$bw = $_bw;
$bw_stamp = $_stamp;
$query_result =
DBQueryFatal("select bw,unixstamp from pair_data ".
" where ".
" srcsite_idx='$src_site' and ".
" dstsite_idx='$dst_site' and ".
" bw is not null ".
$dateclause .
" order by unixstamp desc limit 1");
if (!$query_result->numrows) {
warn("*** Could not get bandwidth data for ".
"$me ($src_site) --> $dstvnode ($dst_site)\n".
" defaulting to ${DEF_BW}Kbps\n");
($bw, $bw_stamp) = ($DEF_BW, time());
} else {
($bw, $bw_stamp) = $query_result->fetchrow_array();
}
if ($showonly || $debug) {
print "$src_ename ($me=$src_site) -> $dst_ename ($dstvnode=$dst_site):\n";
print " (del=$del\@$del_stamp, bw=$bw\@$bw_stamp)\n";
}
#
......@@ -405,8 +405,12 @@ sub get_plabinfo($@)
if ($bw < 0);
}
#
# Compensate for round-trip nature.
# XXX need to handle plr
#
$del = int($del / 2 + 0.5);
}
$bw = int($bw + 0.5);
print "$src_ename -> $dst_ename: ".
"real=$dst_ip, bw=$bw, del=$del, plr=$plr\n"
......@@ -421,7 +425,7 @@ sub get_plabinfo($@)
print STDERR "$src_pname->$dst_ip: old values: bw=$lbw, del=$ldel, plr=$lplr\n"
if ($debug);
} else {
$lbw = $ldel = $lplr = -2;
$lbw = $ldel = $lplr = -1;
}
my $doit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment