$row) {
$server_rows[$key]['server_name'] = $server['server_name'];
}
$rows = array_merge($rows, $server_rows);
}
metaconsole_restore_db();
}
$countRows = count ($rows);
//Empty Branch
if ($countRows === 0) {
echo "
\n";
echo "- ";
if ($lessBranchs == 1)
echo html_print_image ("operation/tree/no_branch.png", true, array ("style" => 'vertical-align: middle;'));
else
echo html_print_image ("operation/tree/branch.png", true, array ("style" => 'vertical-align: middle;'));
echo "" . __("Empty") . "";
echo "
";
echo "
";
return;
}
//Branch with items
$count = 0;
echo "\n";
foreach ($rows as $row) {
$count++;
$agent_info["monitor_alertsfired"] = $row["fired_count"];
$agent_info["monitor_critical"] = $row["critical_count"];
$agent_info["monitor_warning"] = $row["warning_count"];
$agent_info["monitor_unknown"] = $row["unknown_count"];
$agent_info["monitor_normal"] = $row["normal_count"];
$agent_info["modules"] = $row["total_count"];
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agents_tree_view_status_img ($agent_info["monitor_critical"], $agent_info["monitor_warning"], $agent_info["monitor_unknown"]);
// Filter by status (only in policy view)
if ($type == 'policies') {
if ($statusSel == NORMAL) {
if (strpos($agent_info["status_img"], 'ok') === false)
continue;
}
else if ($statusSel == WARNING) {
if (strpos($agent_info["status_img"], 'warning') === false)
continue;
}
else if ($statusSel == CRITICAL) {
if (strpos($agent_info["status_img"], 'critical') === false)
continue;
}
else if ($statusSel == UNKNOWN) {
if (strpos($agent_info["status_img"], 'down') === false)
continue;
}
}
$less = $lessBranchs;
if ($count != $countRows)
$img = html_print_image ("operation/tree/closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image" . $id . "_agent_" . $type . "_" . $row["id_agente"], "pos_tree" => "2"));
else {
$less = $less + 2; // $less = $less or 0b10
$img = html_print_image ("operation/tree/last_closed.png", true, array ("style" => 'vertical-align: middle;', "id" => "tree_image" . $id . "_agent_" . $type . "_" . $row["id_agente"], "pos_tree" => "3"));
}
echo "- ";
echo "";
if ($lessBranchs == 1)
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
else
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
echo $img;
echo "";
echo " ";
echo str_replace('.png' ,'_ball.png',
str_replace('img', 'img style="vertical-align: middle;"', $agent_info["status_img"])
);
echo " ";
echo str_replace('.png' ,'_ball.png',
str_replace('img', 'img style="vertical-align: middle;"', $agent_info["alert_img"])
);
echo "";
echo " ";
echo $row["nombre"];
echo " (" . reporting_tiny_stats($row, true) . ")";
if ($row['quiet']) {
echo " ";
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
}
echo "";
echo "";
echo "
";
}
echo "
\n";
break;
//also aknolegment as second subtree/branch
case 'agent_group':
case 'agent_module_group':
case 'agent_os':
case 'agent_policies':
case 'agent_module':
case 'agent_tag':
$fatherType = str_replace('agent_', '', $type);
if (defined ('METACONSOLE')) {
$server = metaconsole_get_connection ($server_name);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$sql = treeview_getSecondBranchSQL ($fatherType, $id, $id_father);
$rows = db_get_all_rows_sql($sql);
if (empty($rows)) {
$rows = array();
}
$countRows = count ($rows);
if ($countRows === 0) {
echo "\n";
echo "- ";
switch ($lessBranchs) {
case 0:
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 1:
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 2:
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 3:
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
}
echo "" . __("Empty") . "";
echo "
";
echo "
";
return;
}
$count = 0;
echo "\n";
foreach ($rows as $row) {
$count++;
echo "- ";
switch ($lessBranchs) {
case 0:
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 1:
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 2:
html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
case 3:
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;'));
break;
}
if ($countRows != $count)
html_print_image ("operation/tree/leaf.png", false, array ("style" => 'vertical-align: middle;', "id" => "tree_image_os_" . $row["id_agente"], "pos_tree" => "1" ));
else
html_print_image ("operation/tree/last_leaf.png", false, array ("style" => 'vertical-align: middle;', "id" => "tree_image_os_" . $row["id_agente"], "pos_tree" => "2" ));
// This line checks for (non-initialized) asyncronous modules
if ($row["estado"] == 0 AND $row["utimestamp"] == 0 AND ($row["id_tipo_modulo"] >= 21 AND $row["id_tipo_modulo"] <= 23)){
$status = STATUS_MODULE_NO_DATA;
$title = __('UNKNOWN');
} // Else checks module status
elseif ($row["estado"] == 1) {
$status = STATUS_MODULE_CRITICAL;
$title = __('CRITICAL');
}
elseif ($row["estado"] == 2) {
$status = STATUS_MODULE_WARNING;
$title = __('WARNING');
}
elseif ($row["estado"] == 3) {
$status = STATUS_MODULE_NO_DATA;
$title = __('UNKNOWN');
}
else {
$status = STATUS_MODULE_OK;
$title = __('NORMAL');
}
if (is_numeric($row["datos"])) {
$title .= " : " . format_for_graph($row["datos"]);
}
else {
$title .= " : " . substr(io_safe_output($row["datos"]),0,42);
}
echo str_replace('.png' ,'_ball.png',
str_replace('img', 'img style="vertical-align: middle;"', ui_print_status_image($status, $title,true))
);
echo " ";
echo str_replace('img', 'img style="vertical-align: middle;"', servers_show_type ($row['id_modulo']));
echo " ";
$graph_type = return_graphtype ($row["id_tipo_modulo"]);
$win_handle=dechex(crc32($row["id_agente_modulo"] . $row["nombre"]));
if (defined ('METACONSOLE')) {
$console_url = $server['server_url'] . '/';
}
else {
$console_url = '';
}
//Icon and link to the Module graph.
if (defined('METACONSOLE')) {
$url_module_graph = ui_meta_get_url_console_child(
$server, null, null, null, null,
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"] . "&" .
"label=" . base64_encode($row["nombre"]) . "&" .
"refresh=600");
}
else {
$url_module_graph = $console_url .
"operation/agentes/stat_win.php?" .
"type=$graph_type&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"] . "&" .
"label=" . base64_encode($row["nombre"]) . "&" .
"refresh=600";
}
$link ="winopeng('" . $url_module_graph . "','day_".$win_handle."')";
echo '' . html_print_image ("images/chart_curve.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . '';
echo " ";
//Icon and link to the Module data.
if (defined('METACONSOLE')) {
$url_module_data = ui_meta_get_url_console_child(
$server,
"estado", "operation/agentes/ver_agente",
"id_agente=" . $row['id_agente'] . "&" .
"tab=data_view&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"]);
}
else {
$url_module_data = $console_url .
"index.php?" .
"sec=estado&" .
"sec2=operation/agentes/ver_agente&" .
"id_agente=" . $row['id_agente'] . "&" .
"tab=data_view&" .
"period=86400&" .
"id=" . $row["id_agente_modulo"];
}
echo "". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "";
echo " ";
$nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"]));
if($nmodule_alerts > 0) {
echo "";
echo html_print_image ("images/bell.png", true, array ("style" => 'vertical-align: middle;', "border" => "0", "title" => __('Module alerts') ));
echo "";
echo " ";
}
echo "";
echo io_safe_output($row['nombre']);
echo "";
if ($row['quiet']) {
echo " ";
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
}
if (is_numeric($row["datos"]))
$data = format_numeric($row["datos"]);
else
$data = "".substr(io_safe_output($row["datos"]),0,12)."";
echo "";
echo $data;
if ($row['unit'] != '') {
echo " ";
echo '('.$row['unit'].')';
}
if ($row['utimestamp'] != '') {
echo " ";
ui_print_help_tip ($row["timestamp"], '', 'images/clock2.png');
}
echo "
";
}
echo "
\n";
if (defined ('METACONSOLE')) {
metaconsole_restore_db_force();
}
break;
}
return;
}
//End of AJAX code.
include_once($config['homedir'] . "/include/functions_groups.php");
include_once($config['homedir'] . "/include/functions_os.php");
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_reporting.php");
include_once($config['homedir'] . "/include/functions_ui.php");
global $config;
$pure = get_parameter('pure', 0);
$enterpriseEnable = false;
if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) {
$enterpriseEnable = true;
}
///////// INI MENU AND TABS /////////////
$img_style = array ("class" => "top", "width" => 16);
$activeTab = get_parameter('sort_by','group');
$os_tab = array('text' => ""
. html_print_image ("images/operating_system.png", true, array ("title" => __('OS'))) . "", 'active' => $activeTab == "os");
$group_tab = array('text' => ""
. html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "", 'active' => $activeTab == "group");
$module_group_tab = array('text' => ""
. html_print_image ("images/module_group.png", true, array ("title" => __('Module groups'))) . "", 'active' => $activeTab == "module_group");
if ($enterpriseEnable) {
$policies_tab = array('text' => ""
. html_print_image ("images/policies_mc.png", true, array ("title" => __('Policies'))) . "", 'active' => $activeTab == "policies");
}
else {
$policies_tab = '';
}
$module_tab = array('text' => ""
. html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "", 'active' => $activeTab == "module");
$tags_tab = array('text' => ""
. html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "", 'active' => $activeTab == "tag");
switch ($activeTab) {
case 'group':
$order = __('groups');
break;
case 'module_group':
$order = __('module groups');
break;
case 'policies':
$order = __('policies');
break;
case 'module':
$order = __('modules');
break;
case 'os':
$order = __('OS');
break;
case 'tag':
$order = __('tags');
break;
}
if (! defined ('METACONSOLE')) {
$onheader = array('tag' => $tags_tab, 'os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab);
ui_print_page_header (__('Tree view')." - ".__('Sort the agents by ') .$order, "images/extensions.png", false, "", false, $onheader);
}
else {
ui_meta_add_breadcrumb(array('link' => 'index.php?sec=monitoring&sec2=operation/tree', 'text' => __('Tree View')));
ui_meta_print_page_header($nav_bar);
$img_style = array ("class" => "top", "width" => 16);
$activeTab = get_parameter('tab','group');
$group_tab = array('text' => ""
. html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "",
'active' => $activeTab == "group");
$tags_tab = array('text' => ""
. html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "", 'active' => $activeTab == "tag");
$subsections = array('group' => $group_tab, 'tag' => $tags_tab);
switch ($activeTab) {
case 'group':
$subsection = __('Groups');
$tab = 'group';
break;
case 'tag':
$subsection = __('Tags');
$tab = 'tag';
break;
}
ui_meta_print_header(__("Tree view"), $subsection, $subsections);
}
if(tags_has_user_acl_tags()) {
ui_print_tags_warning();
}
echo "
";
if (! defined ('METACONSOLE')) {
echo '";
echo "";
echo "";
echo "";
///////// END MENU AND TABS /////////////
echo "";
ui_require_javascript_file('pandora_modules');
treeview_printTree($activeTab);
?>