From 5c77c1a93b85f791c03a9760fcb2c2c1684755a5 Mon Sep 17 00:00:00 2001 From: intsimoa Date: Sat, 7 Jul 2012 11:50:44 +0200 Subject: [PATCH] [FIX] wfsolr_indexSize: always output values in the same unit (MB) --- plugins/solr/wfsolr_ | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/solr/wfsolr_ b/plugins/solr/wfsolr_ index 1473979b..01408f39 100755 --- a/plugins/solr/wfsolr_ +++ b/plugins/solr/wfsolr_ @@ -104,6 +104,24 @@ function getSolrAdminUrl($core = null) return $url; } +/** + * Assure some conversions. KB and GB converted to MB + */ +function wffloatval($val) +{ + $fVal = floatval(str_replace(",", ".", $val)); + $valEnd = substr($val, -2); + if ($valEnd == "KB") + { + $fVal = $fVal / 1024; + } + elseif ($valEnd == "GB") + { + $fVal = $fVal * 1024; + } + return $fVal; +} + if ("config" == $action) { echo 'graph_category Solr ' . $core . "\n"; @@ -171,7 +189,7 @@ else { if($property == trim($stat->getAttribute('name'))) { - echo $core . $item . $property . 'solr.value ' . floatval(trim($stat->textContent)) . "\n"; + echo $core . $item . $property . 'solr.value ' . wffloatval(trim($stat->textContent)) . "\n"; exit(0); } }