Merge branch 'clusters' of https://192.168.50.5:8081/artica/pandorafms into clusters
This commit is contained in:
commit
b07021f6bc
|
@ -32,7 +32,7 @@ ui_print_page_header ( __("Cluster detail").' » '.clusters_get_name($id_cluster
|
|||
|
||||
$font_size = 10;
|
||||
$width = "100%";
|
||||
$height = "600";
|
||||
$height = "500";
|
||||
$node_radius = 40;
|
||||
$baseurl = ui_get_full_url(false, false, false, false);
|
||||
|
||||
|
@ -74,7 +74,7 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:red;'></div>
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_CRITICAL.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
|
@ -83,7 +83,7 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:yellow;'></div>
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_WARNING.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
|
@ -92,7 +92,7 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:blue;'></div>
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_NOTINIT.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
|
@ -101,7 +101,7 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:gray;'></div>
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_UNKNOWN.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
|
@ -110,7 +110,7 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:blue;'></div>
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_NOTINIT.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
|
@ -119,7 +119,7 @@ echo "<table style='width:100%;'>";
|
|||
|
||||
echo "<div style='border:3px gray groove;float:left;width:100px;margin-left:20px;margin-top:20px;height:50px;'>
|
||||
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:green;'></div>
|
||||
<div class='status_animation' style='position:relative;width:100px;background-color:".COL_NORMAL.";'></div>
|
||||
|
||||
</div>";
|
||||
|
||||
|
@ -328,7 +328,7 @@ system ($cmd);
|
|||
|
||||
unlink($filename_dot);
|
||||
|
||||
$nodes = cluster_loadfile($filename_plain, $graph);
|
||||
$nodes = cluster_loadfile($filename_plain, $graph, $id_cluster);
|
||||
|
||||
|
||||
foreach ($nodes['nodes'] as $key => $node) {
|
||||
|
|
|
@ -213,6 +213,100 @@ function cluster_get_status ($id_agente){
|
|||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the worst status of all modules of a given cluster agent.
|
||||
*
|
||||
* @param int Id agent to check.
|
||||
* @param bool Whether the call check ACLs or not
|
||||
*
|
||||
* @return int Worst status of an cluster agent for all of its modules.
|
||||
* The value -1 is returned in case the agent has exceed its interval.
|
||||
*/
|
||||
function cluster_agents_get_status($id_agent = 0, $noACLs = false, $id_cluster = 0) {
|
||||
global $config;
|
||||
|
||||
if (!$noACLs) {
|
||||
$sql_module_cluster = "SELECT am.nombre,am.id_agente_modulo, ae.datos, ae.estado FROM tagente_modulo am
|
||||
INNER JOIN tagente_estado ae ON ae.id_agente_modulo = am.id_agente_modulo
|
||||
WHERE nombre IN (SELECT name FROM tcluster_item WHERE id_cluster = $id_cluster) AND am.id_agente = $id_agent";
|
||||
|
||||
$modules = db_get_all_rows_sql ($sql_module_cluster);
|
||||
}
|
||||
|
||||
if (!isset($modules) || empty($modules) || count($modules) == 0) {
|
||||
return AGENT_MODULE_STATUS_NOT_INIT;
|
||||
}
|
||||
|
||||
$modules_status = array();
|
||||
$modules_async = 0;
|
||||
foreach ($modules as $module) {
|
||||
|
||||
$modules_status[] = $module['estado'];
|
||||
|
||||
$module_type = modules_get_agentmodule_type($module['id_agente_modulo']);
|
||||
if (($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
|
||||
$modules_async++;
|
||||
}
|
||||
}
|
||||
|
||||
// If all the modules are asynchronous or keep alive, the group cannot be unknown
|
||||
if ($modules_async < count($modules)) {
|
||||
$time = get_system_time ();
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$status = db_get_value_filter ('COUNT(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'UNIX_TIMESTAMP(ultimo_contacto) + intervalo * 2 > '.$time));
|
||||
break;
|
||||
case "postgresql":
|
||||
$status = db_get_value_filter ('COUNT(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'ceil(date_part(\'epoch\', ultimo_contacto)) + intervalo * 2 > '.$time));
|
||||
break;
|
||||
case "oracle":
|
||||
$status = db_get_value_filter ('count(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')) > ' . $time));
|
||||
break;
|
||||
}
|
||||
|
||||
if (! $status)
|
||||
return AGENT_MODULE_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
// Checking if any module has alert fired
|
||||
if (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_ALERT, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_CRITICAL_ALERT;
|
||||
}
|
||||
// Checking if any module has alert fired
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING_ALERT, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_WARNING_ALERT;
|
||||
}
|
||||
// Checking if any module has critical status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_CRITICAL_BAD, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||
}
|
||||
// Checking if any module has critical status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_NORMAL_ALERT, $modules_status))) {
|
||||
return AGENT_STATUS_ALERT_FIRED;
|
||||
}
|
||||
// Checking if any module has warning status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_WARNING,$modules_status))) {
|
||||
return AGENT_MODULE_STATUS_WARNING;
|
||||
}
|
||||
// Checking if any module has unknown status
|
||||
elseif (is_int(array_search(AGENT_MODULE_STATUS_UNKNOWN, $modules_status))) {
|
||||
return AGENT_MODULE_STATUS_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
return AGENT_MODULE_STATUS_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue