Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge branch '2.6.x' of http://git.centreon.com/centreon into 2.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
querwin committed Apr 22, 2015
2 parents 6929424 + a363b39 commit 2023a1a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
27 changes: 26 additions & 1 deletion www/class/centreonCriticality.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function criticitiesConfigOnSTpl($service_id) {
if (isset($this->tree[$service_id]) && $this->tree[$service_id] != 0) {
return $this->tree[$service_id];
}
return array();
return 0;
}

/**
Expand Down Expand Up @@ -329,4 +329,29 @@ protected function getServiceCriticality($service_id) {
}
return 0;
}

function getHostTplCriticities($host_id, $cache) {
global $pearDB;

if (!$host_id) {
return NULL;
}

$rq = "SELECT host_tpl_id " .
"FROM host_template_relation " .
"WHERE host_host_id = '".$host_id."' " .
"ORDER BY `order`";
$DBRESULT = $pearDB->query($rq);
while ($row = $DBRESULT->fetchRow()) {
if (isset($cache[$row['host_tpl_id']])) {
return $this->getData($cache[$row['host_tpl_id']], false);
} else {
if ($result_field = $this->getHostTplCriticities($row['host_tpl_id'], $cache)) {
return $result_field;
}
}
}
return NULL;
}

}
24 changes: 18 additions & 6 deletions www/include/configuration/configGenerate/genServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@
* Build cache for Macro
*/
$macroCache = array();
$DBRESULT3 = $pearDB->query("SELECT svc_macro_name, svc_macro_value, svc_svc_id
FROM on_demand_macro_service
WHERE svc_macro_name NOT IN (SELECT macro_name FROM nagios_macro)");
$DBRESULT3 = $pearDB->query("SELECT svc_macro_name, svc_macro_value, svc_svc_id FROM on_demand_macro_service WHERE svc_macro_name NOT IN (SELECT macro_name FROM nagios_macro)");
while ($od_macro = $DBRESULT3->fetchRow()) {
if (!isset($macroCache[$od_macro["svc_svc_id"]]))
if (!isset($macroCache[$od_macro["svc_svc_id"]])) {
$macroCache[$od_macro["svc_svc_id"]] = array();
}
$macroCache[$od_macro["svc_svc_id"]][$od_macro["svc_macro_name"]] = $od_macro["svc_macro_value"];
}
$DBRESULT3->free();
Expand Down Expand Up @@ -217,13 +216,18 @@
} else {
// Check if criticities is configured on service templates
$buff = $criticality->criticitiesConfigOnSTpl($service['service_template_model_stm_id']);

if ($buff == 0) {
// Get Criticities From hosts
global $critCacheName;
if (isset($critCacheName[$host_name])) {
$name = $critCacheName[$host_name]['name'];
$strTMP .= print_line("_CRITICALITY_LEVEL", $critSData[$name]['level']);
$strTMP .= print_line("_CRITICALITY_ID", $critSData[$name]['id']);
} else {
$tmp1 = $criticality->getHostTplCriticities($host_id, $critHTpl);
$strTMP .= print_line("_CRITICALITY_LEVEL", $critSData[$tmp1['name']]['level']);
$strTMP .= print_line("_CRITICALITY_ID", $critSData[$tmp1['name']]['id']);
}
}
}
Expand Down Expand Up @@ -541,10 +545,14 @@
* Host Relation
*/
$strTMPTemp = NULL;
$tmpHostName = "";
if (isset($serviceRelation[$service["service_id"]]["h"]))
foreach ($serviceRelation[$service["service_id"]]["h"] as $key => $value) {
$parent = true;
$strTMPTemp != NULL ? $strTMPTemp .= ", ".$value : $strTMPTemp = $value;
if ($tmpHostName == ''){
$tmpHostName = $strTMPTemp;
}
$LinkedToHost++;
}
if ($strTMPTemp) {
Expand Down Expand Up @@ -580,10 +588,14 @@
if ($buff == 0) {
// Get Criticities From hosts
global $critCacheName;
if (isset($critCacheName[$host_name])) {
$name = $critCacheName[$host_name]['name'];
if (isset($critCacheName[$tmpHostName])) {
$name = $critCacheName[$tmpHostName]['name'];
$strTMP .= print_line("_CRITICALITY_LEVEL", $critSData[$name]['level']);
$strTMP .= print_line("_CRITICALITY_ID", $critSData[$name]['id']);
} else {
$tmp1 = $criticality->getHostTplCriticities($host_id, $critHTpl);
$strTMP .= print_line("_CRITICALITY_LEVEL", $critSData[$tmp1['name']]['level']);
$strTMP .= print_line("_CRITICALITY_ID", $critSData[$tmp1['name']]['id']);
}
}
}
Expand Down

0 comments on commit 2023a1a

Please sign in to comment.