2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

[FIX] wfsolr_indexSize: always output values in the same unit (MB)

This commit is contained in:
intsimoa 2012-07-07 11:50:44 +02:00
parent 94c75daa81
commit 5c77c1a93b

View File

@ -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);
}
}