diff --git a/pandora_console/extras/mr/27.sql b/pandora_console/extras/mr/27.sql
new file mode 100644
index 0000000000..a2c721cd5f
--- /dev/null
+++ b/pandora_console/extras/mr/27.sql
@@ -0,0 +1,23 @@
+START TRANSACTION;
+
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_critical` int(4) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_critical` int(4) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_critical` int(4) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_critical` int(4) unsigned default '0';
+
+COMMIT;
\ No newline at end of file
diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
index 6e5e2ebcc9..4aed6f9000 100644
--- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
@@ -58,6 +58,11 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` (
ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tlocal_component` ADD COLUMN `ff_critical` int(4) unsigned default '0';
+
-- -----------------------------------------------------
-- Table `tpolicy_modules`
@@ -136,6 +141,10 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` (
ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_critical` int(4) unsigned default '0';
-- ---------------------------------------------------------------------
-- Table `tpolicies`
@@ -1260,6 +1269,10 @@ ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default
ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL default 0;
ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL default 0;
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tagente_modulo` ADD COLUMN `ff_critical` int(4) unsigned default '0';
-- ---------------------------------------------------------------------
-- Table `tagente_datos`
@@ -1279,6 +1292,10 @@ ALTER TABLE tnetwork_component ADD COLUMN `dynamic_max` int(4) default '0';
ALTER TABLE tnetwork_component ADD COLUMN `dynamic_min` int(4) default '0';
ALTER TABLE tnetwork_component ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE tnetwork_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_normal` int(4) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_warning` int(4) unsigned default '0';
+ALTER TABLE `tnetwork_component` ADD COLUMN `ff_critical` int(4) unsigned default '0';
-- ---------------------------------------------------------------------
-- Table `tagente`
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index 9c10099042..c0a9c27c41 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -1320,6 +1320,7 @@ if ($update_module || $create_module) {
$ff_event_normal = (int) get_parameter('ff_event_normal');
$ff_event_warning = (int) get_parameter('ff_event_warning');
$ff_event_critical = (int) get_parameter('ff_event_critical');
+ $ff_type = (int) get_parameter('ff_type');
$each_ff = (int) get_parameter('each_ff');
$ff_timeout = (int) get_parameter('ff_timeout');
$unit = (string) get_parameter('unit_select');
@@ -1482,6 +1483,7 @@ if ($update_module) {
'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical,
+ 'ff_type' => $ff_type,
'each_ff' => $each_ff,
'ff_timeout' => $ff_timeout,
'unit' => io_safe_output($unit),
@@ -1677,6 +1679,7 @@ if ($create_module) {
'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical,
+ 'ff_type' => $ff_type,
'each_ff' => $each_ff,
'ff_timeout' => $ff_timeout,
'unit' => io_safe_output($unit),
diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php
index aaa2078479..9d49bb0a96 100644
--- a/pandora_console/godmode/agentes/module_manager_editor.php
+++ b/pandora_console/godmode/agentes/module_manager_editor.php
@@ -249,6 +249,7 @@ if ($id_agent_module) {
$ff_event_normal = $module['min_ff_event_normal'];
$ff_event_warning = $module['min_ff_event_warning'];
$ff_event_critical = $module['min_ff_event_critical'];
+ $ff_type = $module['ff_type'];
$each_ff = $module['each_ff'];
$ff_timeout = $module['ff_timeout'];
// Select tag info.
@@ -393,6 +394,7 @@ if ($id_agent_module) {
$ff_event_normal = '';
$ff_event_warning = '';
$ff_event_critical = '';
+ $ff_type = 0;
$id_category = 0;
diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php
index 892228042a..1724ee6622 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_common.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_common.php
@@ -496,10 +496,28 @@ if (modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[5][1] .= '
'.__('Inverse interval').'';
$table_simple->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy);
-// FF stands for Flip-flop
-$table_simple->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true);
+// FF stands for Flip-flop.
+$table_simple->data[6][0] = __('FF threshold').' ';
+$table_simple->data[6][0] .= ui_print_help_icon('ff_threshold', true);
-$table_simple->data[6][1] = html_print_radio_button('each_ff', 0, '', $each_ff, true, $disabledBecauseInPolicy).' '.__('All state changing').' : ';
+$table_simple->data[6][1] .= __('Keep counters');
+$table_simple->data[6][1] .= html_print_checkbox(
+ 'ff_type',
+ 1,
+ $ff_type,
+ true,
+ $disabledBecauseInPolicy
+).'
';
+
+$table_simple->data[6][1] .= html_print_radio_button(
+ 'each_ff',
+ 0,
+ '',
+ $each_ff,
+ true,
+ $disabledBecauseInPolicy
+);
+$table_simple->data[6][1] .= ' '.__('All state changing').' : ';
$table_simple->data[6][1] .= html_print_input_text(
'ff_event',
$ff_event,
@@ -512,7 +530,16 @@ $table_simple->data[6][1] .= html_print_input_text(
'',
$classdisabledBecauseInPolicy
).'
';
-$table_simple->data[6][1] .= html_print_radio_button('each_ff', 1, '', $each_ff, true, $disabledBecauseInPolicy).' '.__('Each state changing').' : ';
+$table_simple->data[6][1] .= html_print_radio_button(
+ 'each_ff',
+ 1,
+ '',
+ $each_ff,
+ true,
+ $disabledBecauseInPolicy
+);
+
+$table_simple->data[6][1] .= ' '.__('Each state changing').' : ';
$table_simple->data[6][1] .= __('To normal');
$table_simple->data[6][1] .= html_print_input_text(
'ff_event_normal',
@@ -526,6 +553,7 @@ $table_simple->data[6][1] .= html_print_input_text(
'',
$classdisabledBecauseInPolicy
).' ';
+
$table_simple->data[6][1] .= __('To warning');
$table_simple->data[6][1] .= html_print_input_text(
'ff_event_warning',
@@ -539,6 +567,7 @@ $table_simple->data[6][1] .= html_print_input_text(
'',
$classdisabledBecauseInPolicy
).' ';
+
$table_simple->data[6][1] .= __('To critical');
$table_simple->data[6][1] .= html_print_input_text(
'ff_event_critical',
@@ -552,16 +581,31 @@ $table_simple->data[6][1] .= html_print_input_text(
'',
$classdisabledBecauseInPolicy
);
+
$table_simple->data[7][0] = __('Historical data');
if ($disabledBecauseInPolicy) {
- // If is disabled, we send a hidden in his place and print a false checkbox because HTML dont send disabled fields and could be disabled by error
- $table_simple->data[7][1] = html_print_checkbox('history_data_fake', 1, $history_data, true, $disabledBecauseInPolicy);
+ // If is disabled, we send a hidden in his place and print a false
+ // checkbox because HTML dont send disabled fields
+ // and could be disabled by error.
+ $table_simple->data[7][1] = html_print_checkbox(
+ 'history_data_fake',
+ 1,
+ $history_data,
+ true,
+ $disabledBecauseInPolicy
+ );
$table_simple->data[7][1] .= '';
} else {
- $table_simple->data[7][1] = html_print_checkbox('history_data', 1, $history_data, true, $disabledBecauseInPolicy);
+ $table_simple->data[7][1] = html_print_checkbox(
+ 'history_data',
+ 1,
+ $history_data,
+ true,
+ $disabledBecauseInPolicy
+ );
}
-// Advanced form part
+// Advanced form part.
$table_advanced = new stdClass();
$table_advanced->id = 'advanced';
$table_advanced->width = '100%';
diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php
index f1fae1785d..ab2063fe35 100644
--- a/pandora_console/godmode/modules/manage_network_components.php
+++ b/pandora_console/godmode/modules/manage_network_components.php
@@ -124,6 +124,7 @@ $pure = get_parameter('pure', 0);
$ff_event_normal = (int) get_parameter('ff_event_normal');
$ff_event_warning = (int) get_parameter('ff_event_warning');
$ff_event_critical = (int) get_parameter('ff_event_critical');
+$ff_type = (int) get_parameter('ff_type');
$each_ff = (int) get_parameter('each_ff');
if (count($id_tag_selected) == 1 && empty($id_tag_selected[0])) {
@@ -261,6 +262,7 @@ if ($create_component) {
'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical,
+ 'ff_type' => $ff_type,
'each_ff' => $each_ff,
]
);
@@ -355,6 +357,7 @@ if ($update_component) {
'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical,
+ 'ff_type' => $ff_type,
'each_ff' => $each_ff,
]
);
diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php
index 3f9a33cb8a..fd922046d1 100644
--- a/pandora_console/godmode/modules/manage_network_components_form.php
+++ b/pandora_console/godmode/modules/manage_network_components_form.php
@@ -76,6 +76,7 @@ if ($create_network_from_module) {
$ff_event_normal = $data_module['min_ff_event_normal'];
$ff_event_warning = $data_module['min_ff_event_warning'];
$ff_event_critical = $data_module['min_ff_event_critical'];
+ $ff_type = $data_module['ff_type'];
$each_ff = $data_module['each_ff'];
}
@@ -134,6 +135,7 @@ if (isset($id)) {
$ff_event_normal = $component['min_ff_event_normal'];
$ff_event_warning = $component['min_ff_event_warning'];
$ff_event_critical = $component['min_ff_event_critical'];
+ $ff_type = $component['ff_type'];
$each_ff = $component['each_ff'];
if ($type >= 15 && $type <= 18) {
@@ -192,6 +194,7 @@ if (isset($id)) {
$ff_event_normal = 0;
$ff_event_warning = 0;
$ff_event_critical = 0;
+ $ff_type = 0;
$each_ff = 0;
$snmp_version = 1;
diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php
index 2e511c6f6f..7b33a0a275 100644
--- a/pandora_console/godmode/modules/manage_network_components_form_common.php
+++ b/pandora_console/godmode/modules/manage_network_components_form_common.php
@@ -233,7 +233,23 @@ $table->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inver
$table->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true);
$table->colspan[6][1] = 3;
-$table->data[6][1] = html_print_radio_button('each_ff', 0, '', $each_ff, true).' '.__('All state changing').' : ';
+
+$table->data[6][1] = __('Keep counters');
+$table->data[6][1] .= html_print_checkbox(
+ 'ff_type',
+ 1,
+ $ff_type,
+ true
+).'
';
+
+$table->data[6][1] .= html_print_radio_button(
+ 'each_ff',
+ 0,
+ '',
+ $each_ff,
+ true
+).' '.__('All state changing').' : ';
+
$table->data[6][1] .= html_print_input_text(
'ff_event',
$ff_event,
@@ -242,13 +258,40 @@ $table->data[6][1] .= html_print_input_text(
15,
true
).'
';
-$table->data[6][1] .= html_print_radio_button('each_ff', 1, '', $each_ff, true).' '.__('Each state changing').' : ';
+$table->data[6][1] .= html_print_radio_button(
+ 'each_ff',
+ 1,
+ '',
+ $each_ff,
+ true
+).' '.__('Each state changing').' : ';
$table->data[6][1] .= __('To normal');
-$table->data[6][1] .= html_print_input_text('ff_event_normal', $ff_event_normal, '', 5, 15, true).' ';
+$table->data[6][1] .= html_print_input_text(
+ 'ff_event_normal',
+ $ff_event_normal,
+ '',
+ 5,
+ 15,
+ true
+).' ';
$table->data[6][1] .= __('To warning');
-$table->data[6][1] .= html_print_input_text('ff_event_warning', $ff_event_warning, '', 5, 15, true).' ';
+$table->data[6][1] .= html_print_input_text(
+ 'ff_event_warning',
+ $ff_event_warning,
+ '',
+ 5,
+ 15,
+ true
+).' ';
$table->data[6][1] .= __('To critical');
-$table->data[6][1] .= html_print_input_text('ff_event_critical', $ff_event_critical, '', 5, 15, true);
+$table->data[6][1] .= html_print_input_text(
+ 'ff_event_critical',
+ $ff_event_critical,
+ '',
+ 5,
+ 15,
+ true
+);
$table->data[7][0] = __('Historical data');
$table->data[7][1] = html_print_checkbox('history_data', 1, $history_data, true);
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index 0ecc9b8f5d..457bef61d6 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -249,6 +249,10 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
`min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0',
+ `ff_type` tinyint(1) unsigned default '0',
+ `ff_normal` int(4) unsigned default '0',
+ `ff_warning` int(4) unsigned default '0',
+ `ff_critical` int(4) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0',
`ff_timeout` int(4) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0',
@@ -863,6 +867,10 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` (
`min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0',
+ `ff_type` tinyint(1) unsigned default '0',
+ `ff_normal` int(4) unsigned default '0',
+ `ff_warning` int(4) unsigned default '0',
+ `ff_critical` int(4) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0',
`dynamic_max` int(4) default '0',
@@ -2222,6 +2230,10 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` (
`min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0',
+ `ff_type` tinyint(1) unsigned default '0',
+ `ff_normal` int(4) unsigned default '0',
+ `ff_warning` int(4) unsigned default '0',
+ `ff_critical` int(4) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0',
`ff_timeout` int(4) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0',
@@ -2300,6 +2312,10 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` (
`min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0',
+ `ff_type` tinyint(1) unsigned default '0',
+ `ff_normal` int(4) unsigned default '0',
+ `ff_warning` int(4) unsigned default '0',
+ `ff_critical` int(4) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0',
`ff_timeout` int(4) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0',
diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm
index 2e79e4958c..3316cc2202 100644
--- a/pandora_server/lib/PandoraFMS/Core.pm
+++ b/pandora_server/lib/PandoraFMS/Core.pm
@@ -1609,49 +1609,82 @@ sub pandora_process_module ($$$$$$$$$;$) {
my $min_ff_event = $module->{'min_ff_event'};
my $current_utimestamp = time ();
my $ff_timeout = $module->{'ff_timeout'};
+ my $ff_warning = $module->{'ff_warning'};
+ my $ff_critical = $module->{'ff_critical'};
+ my $ff_normal = $module->{'ff_normal'};
- if ($module->{'each_ff'}) {
- $min_ff_event = $module->{'min_ff_event_normal'} if ($new_status == 0);
- $min_ff_event = $module->{'min_ff_event_critical'} if ($new_status == 1);
- $min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2);
- }
-
- if ($last_known_status == $new_status) {
- # Avoid overflows
- $status_changes = $min_ff_event if ($status_changes > $min_ff_event);
+ if ($module->{'ff_type'} == 0) {
+ if ($module->{'each_ff'}) {
+ $min_ff_event = $module->{'min_ff_event_normal'} if ($new_status == 0);
+ $min_ff_event = $module->{'min_ff_event_critical'} if ($new_status == 1);
+ $min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2);
+ }
- $status_changes++;
- if ($module_type =~ m/async/ && $min_ff_event != 0 && $ff_timeout != 0 && ($utimestamp - $ff_start_utimestamp) > $ff_timeout) {
+ if ($last_known_status == $new_status) {
+ # Avoid overflows
+ $status_changes = $min_ff_event if ($status_changes > $min_ff_event);
+
+ $status_changes++;
+ if ($module_type =~ m/async/ && $min_ff_event != 0 && $ff_timeout != 0 && ($utimestamp - $ff_start_utimestamp) > $ff_timeout) {
+ $status_changes = 0;
+ $ff_start_utimestamp = $utimestamp;
+ }
+ }
+ else {
$status_changes = 0;
- $ff_start_utimestamp = $utimestamp;
+ $ff_start_utimestamp = $utimestamp if ($module_type =~ m/async/);
+ }
+
+ # Active ff interval
+ if ($module->{'module_ff_interval'} != 0 && $status_changes < $min_ff_event) {
+ $current_interval = $module->{'module_ff_interval'};
+ }
+
+ # Change status
+ if ($status_changes >= $min_ff_event && $known_status != $new_status) {
+ generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh);
+ $status = $new_status;
+
+ # Update module status count.
+ $mark_for_update = 1;
+
+ # Safe mode execution.
+ if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) {
+ safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh);
+ }
+ }
+ } else {
+ # Independent min_ff_event for all.
+ if ($module->{'each_ff'}) {
+ $min_ff_event = $module->{'min_ff_event_normal'} if ($new_status == 0);
+ $min_ff_event = $module->{'min_ff_event_critical'} if ($new_status == 1);
+ $min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2);
+ }
+
+ if ($last_known_status == $new_status) {
+ $ff_normal = 0;
+ $ff_critical = 0;
+ $ff_warning = 0;
+ } else {
+ # Status change.
+ $ff_critical++ if ($new_status == 1);
+ $ff_warning++ if ($new_status == 2);
+ $ff_normal++ if ($new_status == 0);
+ }
+
+ if ( ($new_status == 0 && $ff_normal >= $min_ff_event)
+ || ($new_status == 1 && $ff_critical >= $min_ff_event)
+ || ($new_status == 2 && $ff_warning >= $min_ff_event)) {
+ $status = $new_status;
+ $ff_normal = 0;
+ $ff_critical = 0;
+ $ff_warning = 0;
}
}
- else {
- $status_changes = 0;
- $ff_start_utimestamp = $utimestamp if ($module_type =~ m/async/);
- }
-
- # Active ff interval
- if ($module->{'module_ff_interval'} != 0 && $status_changes < $min_ff_event) {
- $current_interval = $module->{'module_ff_interval'};
- }
-
- # Change status
- if ($status_changes >= $min_ff_event && $known_status != $new_status) {
- generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh);
- $status = $new_status;
- # Update module status count.
- $mark_for_update = 1;
-
- # Safe mode execution.
- if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) {
- safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh);
- }
- }
# Set not-init modules to normal status even if min_ff_event is not matched the first time they receive data.
# if critical or warning status, just pass through here and wait the time min_ff_event will be matched.
- elsif ($status == 4) {
+ if ($status == 4) {
generate_status_event ($pa_config, $processed_data, $agent, $module, 0, $status, $known_status, $dbh);
$status = 0;
@@ -1692,10 +1725,11 @@ sub pandora_process_module ($$$$$$$$$;$) {
status_changes = ?, utimestamp = ?, timestamp = ?,
id_agente = ?, current_interval = ?, running_by = ?,
last_execution_try = ?, last_try = ?, last_error = ?,
- ff_start_utimestamp = ?
+ ff_start_utimestamp = ?, ff_normal = ?, ff_warning = ?, ff_critical = ?
WHERE id_agente_modulo = ?', $processed_data, $status, $status, $new_status, $new_status, $status_changes,
$current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id,
- $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $ff_start_utimestamp, $module->{'id_agente_modulo'});
+ $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $ff_start_utimestamp,
+ $ff_normal, $ff_warning, $ff_critical, $module->{'id_agente_modulo'});
}
# Save module data. Async and log4x modules are not compressed.