From 69a3c4417c4a3ff581bb64c83beb02aadcf37f6b Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Tue, 8 Sep 2015 09:19:39 +0200 Subject: [PATCH] Refactor ykval-munin-ksmlatency plugin. - depend on libcurl instead of curl binary. - due to this commit, requests sent to KSM URLs will contain a User-Agent header. --- ykval-munin-ksmlatency.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ykval-munin-ksmlatency.php b/ykval-munin-ksmlatency.php index ef232b4..1608a1f 100755 --- a/ykval-munin-ksmlatency.php +++ b/ykval-munin-ksmlatency.php @@ -31,6 +31,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . "/etc/yubico/val:/usr/share/yubikey-val"); require_once 'ykval-config.php'; +require_once 'ykval-common.php'; function url2shortname ($url) { @@ -76,17 +77,9 @@ echo "multigraph ykval_ksmlatency\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 (($total_time = total_time($ksm)) === FALSE) + $total_time = 'error'; - if (preg_match("/^0\.000/", $time)) - { - $time = "error"; - } - - echo "${shortksm}_avgwait.value $time\n"; + echo "${shortksm}_avgwait.value $total_time\n"; }