diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index dd394645a8..51dc9c54cb 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -10,6 +10,8 @@ ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; +ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL DEFAULT '0'; + ALTER TABLE `tpolicy_modules` ADD COLUMN `cps` int NOT NULL 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 fe494ad6a1..2cb41a72d0 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 @@ -1269,6 +1269,7 @@ UPDATE tagente SET tagente.alias = tagente.nombre; ALTER TABLE `tservice` ADD COLUMN `quiet` tinyint(1) NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `cps` int NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `cascade_protection` tinyint(1) NOT NULL default 0; +ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL default 0; -- --------------------------------------------------------------------- -- Table `tlayout` diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 40aee4353f..8979b04b14 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -10345,10 +10345,11 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) { * * @param $thrash1 Don't use. * @param $thrash2 Don't use. - * @param array $other it's array, $other as param is ;;; + * @param array $other it's array, $other as param is ;;; * ;;;;; - * ;; - * in this order and separator char (after text ; ) and separator + * ;;; + * ;; + * in this order and separator char (after text ; ) and separator * (pass in param othermode as othermode=url_encode_separator_) * @param $thrash3 Don't use * @@ -10376,6 +10377,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { $id_critical_module_sla = $other['data'][10]; $quiet = $other['data'][11]; $cascade_protection = $other['data'][12]; + $evaluate_sla = $other['data'][13]; if(empty($name)){ returnError('error_create_service', __('Error in creation service. No name')); @@ -10425,6 +10427,9 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { if(empty($cascade_protection)){ $cascade_protection = 0; } + if(empty($evaluate_sla)){ + $evaluate_sla = 0; + } $result = services_create_service ( $name, $description, $id_group, @@ -10432,7 +10437,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { $mode, $id_agent, $sla_interval, $sla_limit, $id_warning_module_template, $id_critical_module_template, $id_unknown_module_template, $id_critical_module_sla, - $quiet, $cascade_protection + $quiet, $cascade_protection, $evaluate_sla ); if($result){ @@ -10447,10 +10452,11 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { * * @param $thrash1 service id. * @param $thrash2 Don't use. - * @param array $other it's array, $other as param is ;;;; + * @param array $other it's array, $other as param is ;;;; * ;;;;; - * ;; - * in this order and separator char (after text ; ) and separator + * ;;; + * ;; + * in this order and separator char (after text ; ) and separator * (pass in param othermode as othermode=url_encode_separator_) * @param $thrash3 Don't use * @@ -10548,6 +10554,11 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) { $cascade_protection = $service['cascade_protection']; } + $evaluate_sla = $other['data'][13]; + if(empty($evaluate_sla)){ + $evaluate_sla = $service['evaluate_sla']; + } + $result = services_update_service ( $id_service, $name,$description, $id_group, $critical, $warning, SECONDS_5MINUTES, $mode, @@ -10556,7 +10567,8 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) { $id_critical_module_template, $id_unknown_module_template, $id_critical_module_sla, - $quiet, $cascade_protection + $quiet, $cascade_protection, + $evaluate_sla ); if($result){ @@ -10571,10 +10583,10 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) { * * @param $thrash1 service id. * @param $thrash2 Don't use. - * @param array $other it's a json, $other as param is ;;; + * @param array $other it's a json, $other as param is ;;; * ;;;;; - * ;; - * in this order and separator char (after text ; ) and separator + * ;; + * in this order and separator char (after text ; ) and separator * (pass in param othermode as othermode=url_encode_separator_) * @param $thrash3 Don't use * @@ -10590,7 +10602,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { if (is_metaconsole()) return; $id = $thrash1; - + if(empty($id)){ returnError('error_add_service_element', __('Error adding elements to service. No service id')); return; @@ -10619,7 +10631,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { continue; } break; - + case 'module': $agent_id = 0; $id_service_child = 0; @@ -10628,7 +10640,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { continue; } break; - + case 'service': $agent_id = 0; $id_agente_modulo = 0; @@ -10641,7 +10653,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { } break; } - + $values = array( 'id_agente_modulo' => $id_agente_modulo, 'description' => $element['description'], @@ -10653,20 +10665,20 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { 'id_agent' => $agent_id, 'id_service_child' => $id_service_child, 'id_server_meta' => 0); - + $result = db_process_sql_insert('tservice_element',$values); if($result && !$results){ $results = $result; } } } - + if($results){ returnData('string', array('type' => 'string', 'data' => 1)); } else { returnError('error_add_service_element', __('Error adding elements to service')); } - + } /** * Update a special day. And return a message with the result of the operation. diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 06d965d939..cbee30c35f 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4091,21 +4091,32 @@ function fullscale_data ( $data["sum" . $series_suffix]['data'][] = array($real_date , $sum_data/$count_data); if($type_mode_graph && !$params['baseline']){ - $data["min" . $series_suffix]['data'][] = array($real_date , $min_value); - $data["max" . $series_suffix]['data'][] = array($real_date , $max_value); + if($min_value != PHP_INT_MAX) { + $data["min" . $series_suffix]['data'][] = array($real_date , $min_value); + } + + if($max_value != -PHP_INT_MAX) { + $data["max" . $series_suffix]['data'][] = array($real_date , $max_value); + } } else{ - $data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value; + if($min_value != PHP_INT_MAX) { + $data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value; + } + $data["sum" . $series_suffix]['slice_data'][$real_date]['avg'] = $sum_data/$count_data; - $data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value; + + if($max_value != -PHP_INT_MAX) { + $data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value; + } } //max_total - if($max_value >= $max_value_total){ + if($max_value >= $max_value_total && $max_value != -PHP_INT_MAX){ $max_value_total = $max_value; } //min_total - if($min_value <= $min_value_total){ + if($min_value <= $min_value_total && $min_value != PHP_INT_MAX){ $min_value_total = $min_value; } //avg sum_total @@ -4117,27 +4128,31 @@ function fullscale_data ( if($type_mode_graph && !$params['baseline']){ /*MIN*/ //max_min - if($min_value >= $min_value_max){ + if($min_value >= $min_value_max && $min_value != PHP_INT_MAX){ $min_value_max = $min_value; } //min_min - if($min_value <= $min_value_min){ + if($min_value <= $min_value_min && $min_value != PHP_INT_MAX){ $min_value_min = $min_value; } //avg sum_min - $sum_data_min += $min_value; + if ($min_value != PHP_INT_MAX) { + $sum_data_min += $min_value; + } /*MAX*/ //max_max - if($max_value >= $max_value_max){ + if($max_value >= $max_value_max && $max_value != -PHP_INT_MAX){ $max_value_max = $max_value; } //min_max - if($max_value <= $max_value_min){ + if($max_value <= $max_value_min && $max_value != -PHP_INT_MAX){ $max_value_min = $max_value; } //avg sum_max - $sum_data_max += $max_value; + if ($max_value != -PHP_INT_MAX) { + $sum_data_max += $max_value; + } /*AVG*/ //max_max diff --git a/pandora_console/include/help/en/help_alert_config.php b/pandora_console/include/help/en/help_alert_config.php index b8d02b6282..8eeb49e34d 100644 --- a/pandora_console/include/help/en/help_alert_config.php +++ b/pandora_console/include/help/en/help_alert_config.php @@ -90,6 +90,7 @@ Apart from the defined module macros, the following macros are also available:
  • _plugin_parameters_: Module plugin parameters.
  • _policy_: Name of the policy that the module belongs to (if applies).
  • _prevdata_: Module previous data before the alert has been triggered.
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_: Ip of server assigned to agent.
  • _server_name_: Name of server assigned to agent.
  • _target_ip_: IP address for the module’s target.
  • diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php index d2afc89053..a40d56e122 100644 --- a/pandora_console/include/help/en/help_alert_macros.php +++ b/pandora_console/include/help/en/help_alert_macros.php @@ -75,6 +75,7 @@ Besides the defined module macros, the following macros are available:
  • _plugin_parameters_: Module plugin parameters.
  • _policy_: Name of the policy that the module belongs to (if applies).
  • _prevdata_: Module previous data before the alert has been triggered.
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_: Ip of server assigned to agent.
  • _server_name_: Name of server assigned to agent.
  • _target_ip_: IP address for the module’s target.
  • diff --git a/pandora_console/include/help/es/help_alert_config.php b/pandora_console/include/help/es/help_alert_config.php index 312862a10e..e26533ba9a 100644 --- a/pandora_console/include/help/es/help_alert_config.php +++ b/pandora_console/include/help/es/help_alert_config.php @@ -92,6 +92,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _plugin_parameters_: Parámetros del plugin del módulo.
  • _policy_: Nombre de la política a la que pertenece el módulo (si aplica).
  • _prevdata_: Dato previo antes de disparase la alerta.
  • +
  • _rca_: Cadena de análasis de causa raíz (sólo para servicios).
  • _server_ip_: Ip del servidor al que el agente está asignado.
  • _server_name_: Nombre del servidor al que el agente está asignado.
  • _target_ip_: Dirección IP del objetivo del módulo.
  • diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php index fec55d7175..2817b32abb 100644 --- a/pandora_console/include/help/es/help_alert_macros.php +++ b/pandora_console/include/help/es/help_alert_macros.php @@ -75,6 +75,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _plugin_parameters_: Parámetros del plugin del módulo.
  • _policy_: Nombre de la política a la que pertenece el módulo (si aplica).
  • _prevdata_: Dato previo antes de disparase la alerta.
  • +
  • _rca_: Cadena de análasis de causa raíz (sólo para servicios).
  • _server_ip_: Ip del servidor al que el agente está asignado.
  • _server_name_: Nombre del servidor al que el agente está asignado.
  • _target_ip_: Dirección IP del objetivo del módulo.
  • diff --git a/pandora_console/include/help/ja/help_alert_config.php b/pandora_console/include/help/ja/help_alert_config.php index 870591f83a..d8dab9c2fa 100644 --- a/pandora_console/include/help/ja/help_alert_config.php +++ b/pandora_console/include/help/ja/help_alert_config.php @@ -91,6 +91,7 @@ email アクションを設定するには、_field1_ (送信先アドレス)、
  • _plugin_parameters_ : モジュールのプラグインパラメータ
  • _policy_ : モジュールが属するポリシー名 (存在する場合)
  • _prevdata_ : アラートを発報する前のモジュールデータ
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_ : エージェントが割り当てられているサーバ IP。
  • _server_name_ : エージェントが割り当てられているサーバ名。
  • _target_ip_ : モジュールの対象IPアドレス
  • diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 85b1de7c46..1a7fd69680 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -75,6 +75,7 @@
  • _plugin_parameters_ : モジュールのプラグインパラメータ
  • _policy_ : モジュールが属するポリシー名 (存在する場合)
  • _prevdata_ : アラートを発報する前のモジュールデータ
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_ : エージェントが割り当てられているサーバ IP。
  • _server_name_ : エージェントが割り当てられているサーバ名。
  • _target_ip_ : モジュールの対象IPアドレス
  • diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 4399b4a546..bbc990168b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2430,6 +2430,7 @@ CREATE TABLE IF NOT EXISTS `tservice` ( `quiet` tinyint(1) NOT NULL default 0, `cps` int NOT NULL default 0, `cascade_protection` tinyint(1) NOT NULL default 0, + `evaluate_sla` int(1) NOT NULL default 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB COMMENT = 'Table to define services to monitor' diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 12ac711da5..19caec0169 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -352,16 +352,6 @@ sub pandora_generate_alerts ($$$$$$$$;$$$) { return; } - if ($agent->{'cps'} > 0) { - logger($pa_config, "Generate Alert. The agent '" . $agent->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } - - if ($module->{'cps'} > 0) { - logger($pa_config, "Generate Alert. The module '" . $module->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } - # Do not generate alerts for disabled groups if (is_group_disabled ($dbh, $agent->{'id_grupo'})) { return; @@ -1649,7 +1639,7 @@ sub pandora_process_module ($$$$$$$$$;$) { } # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) { pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $timestamp, $extra_macros, $last_data_value); } else { @@ -3140,11 +3130,6 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) { logger($pa_config, "Generate Event. The agent '" . $agent->{'nombre'} . "' is in quiet mode.", 10); return; } - - if (defined ($agent) && $agent->{'cps'} > 0) { - logger($pa_config, "Generate Event. The agent '" . $agent->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } } my $module = undef; @@ -3154,11 +3139,6 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) { logger($pa_config, "Generate Event. The module '" . $module->{'nombre'} . "' is in quiet mode.", 10); return; } - - if (defined ($module) && $module->{'cps'} > 0) { - logger($pa_config, "Generate Event. The module '" . $module->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } } # Get module tags @@ -4289,6 +4269,20 @@ sub pandora_inhibit_alerts { return pandora_inhibit_alerts ($pa_config, $agent, $dbh, $depth + 1); } +########################################################################## +# Returns 1 if service cascade protection is enabled for the given +# agent/module, 0 otherwise. +########################################################################## +sub pandora_cps_enabled($$) { + my ($agent, $module) = @_; + + return 1 if ($agent->{'cps'} > 0); + + return 1 if ($module->{'cps'} > 0); + + return 0; +} + ########################################################################## =head2 C<< save_agent_position (I<$pa_config>, I<$current_longitude>, I<$current_latitude>, I<$current_altitude>, I<$agent_id>, I<$dbh>, [I<$start_timestamp>], [I<$description>]) >> @@ -4925,7 +4919,7 @@ sub pandora_module_unknown ($$) { pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'}); # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) { pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); } else { @@ -4969,7 +4963,7 @@ sub pandora_module_unknown ($$) { pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'}); # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) { pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); } else { diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index ec7fa7e586..361eb338e2 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -176,7 +176,7 @@ sub exec_prediction_module ($$$$) { logger ($pa_config, "Executing service module " . $agent_module->{'id_agente_modulo'} . " " . $agent_module->{'nombre'}, 10); - enterprise_hook ('exec_service_module', [$pa_config, $agent_module, $server_id, $dbh]); + enterprise_hook ('exec_service_module', [$pa_config, $agent_module, undef, $server_id, $dbh]); } return;