2013-03-04 Sergio Martin <sergio.martin@artica.es>
* include/functions_alerts.php include/functions_modules.php include/functions_reporting.php include/functions_servers.php: Fix counts when validate or delete alerts and fix some little bugs of previous commits git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7775 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
aa8f959083
commit
166106e298
|
@ -1,3 +1,11 @@
|
|||
2013-03-04 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_alerts.php
|
||||
include/functions_modules.php
|
||||
include/functions_reporting.php
|
||||
include/functions_servers.php: Fix counts when validate or
|
||||
delete alerts and fix some little bugs of previous commits
|
||||
|
||||
2013-03-04 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/constants.php: added constant for the module not init
|
||||
|
|
|
@ -873,14 +873,33 @@ function alerts_delete_alert_agent_module ($id_alert_agent_module, $filter = fal
|
|||
if ($id_alert_agent_module)
|
||||
$filter['id'] = $id_alert_agent_module;
|
||||
|
||||
// Get the modules of the fired alerts that will be deleted to update counts
|
||||
$filter_get = $filter;
|
||||
|
||||
$filter_get['group'] = 'id_agent_module';
|
||||
$filter_get['times_fired'] = '>0';
|
||||
|
||||
$fired_alert_modules = db_get_all_rows_filter('talert_template_modules', $filter_get, array('id_agent_module', 'COUNT(*) alerts'));
|
||||
|
||||
/*
|
||||
The deletion of actions from talert_template_module_actions,
|
||||
it is automatily because the data base this table have
|
||||
a foreing key and delete on cascade.
|
||||
*/
|
||||
if (@db_process_sql_delete ('talert_template_modules', $filter) !== false) {
|
||||
// If there are fired alert modules, update counts
|
||||
if($fired_alert_modules !== false) {
|
||||
foreach($fired_alert_modules as $fam) {
|
||||
$agent_id = modules_get_agentmodule_agent($fam['id_agent_module']);
|
||||
|
||||
return (@db_process_sql_delete ('talert_template_modules',
|
||||
$filter)) !== false;
|
||||
db_process_sql(sprintf('UPDATE tagente SET fired_count=fired_count-%d WHERE id_agente = %d', $fam['alerts'], $agent_id));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -155,10 +155,10 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
|
|||
|
||||
// Define the operation dependes if is disable or enable
|
||||
if($new_value == 1) {
|
||||
$operation = '- 1';
|
||||
$operation = '-';
|
||||
}
|
||||
else {
|
||||
$operation = '+ 1';
|
||||
$operation = '+';
|
||||
}
|
||||
|
||||
foreach($id_agent_module as $id_module) {
|
||||
|
@ -175,30 +175,24 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
|
|||
// Define the field to update depends the status
|
||||
switch($status) {
|
||||
case AGENT_MODULE_STATUS_NO_DATA:
|
||||
$modification = 'notinit_count = notinit_count ' . $operation . ',';
|
||||
$modification = 'notinit_count = notinit_count ' . $operation . ' 1,';
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
$modification = 'critical_count = critical_count ' . $operation . ',';
|
||||
$modification = 'critical_count = critical_count ' . $operation . ' 1,';
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
$modification = 'warning_count = warning_count ' . $operation . ',';
|
||||
$modification = 'warning_count = warning_count ' . $operation . ' 1,';
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
$modification = 'normal_count = normal_count ' . $operation . ',';
|
||||
$modification = 'normal_count = normal_count ' . $operation . ' 1,';
|
||||
break;
|
||||
case AGENT_MODULE_STATUS_UNKNOW:
|
||||
$modification = 'unknown_count = unknown_count ' . $operation . ',';
|
||||
$modification = 'unknown_count = unknown_count ' . $operation . ' 1,';
|
||||
break;
|
||||
default:
|
||||
$modification = '';
|
||||
break;
|
||||
}
|
||||
|
||||
// Increase total count of the agent
|
||||
$result = db_process_sql('UPDATE tagente SET ' . $modification . ' total_count = total_count ' . $operation . ' WHERE id_agente = ' . $agent_id);
|
||||
if(!$result) {
|
||||
return ERR_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
$result = db_process_sql_update('tagente_modulo', array('disabled' => $new_value), array('id_agente_modulo' => $id_agent_module));
|
||||
|
@ -229,7 +223,8 @@ function modules_delete_agent_module ($id_agent_module) {
|
|||
|
||||
enterprise_hook('config_agents_delete_module_in_conf', array(modules_get_agentmodule_agent($id_agent_module), modules_get_agentmodule_name($id_agent_module)));
|
||||
|
||||
db_process_sql_delete ('talert_template_modules', $where);
|
||||
alerts_delete_alert_agent_module (0, $where);
|
||||
|
||||
db_process_sql_delete ('tgraph_source', $where);
|
||||
db_process_sql_delete ('treport_content', $where);
|
||||
db_process_sql_delete ('tevento', array ('id_agentmodule' => $id_agent_module));
|
||||
|
|
|
@ -6636,7 +6636,7 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent') {
|
|||
$template_title['critical_count'] = __('%d Critical agents');
|
||||
$template_title['warning_count'] = __('%d Warning agents');
|
||||
$template_title['unknown_count'] = __('%d Unknown agents');
|
||||
$template_title['fired_count'] = __('%d Fired agents');
|
||||
$template_title['fired_count'] = __('%d Fired alerts');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6670,7 +6670,7 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent') {
|
|||
|
||||
if(isset($counts_info['fired_count'])) {
|
||||
$fired_count = $counts_info['fired_count'];
|
||||
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['total_count'], $fired_count));
|
||||
$stats[] = array('name' => 'fired_count', 'count' => $fired_count, 'title' => sprintf($template_title['fired_count'], $fired_count));
|
||||
}
|
||||
|
||||
$uniq_id = uniqid();
|
||||
|
|
|
@ -186,7 +186,7 @@ function servers_get_performance () {
|
|||
$interval_avgs_agents = db_get_all_rows_sql ("SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente.intervalo) avg_interval
|
||||
FROM tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0 AND module_interval = 0 AND (utimestamp > 0 OR (id_tipo_modulo = 100 OR (id_tipo_modulo >= 21 AND id_tipo_modulo <= 24)))
|
||||
AND tagente_modulo.disabled = 0 AND module_interval = 0 AND (utimestamp > 0 OR (id_tipo_modulo = 100 OR (id_tipo_modulo >= 21 AND id_tipo_modulo <= 23)))
|
||||
AND delete_pending = 0
|
||||
AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente GROUP BY tagente_modulo.id_modulo");
|
||||
|
||||
|
|
Loading…
Reference in New Issue