mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 01:54:49 +00:00
(systemhealth) fix for rrd files without topic in them, like ntpd
This commit is contained in:
parent
852b7e7147
commit
bc37482fb5
@ -457,7 +457,7 @@ class SystemhealthController extends ApiControllerBase
|
||||
|
||||
/**
|
||||
* retrieve descriptive details of rrd
|
||||
* @param string $rrd rrd filename
|
||||
* @param string $rrd rrd category - item
|
||||
* @return array result status and data
|
||||
*/
|
||||
private function getRRDdetails($rrd)
|
||||
@ -466,15 +466,22 @@ class SystemhealthController extends ApiControllerBase
|
||||
$result = array();
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdpRun("systemhealth list");
|
||||
$output= json_decode($response, true);
|
||||
if (is_array($output) && array_key_exists($rrd, $output)) {
|
||||
$result["result"] = "ok";
|
||||
$result["data"] = $output[$rrd];
|
||||
} else {
|
||||
// always return a valid (empty) data set
|
||||
$result["result"] = "not found";
|
||||
$result["data"] = ["title"=>"","y-axis_label"=>"","field_units"=>[]];
|
||||
$healthList = json_decode($response, true);
|
||||
// search by topic and name, return array with filename
|
||||
if (is_array($healthList)) {
|
||||
foreach ($healthList as $filename => $healthItem) {
|
||||
if ($healthItem['itemName'] .'-' . $healthItem['topic'] == $rrd) {
|
||||
$result["result"] = "ok";
|
||||
$healthItem['filename'] = $filename;
|
||||
$result["data"] = $healthItem;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// always return a valid (empty) data set
|
||||
$result["result"] = "not found";
|
||||
$result["data"] = ["title"=>"","y-axis_label"=>"","field_units"=>[], "itemName" => "", "filename" => ""];
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -485,7 +492,7 @@ class SystemhealthController extends ApiControllerBase
|
||||
*/
|
||||
public function getRRDlistAction()
|
||||
{
|
||||
# Suurce of data: filelisting of /var/db/rrd/*.rrd
|
||||
# Source of data: filelisting of /var/db/rrd/*.rrd
|
||||
$result = array();
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdpRun("systemhealth list");
|
||||
@ -536,9 +543,13 @@ class SystemhealthController extends ApiControllerBase
|
||||
|
||||
$rrd_details=$this->getRRDdetails($rrd)["data"];
|
||||
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdpRun("systemhealth fetch ", array($rrd));
|
||||
$xml = simplexml_load_string($response);
|
||||
if ($rrd_details['filename'] != "") {
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdpRun("systemhealth fetch ", array($rrd_details['filename']));
|
||||
$xml = simplexml_load_string($response);
|
||||
} else {
|
||||
$xml = false;
|
||||
}
|
||||
|
||||
if ($xml !== false) {
|
||||
// we only use the average databases in any RRD, remove the rest to avoid strange behaviour.
|
||||
|
||||
@ -188,11 +188,7 @@
|
||||
}
|
||||
|
||||
subitem=data["data"][category][0]; // first sub item
|
||||
if (category=="system") {
|
||||
rrd_name = category + '-' + subitem;
|
||||
} else {
|
||||
rrd_name = subitem + '-' + category;
|
||||
}
|
||||
rrd_name = subitem + '-' + category;
|
||||
|
||||
// create dropdown menu
|
||||
tabs+='<a data-toggle="dropdown" href="#" class="dropdown-toggle pull-right visible-lg-inline-block visible-md-inline-block visible-xs-inline-block visible-sm-inline-block" role="button" style="border-left: 1px dashed lightgray;">';
|
||||
@ -205,11 +201,7 @@
|
||||
// add subtabs
|
||||
for (var count=0; count<data["data"][category].length;++count ) {
|
||||
subitem=data["data"][category][count];
|
||||
if (category=="system") {
|
||||
rrd_name = category + '-' + subitem;
|
||||
} else {
|
||||
rrd_name = subitem + '-' + category;
|
||||
}
|
||||
rrd_name = subitem + '-' + category;
|
||||
|
||||
if (subitem==active_subitem) {
|
||||
tabs += '<li class="active"><a data-toggle="tab" onclick="getdata(\''+rrd_name+'\',0,0,120,0);" id="'+rrd_name+'"><i class="fa fa-check-square"></i> ' + subitem[0].toUpperCase() + subitem.slice(1) + '</a></li>';
|
||||
|
||||
@ -46,6 +46,10 @@ for filename in glob.glob('%s/*.rrd' % rrd_reports_dir):
|
||||
if rrdFilename.split('-')[0] == 'system' and rrdFilename.find('-') > -1:
|
||||
topic = rrdFilename.split('-')[0]
|
||||
itemName = '-'.join(rrdFilename.split('-')[1:])
|
||||
elif rrdFilename.find('-') == -1:
|
||||
# set topic for items without one
|
||||
topic = 'services'
|
||||
itemName = rrdFilename.split('.')[0]
|
||||
else:
|
||||
topic = rrdFilename.split('-')[-1]
|
||||
itemName = '-'.join(rrdFilename.split('-')[:-1])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user