2010-02-25 Sancho Lerena <slerena@artica.es>
* lib/PandoraFMS/Core.pm: Implemented new alert type "onChange". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2428 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9c8b33b3d9
commit
0234c9e8c8
|
@ -1,3 +1,7 @@
|
||||||
|
2010-02-25 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Core.pm: Implemented new alert type "onChange".
|
||||||
|
|
||||||
2010-02-25 Pablo de la Concepción <pablo.concepcion@artica.es>
|
2010-02-25 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||||
|
|
||||||
* conf/pandora_server.conf: New option, update_parent to let the
|
* conf/pandora_server.conf: New option, update_parent to let the
|
||||||
|
|
|
@ -157,14 +157,14 @@ our @ServerTypes = qw (dataserver networkserver snmpconsole reconserver pluginse
|
||||||
our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not execute the alert, but increment its internal counter', 'Cease the alert', 'Recover the alert', 'Reset internal counter');
|
our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not execute the alert, but increment its internal counter', 'Cease the alert', 'Recover the alert', 'Reset internal counter');
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
=head2 C<< pandora_generate_alerts (I<$pa_config> I<$data> I<$status> I<$agent> I<$module> I<$utimestamp> I<$dbh>) >>
|
=head2 C<< pandora_generate_alerts (I<$pa_config> I<$data> I<$status> I<$agent> I<$module> I<$utimestamp> I<$dbh> I<$extraMacros> I<$last_data_value>) >>
|
||||||
|
|
||||||
Generate alerts for a given I<$module>.
|
Generate alerts for a given I<$module>.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_generate_alerts ($$$$$$$;$) {
|
sub pandora_generate_alerts ($$$$$$$;$$) {
|
||||||
my ($pa_config, $data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros) = @_;
|
my ($pa_config, $data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros, $last_data_value) = @_;
|
||||||
|
|
||||||
# Do not generate alerts for disabled groups
|
# Do not generate alerts for disabled groups
|
||||||
if (is_group_disabled ($dbh, $agent->{'id_grupo'})) {
|
if (is_group_disabled ($dbh, $agent->{'id_grupo'})) {
|
||||||
|
@ -180,7 +180,7 @@ sub pandora_generate_alerts ($$$$$$$;$) {
|
||||||
|
|
||||||
foreach my $alert (@alerts) {
|
foreach my $alert (@alerts) {
|
||||||
my $rc = pandora_evaluate_alert($pa_config, $agent, $data, $status, $alert,
|
my $rc = pandora_evaluate_alert($pa_config, $agent, $data, $status, $alert,
|
||||||
$utimestamp, $dbh);
|
$utimestamp, $dbh, $last_data_value);
|
||||||
|
|
||||||
pandora_process_alert ($pa_config, $data, $agent, $module,
|
pandora_process_alert ($pa_config, $data, $agent, $module,
|
||||||
$alert, $rc, $dbh, $extraMacros);
|
$alert, $rc, $dbh, $extraMacros);
|
||||||
|
@ -208,7 +208,7 @@ B<Returns>:
|
||||||
=cut
|
=cut
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_evaluate_alert ($$$$$$$) {
|
sub pandora_evaluate_alert ($$$$$$$) {
|
||||||
my ($pa_config, $agent, $data, $last_status, $alert, $utimestamp, $dbh) = @_;
|
my ($pa_config, $agent, $data, $last_status, $alert, $utimestamp, $dbh, $last_data_value) = @_;
|
||||||
|
|
||||||
logger ($pa_config, "Evaluating alert '" . $alert->{'name'} . "' for agent '" . $agent->{'nombre'} . "'.", 10);
|
logger ($pa_config, "Evaluating alert '" . $alert->{'name'} . "' for agent '" . $agent->{'nombre'} . "'.", 10);
|
||||||
|
|
||||||
|
@ -263,6 +263,19 @@ sub pandora_evaluate_alert ($$$$$$$) {
|
||||||
$data <= $alert->{'max_value'});
|
$data <= $alert->{'max_value'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($alert->{'type'} eq "onchange") {
|
||||||
|
|
||||||
|
if (is_numeric($last_data_value)){
|
||||||
|
if ($last_data_value == $data){
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($last_data_value eq $data){
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $status if ($alert->{'type'} eq "equal" && $data != $alert->{'value'});
|
return $status if ($alert->{'type'} eq "equal" && $data != $alert->{'value'});
|
||||||
return $status if ($alert->{'type'} eq "not_equal" && $data == $alert->{'value'});
|
return $status if ($alert->{'type'} eq "not_equal" && $data == $alert->{'value'});
|
||||||
|
@ -701,6 +714,7 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
||||||
my $last_status = $agent_status->{'last_status'};
|
my $last_status = $agent_status->{'last_status'};
|
||||||
my $status = $agent_status->{'estado'};
|
my $status = $agent_status->{'estado'};
|
||||||
my $status_changes = $agent_status->{'status_changes'};
|
my $status_changes = $agent_status->{'status_changes'};
|
||||||
|
my $last_data_value = $agent_status->{'datos'};
|
||||||
|
|
||||||
# Get new status
|
# Get new status
|
||||||
my $new_status = get_module_status ($processed_data, $module, $module_type);
|
my $new_status = get_module_status ($processed_data, $module, $module_type);
|
||||||
|
@ -722,7 +736,7 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
||||||
|
|
||||||
# Generate alerts
|
# Generate alerts
|
||||||
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh) == 0) {
|
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh) == 0) {
|
||||||
pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros);
|
pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros, $last_data_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
# tagente_estado.last_try defaults to NULL, should default to '0000-00-00 00:00:00'
|
# tagente_estado.last_try defaults to NULL, should default to '0000-00-00 00:00:00'
|
||||||
|
|
Loading…
Reference in New Issue