Merge branch 'ent-3858-Alert-template-Condition-Type-Not-normal' into 'develop'

Added condition type not normal in alert templates

See merge request artica/pandorafms!2376

Former-commit-id: bfd561123a0eb57cfb4c99a0c12f3c665a661765
This commit is contained in:
Daniel Rodriguez 2019-05-13 16:51:34 +02:00
commit a38ef3e729
8 changed files with 36 additions and 9 deletions

View File

@ -1,5 +1,8 @@
START TRANSACTION;
ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal');
DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS incident from event';
COMMIT;

View File

@ -1216,13 +1216,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 27);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 28);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '734');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '735');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
-- ---------------------------------------------------------------------
@ -2103,3 +2103,9 @@ ALTER TABLE `tnetflow_filter` DROP COLUMN `output`;
-- Update table `tuser_task`
-- ----------------------------------------------------------------------
UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
-- ----------------------------------------------------------------------
-- Alter table `talert_templates`
-- ----------------------------------------------------------------------
ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal');

View File

@ -186,6 +186,10 @@ switch ($template['type']) {
$condition = __('The alert would fire when the module is in critical status');
break;
case 'not_normal':
$condition = __('The alert would fire when the module is in not normal status');
break;
case 'unknown':
$condition = __('The alert would fire when the module is in unknown status');
break;

View File

@ -679,7 +679,7 @@ if ($step == 2) {
'type',
$type,
'',
__('Select'),
__('None'),
0,
true,
false,
@ -1018,6 +1018,7 @@ var onchange_msg = <?php echo '"'.__('The alert would fire when the module value
var onchange_not = <?php echo '"'.__('The alert would fire when the module value does not change').'"'; ?>;
var unknown = <?php echo "'".__('The alert would fire when the module is in unknown status')."'"; ?>;
var error_message_min_max_zero = <?php echo "'".__('The alert template cannot have the same value for min and max thresholds.')."'"; ?>;
var not_normal = <?php echo "'".__('The alert would fire when the module is in not normal status')."'"; ?>;
function check_fields_step2() {
var correct = true;
@ -1174,6 +1175,13 @@ if ($step == 2) {
/* Show example */
$("span#example").empty ().append (critical);
break;
case "not_normal":
$("#template-value, #template-max, span#matches_value, #template-min").hide ();
$("#template-example").show ();
/* Show example */
$("span#example").empty ().append (not_normal);
break;
case "onchange":
$("#template-value, #template-max, #template-min").hide ();
$("#template-example, span#matches_value").show ();

View File

@ -664,6 +664,7 @@ function alerts_get_alert_templates_types()
$types['unknown'] = __('Unknown status');
$types['onchange'] = __('On Change');
$types['always'] = __('Always');
$types['not_normal'] = __('Not normal status');
return $types;
}
@ -680,7 +681,7 @@ function alerts_get_alert_templates_type_name($type)
{
$types = alerts_get_alert_templates_types();
if (! isset($type[$type])) {
if (!isset($types[$type])) {
return __('Unknown');
}

View File

@ -448,7 +448,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` (
`field13` text NOT NULL,
`field14` text NOT NULL,
`field15` text NOT NULL,
`type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always'),
`type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always', 'not_normal'),
`value` varchar(255) default '',
`matches_value` tinyint(1) default 0,
`max_value` double(18,2) default NULL,

View File

@ -114,10 +114,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''),
('custom_report_front_footer', ''),
('MR', 27),
('MR', 28),
('identification_reminder', 1),
('identification_reminder_timestamp', 0),
('current_package_enterprise', '734'),
('current_package_enterprise', '735'),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'),

View File

@ -391,7 +391,11 @@ sub pandora_generate_alerts ($$$$$$$$;$$$) {
}
# Get enabled alerts associated with this module
my $alert_type_filter = defined ($alert_type) ? " AND type = '$alert_type'" : '';
my $alert_type_filter = '';
if (defined($alert_type)) {
# not_normal includes unknown!
$alert_type_filter = $alert_type eq 'unknown' ? " AND (type = 'unknown' OR type = 'not_normal')" : " AND type = '$alert_type'";
}
my @alerts = get_db_rows ($dbh, '
SELECT talert_template_modules.id as id_template_module,
talert_template_modules.*, talert_templates.*
@ -566,6 +570,7 @@ sub pandora_evaluate_alert ($$$$$$$;$$$) {
return $status if ($last_status != 1 && $alert->{'type'} eq 'critical');
return $status if ($last_status != 2 && $alert->{'type'} eq 'warning');
return $status if ($last_status != 3 && $alert->{'type'} eq 'unknown');
return $status if ($last_status == 0 && $alert->{'type'} eq 'not_normal');
}
# Event alert
else {