2012-11-26 Sergio Martin <sergio.martin@artica.es>

* include/functions_agents.php
	include/functions_networkmap.php
	operation/agentes/status_monitor.php
	operation/netflow/nf_live_view.php: Improve the 
	performance of networkmap with the new status counts.
	Modify some common code between console and metaconsole



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7185 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-11-26 18:38:09 +00:00
parent 1f25998d49
commit 417dcbbe28
5 changed files with 96 additions and 17 deletions

View File

@ -1,3 +1,12 @@
2012-11-26 Sergio Martin <sergio.martin@artica.es>
* include/functions_agents.php
include/functions_networkmap.php
operation/agentes/status_monitor.php
operation/netflow/nf_live_view.php: Improve the
performance of networkmap with the new status counts.
Modify some common code between console and metaconsole
2012-11-26 Ramon Novoa <rnovoa@artica.es>
* include/functions_groups.php,

View File

@ -1565,6 +1565,44 @@ function agents_get_addresses ($id_agent) {
return $ret_arr;
}
/**
* Get the worst status of all modules of a given agent from the counts.
*
* @param array agent to check.
*
* @return int Worst status of an agent for all of its modules.
* return -1 if the data are wrong
*/
function agents_get_status_from_counts($agent) {
// Check if in the data there are all the necessary values
if(!isset($agent['normal_count']) &&
!isset($agent['warning_count']) &&
!isset($agent['critical_count']) &&
!isset($agent['unknown_count']) &&
!isset($agent['notinit_count']) &&
!isset($agent['total_count'])) {
return -1;
}
if($agent['critical_count'] > 0) {
return AGENT_MODULE_STATUS_CRITICAL_BAD;
}
else if($agent['warning_count'] > 0) {
return AGENT_MODULE_STATUS_WARNING;
}
else if($agent['unknown_count'] > 0) {
return AGENT_MODULE_STATUS_UNKNOW;
}
else if($agent['normal_count'] == $agent['total_count']) {
return AGENT_MODULE_STATUS_NORMAL;
}
//~ else if($agent['notinit_count'] == $agent['total_count']) {
//~ return AGENT_MODULE_STATUS_NORMAL;
//~ }
return -1;
}
/**
* Get the worst status of all modules of a given agent.
*

View File

@ -77,14 +77,14 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0,
$filter['id_grupo'] = $group;
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente'));
array ('id_grupo, nombre, id_os, id_parent, id_agente, normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count'));
}
else if ($group == -666) {
$agents = false;
}
else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente'));
array ('id_grupo, nombre, id_os, id_parent, id_agente, normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count'));
}
if ($agents === false)
@ -492,7 +492,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
global $config;
if (defined('METACONSOLE')) {
$status = agents_meta_get_status($id_server, $agent['id_agente']);
$status = agents_get_status_from_counts($agent);
}
else {
$status = agents_get_status($agent['id_agente']);

View File

@ -32,13 +32,22 @@ if (! check_acl ($config['id_user'], 0, "AR")
require_once($config['homedir'] . '/include/functions_agents.php');
require_once($config['homedir'] . '/include/functions_modules.php');
require_once($config['homedir'] . '/include/functions_users.php');
enterprise_include_once ('include/functions_metaconsole.php');
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
// TODO: CLEAN extra_sql
$extra_sql = '';
ui_print_page_header ("Monitor detail", "images/brick.png", false);
if (! defined ('METACONSOLE')) {
//Header
ui_print_page_header ("Monitor detail", "images/brick.png", false);
} else {
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
array('link' => 'index.php?sec=estado&sec2=operation/agentes/status_monitor', 'text' => __('Monitor view')));
ui_meta_print_page_header($nav_bar);
}
$ag_freestring = get_parameter ('ag_freestring');
$ag_modulename = (string) get_parameter ('ag_modulename');
@ -565,14 +574,41 @@ switch ($config["dbtype"]) {
$sql = oracle_recode_query ($sql, $set);
break;
}
$result = db_get_all_rows_sql ($sql);
if (! defined ('METACONSOLE')) {
$result = db_get_all_rows_sql ($sql);
if ($count > $config["block_size"]) {
ui_pagination ($count, false, $offset);
if ($count > $config["block_size"]) {
ui_pagination ($count, false, $offset);
}
if ($result === false) {
$result = array ();
}
}
if ($result === false) {
$result = array ();
else {
// For each server defined and not disabled:
$servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0");
if ($servers === false)
$servers = array();
$result = array();
foreach($servers as $server) {
// If connection was good then retrieve all data server
if (metaconsole_connect($server) == NOERR){
$connection = true;
}
else{
$connection = false;
}
$result_server = db_get_all_rows_sql ($sql);
if(!empty($result_server)) {
$result = array_merge($result, $result_server);
}
}
}
if (($config['dbtype'] == 'oracle') && ($result !== false)) {

View File

@ -19,12 +19,8 @@ global $config;
include_once($config['homedir'] . "/include/functions_graph.php");
include_once($config['homedir'] . "/include/functions_ui.php");
include_once($config['homedir'] . "/include/functions_netflow.php");
if (defined ('METACONSOLE')) {
ui_require_javascript_file ('calendar', '../../include/javascript/');
} else {
ui_require_javascript_file ('calendar');
}
ui_require_javascript_file ('calendar');
// ACL
check_login ();
@ -102,7 +98,7 @@ if (! defined ('METACONSOLE')) {
ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.png", false, "", false, array ());
} else {
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
array('link' => 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_live_view', 'text' => __('Netflow live view')));
array('link' => 'index.php?sec=netf&sec2=operation/netflow/nf_live_view', 'text' => __('Netflow live view')));
ui_meta_print_page_header($nav_bar);
}
@ -140,7 +136,7 @@ else if ($update != '' && check_acl ($config["id_user"], 0, "AW")) {
// The filter name will not be needed anymore
$filter['id_name'] = '';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/operation/netflow/nf_live_view">';
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=operation/netflow/nf_live_view">';
// Chart options table
$table->width = '100%';