1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-12-01 15:24:16 +01:00

Detect timeouts and errors in curl (such as resolver failures).

This commit is contained in:
Fredrik Thulin 2012-05-22 12:15:31 +02:00
parent 3954527d61
commit 2c9b57a0a0
2 changed files with 16 additions and 4 deletions

View File

@ -46,6 +46,12 @@ echo "multigraph yk_latency\n";
foreach ($ksms as $ksm) {
$shortksm = url2shortname ($ksm);
$time = `curl --silent --write-out '%{time_total}' --max-time 3 '$ksm' -o /dev/null`;
if (preg_match("/^3\./", $time)) {
$time = "timeout";
}
if (preg_match("/^0\.000/", $time)) {
$time = "error";
}
echo "${shortksm}_avgwait.value $time\n";
}

View File

@ -52,10 +52,16 @@ echo "multigraph ykval_latency\n";
foreach ($urls as $url) {
$shortname = url2shortname ($url);
$cmd = "--user-agent ykval-munin-vallatency/1.0 --silent --write-out '%{time_total}' --max-time 3 '$url' -o /dev/null";
$ipv4time = `curl --ipv4 $cmd`;
echo "ipv4${shortname}_avgwait.value $ipv4time\n";
$ipv6time = `curl --ipv6 $cmd`;
echo "ipv6${shortname}_avgwait.value $ipv6time\n";
foreach (array('ipv4', 'ipv6') as $ipv) {
$time = `curl --$ipv $cmd`;
if (preg_match("/^3\./", $time)) {
$time = "timeout";
}
if (preg_match("/^0\.000/", $time)) {
$time = "error";
}
echo "$ipv${shortname}_avgwait.value $time\n";
}
}
#%# family=auto