mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
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:
parent
8a6b23e04a
commit
0b9836143e
@ -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>
|
2012-11-26 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* include/functions_groups.php,
|
* include/functions_groups.php,
|
||||||
|
@ -1565,6 +1565,44 @@ function agents_get_addresses ($id_agent) {
|
|||||||
return $ret_arr;
|
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.
|
* Get the worst status of all modules of a given agent.
|
||||||
*
|
*
|
||||||
|
@ -77,14 +77,14 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0,
|
|||||||
$filter['id_grupo'] = $group;
|
$filter['id_grupo'] = $group;
|
||||||
|
|
||||||
$agents = agents_get_agents ($filter,
|
$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) {
|
else if ($group == -666) {
|
||||||
$agents = false;
|
$agents = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$agents = agents_get_agents ($filter,
|
$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)
|
if ($agents === false)
|
||||||
@ -492,7 +492,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined('METACONSOLE')) {
|
if (defined('METACONSOLE')) {
|
||||||
$status = agents_meta_get_status($id_server, $agent['id_agente']);
|
$status = agents_get_status_from_counts($agent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$status = agents_get_status($agent['id_agente']);
|
$status = agents_get_status($agent['id_agente']);
|
||||||
|
@ -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_agents.php');
|
||||||
require_once($config['homedir'] . '/include/functions_modules.php');
|
require_once($config['homedir'] . '/include/functions_modules.php');
|
||||||
require_once($config['homedir'] . '/include/functions_users.php');
|
require_once($config['homedir'] . '/include/functions_users.php');
|
||||||
|
enterprise_include_once ('include/functions_metaconsole.php');
|
||||||
|
|
||||||
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
|
$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php');
|
||||||
|
|
||||||
// TODO: CLEAN extra_sql
|
// TODO: CLEAN extra_sql
|
||||||
$extra_sql = '';
|
$extra_sql = '';
|
||||||
|
|
||||||
|
if (! defined ('METACONSOLE')) {
|
||||||
|
//Header
|
||||||
ui_print_page_header ("Monitor detail", "images/brick.png", false);
|
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_freestring = get_parameter ('ag_freestring');
|
||||||
$ag_modulename = (string) get_parameter ('ag_modulename');
|
$ag_modulename = (string) get_parameter ('ag_modulename');
|
||||||
@ -565,6 +574,8 @@ switch ($config["dbtype"]) {
|
|||||||
$sql = oracle_recode_query ($sql, $set);
|
$sql = oracle_recode_query ($sql, $set);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! defined ('METACONSOLE')) {
|
||||||
$result = db_get_all_rows_sql ($sql);
|
$result = db_get_all_rows_sql ($sql);
|
||||||
|
|
||||||
if ($count > $config["block_size"]) {
|
if ($count > $config["block_size"]) {
|
||||||
@ -574,6 +585,31 @@ if ($count > $config["block_size"]) {
|
|||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$result = array ();
|
$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)) {
|
if (($config['dbtype'] == 'oracle') && ($result !== false)) {
|
||||||
for ($i=0; $i < count($result); $i++) {
|
for ($i=0; $i < count($result); $i++) {
|
||||||
|
@ -19,12 +19,8 @@ global $config;
|
|||||||
include_once($config['homedir'] . "/include/functions_graph.php");
|
include_once($config['homedir'] . "/include/functions_graph.php");
|
||||||
include_once($config['homedir'] . "/include/functions_ui.php");
|
include_once($config['homedir'] . "/include/functions_ui.php");
|
||||||
include_once($config['homedir'] . "/include/functions_netflow.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
|
// ACL
|
||||||
check_login ();
|
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 ());
|
ui_print_page_header (__('Netflow live view'), "images/networkmap/so_cisco_new.png", false, "", false, array ());
|
||||||
} else {
|
} else {
|
||||||
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
|
$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);
|
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
|
// The filter name will not be needed anymore
|
||||||
$filter['id_name'] = '';
|
$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
|
// Chart options table
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user