Merge branch '2226-Analisis_de_causa_raiz_en_alertas_mediante_los_servicios' into 'develop'
add new column evaluate_sla into table tservice See merge request artica/pandorafms!1580
This commit is contained in:
commit
71be336667
|
@ -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;
|
|
@ -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`
|
||||
|
|
|
@ -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 <description>;<id_group>;<critical>;
|
||||
* @param array $other it's array, $other as param is <description>;<id_group>;<critical>;
|
||||
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
|
||||
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;
|
||||
* in this order and separator char (after text ; ) and separator
|
||||
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;<quiet>;
|
||||
* <cascade_protection>;<evaluate_sla>;
|
||||
* in this order and separator char (after text ; ) and separator
|
||||
* (pass in param othermode as othermode=url_encode_separator_<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 <name>;<description>;<id_group>;<critical>;
|
||||
* @param array $other it's array, $other as param is <name>;<description>;<id_group>;<critical>;
|
||||
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
|
||||
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;
|
||||
* in this order and separator char (after text ; ) and separator
|
||||
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;<quiet>;
|
||||
* <cascade_protection>;<evaluate_sla>;
|
||||
* in this order and separator char (after text ; ) and separator
|
||||
* (pass in param othermode as othermode=url_encode_separator_<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 <description>;<id_group>;<critical>;
|
||||
* @param array $other it's a json, $other as param is <description>;<id_group>;<critical>;
|
||||
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
|
||||
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;
|
||||
* in this order and separator char (after text ; ) and separator
|
||||
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;
|
||||
* in this order and separator char (after text ; ) and separator
|
||||
* (pass in param othermode as othermode=url_encode_separator_<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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -90,6 +90,7 @@ Apart from the defined module macros, the following macros are also available:
|
|||
<li>_plugin_parameters_: Module plugin parameters.</li>
|
||||
<li>_policy_: Name of the policy that the module belongs to (if applies).</li>
|
||||
<li>_prevdata_: Module previous data before the alert has been triggered.</li>
|
||||
<li>_rca_: Root cause analysis chain (only for services).</li>
|
||||
<li>_server_ip_: Ip of server assigned to agent. </li>
|
||||
<li>_server_name_: Name of server assigned to agent. </li>
|
||||
<li>_target_ip_: IP address for the module’s target.</li>
|
||||
|
|
|
@ -75,6 +75,7 @@ Besides the defined module macros, the following macros are available:
|
|||
<li>_plugin_parameters_: Module plugin parameters.</li>
|
||||
<li>_policy_: Name of the policy that the module belongs to (if applies).</li>
|
||||
<li>_prevdata_: Module previous data before the alert has been triggered.</li>
|
||||
<li>_rca_: Root cause analysis chain (only for services).</li>
|
||||
<li>_server_ip_: Ip of server assigned to agent. </li>
|
||||
<li>_server_name_: Name of server assigned to agent. </li>
|
||||
<li>_target_ip_: IP address for the module’s target.</li>
|
||||
|
|
|
@ -92,6 +92,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
|
|||
<li>_plugin_parameters_: Parámetros del plugin del módulo.</li>
|
||||
<li>_policy_: Nombre de la política a la que pertenece el módulo (si aplica).</li>
|
||||
<li>_prevdata_: Dato previo antes de disparase la alerta.</li>
|
||||
<li>_rca_: Cadena de análasis de causa raíz (sólo para servicios).</li>
|
||||
<li>_server_ip_: Ip del servidor al que el agente está asignado. </li>
|
||||
<li>_server_name_: Nombre del servidor al que el agente está asignado. </li>
|
||||
<li>_target_ip_: Dirección IP del objetivo del módulo.</li>
|
||||
|
|
|
@ -75,6 +75,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
|
|||
<li>_plugin_parameters_: Parámetros del plugin del módulo.</li>
|
||||
<li>_policy_: Nombre de la política a la que pertenece el módulo (si aplica).</li>
|
||||
<li>_prevdata_: Dato previo antes de disparase la alerta.</li>
|
||||
<li>_rca_: Cadena de análasis de causa raíz (sólo para servicios).</li>
|
||||
<li>_server_ip_: Ip del servidor al que el agente está asignado. </li>
|
||||
<li>_server_name_: Nombre del servidor al que el agente está asignado. </li>
|
||||
<li>_target_ip_: Dirección IP del objetivo del módulo.</li>
|
||||
|
|
|
@ -91,6 +91,7 @@ email アクションを設定するには、_field1_ (送信先アドレス)、
|
|||
<li>_plugin_parameters_ : モジュールのプラグインパラメータ</li>
|
||||
<li>_policy_ : モジュールが属するポリシー名 (存在する場合)</li>
|
||||
<li>_prevdata_ : アラートを発報する前のモジュールデータ</li>
|
||||
<li>_rca_: Root cause analysis chain (only for services).</li>
|
||||
<li>_server_ip_ : エージェントが割り当てられているサーバ IP。</li>
|
||||
<li>_server_name_ : エージェントが割り当てられているサーバ名。 </li>
|
||||
<li>_target_ip_ : モジュールの対象IPアドレス</li>
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<li>_plugin_parameters_ : モジュールのプラグインパラメータ</li>
|
||||
<li>_policy_ : モジュールが属するポリシー名 (存在する場合)</li>
|
||||
<li>_prevdata_ : アラートを発報する前のモジュールデータ</li>
|
||||
<li>_rca_: Root cause analysis chain (only for services).</li>
|
||||
<li>_server_ip_ : エージェントが割り当てられているサーバ IP。</li>
|
||||
<li>_server_name_ : エージェントが割り当てられているサーバ名。 </li>
|
||||
<li>_target_ip_ : モジュールの対象IPアドレス</li>
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue