1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-01 01:52:18 +01:00

Simplify.

This commit is contained in:
Simon Josefsson 2010-11-15 10:48:52 +00:00
parent cc121fb2d3
commit 26e4c45800

View File

@ -8,16 +8,17 @@ require_once 'ykval-synclib.php';
require_once 'ykval-config.php'; require_once 'ykval-config.php';
require_once 'ykval-log.php'; require_once 'ykval-log.php';
function ksmurl2shortname ($ksmurl) { function url2shortname ($url) {
if (preg_match("/^[^\/]+\/\/([a-z0-9-]+)/", $ksmurl, $ksmname)==0){ if (preg_match("/^[^\/]+\/\/([a-z0-9-]+)/", $url, $name)==0){
echo "Cannot match ksm name: " . $ksmurl . "\n"; echo "Cannot match URL hostname: " . $url . "\n";
exit (1); exit (1);
} }
return $ksmname[1]; return $name[1];
} }
$ksms = otp2ksmurls ("ccccccccfnkjtvvijktfrvvginedlbvudjhjnggndtck", 16); $ksms = otp2ksmurls ("ccccccccfnkjtvvijktfrvvginedlbvudjhjnggndtck", 16);
$shortksms = array_map("ksmurl2shortname", $ksms); $shortksms = array_map("url2shortname", $ksms);
if ($argc==2 && strcmp($argv[1], "autoconf") == 0) { if ($argc==2 && strcmp($argv[1], "autoconf") == 0) {
print "yes\n"; print "yes\n";
@ -43,9 +44,9 @@ if ($argc==2 && strcmp($argv[1], "config") == 0) {
exit (0); exit (0);
} }
echo "multigraph diskstats_latency\n"; echo "multigraph yk_latency\n";
foreach ($ksms as $ksm) { foreach ($ksms as $ksm) {
$shortksm = ksmurl2shortname ($ksm); $shortksm = url2shortname ($ksm);
$time = `curl --silent --write-out '%{time_total}' --max-time 3 '$ksm' -o /dev/null`; $time = `curl --silent --write-out '%{time_total}' --max-time 3 '$ksm' -o /dev/null`;
echo "${shortksm}_avgwait.value $time\n"; echo "${shortksm}_avgwait.value $time\n";
} }