Fix issues with alert fields

This commit is contained in:
Jose Gonzalez 2020-11-26 13:39:17 +01:00
parent 31f23a7994
commit dbfe52e383
2 changed files with 75 additions and 17 deletions

View File

@ -0,0 +1,9 @@
START TRANSACTION;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field16` TEXT NOT NULL DEFAULT "" AFTER `al_field15`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field17` TEXT NOT NULL DEFAULT "" AFTER `al_field16`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field18` TEXT NOT NULL DEFAULT "" AFTER `al_field17`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field19` TEXT NOT NULL DEFAULT "" AFTER `al_field18`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field20` TEXT NOT NULL DEFAULT "" AFTER `al_field19`;
COMMIT;

View File

@ -1,16 +1,17 @@
<?php <?php
/**
// Pandora FMS - http://pandorafms.com * Pandora FMS - http://pandorafms.com
// ================================================== * ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas * Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2. * as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. * GNU General Public License for more details.
*/
// Load global vars // Load global vars
if (! check_acl($config['id_user'], 0, 'LW')) { if (! check_acl($config['id_user'], 0, 'LW')) {
db_pandora_audit( db_pandora_audit(
@ -61,6 +62,11 @@ if ($add_action) {
$values[db_escape_key_identifier('al_field13')] = get_parameter('field13_value'); $values[db_escape_key_identifier('al_field13')] = get_parameter('field13_value');
$values[db_escape_key_identifier('al_field14')] = get_parameter('field14_value'); $values[db_escape_key_identifier('al_field14')] = get_parameter('field14_value');
$values[db_escape_key_identifier('al_field15')] = get_parameter('field15_value'); $values[db_escape_key_identifier('al_field15')] = get_parameter('field15_value');
$values[db_escape_key_identifier('al_field16')] = get_parameter('field16_value');
$values[db_escape_key_identifier('al_field17')] = get_parameter('field17_value');
$values[db_escape_key_identifier('al_field18')] = get_parameter('field18_value');
$values[db_escape_key_identifier('al_field19')] = get_parameter('field19_value');
$values[db_escape_key_identifier('al_field20')] = get_parameter('field20_value');
$result = db_process_sql_insert('talert_snmp_action', $values); $result = db_process_sql_insert('talert_snmp_action', $values);
} }
@ -123,6 +129,11 @@ if ($save_alert || $modify_alert) {
$al_field13 = (string) get_parameter_post('field13_value'); $al_field13 = (string) get_parameter_post('field13_value');
$al_field14 = (string) get_parameter_post('field14_value'); $al_field14 = (string) get_parameter_post('field14_value');
$al_field15 = (string) get_parameter_post('field15_value'); $al_field15 = (string) get_parameter_post('field15_value');
$al_field16 = (string) get_parameter_post('field16_value');
$al_field17 = (string) get_parameter_post('field17_value');
$al_field18 = (string) get_parameter_post('field18_value');
$al_field19 = (string) get_parameter_post('field19_value');
$al_field20 = (string) get_parameter_post('field20_value');
$max_alerts = (int) get_parameter_post('max_alerts', 1); $max_alerts = (int) get_parameter_post('max_alerts', 1);
$min_alerts = (int) get_parameter_post('min_alerts', 0); $min_alerts = (int) get_parameter_post('min_alerts', 0);
$priority = (int) get_parameter_post('priority', 0); $priority = (int) get_parameter_post('priority', 0);
@ -195,6 +206,11 @@ if ($save_alert || $modify_alert) {
'al_field13' => $al_field13, 'al_field13' => $al_field13,
'al_field14' => $al_field14, 'al_field14' => $al_field14,
'al_field15' => $al_field15, 'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
'description' => $description, 'description' => $description,
'agent' => $source_ip, 'agent' => $source_ip,
'custom_oid' => $custom_value, 'custom_oid' => $custom_value,
@ -267,7 +283,9 @@ if ($save_alert || $modify_alert) {
al_field5 = '%s', al_field6 = '%s',al_field7 = '%s', al_field5 = '%s', al_field6 = '%s',al_field7 = '%s',
al_field8 = '%s', al_field9 = '%s',al_field10 = '%s', al_field8 = '%s', al_field9 = '%s',al_field10 = '%s',
al_field11 = '%s', al_field12 = '%s', al_field13 = '%s', al_field11 = '%s', al_field12 = '%s', al_field13 = '%s',
al_field14 = '%s', al_field15 = '%s', al_field14 = '%s', al_field15 = '%s', al_field16 = '%s',
al_field17 = '%s', al_field18 = '%s', al_field19 = '%s',
al_field20 = '%s',
description = '%s', description = '%s',
agent = '%s', custom_oid = '%s', oid = '%s', agent = '%s', custom_oid = '%s', oid = '%s',
time_threshold = %d, max_alerts = %d, min_alerts = %d, time_threshold = %d, max_alerts = %d, min_alerts = %d,
@ -318,6 +336,11 @@ if ($save_alert || $modify_alert) {
$al_field13, $al_field13,
$al_field14, $al_field14,
$al_field15, $al_field15,
$al_field16,
$al_field17,
$al_field18,
$al_field19,
$al_field20,
$description, $description,
$source_ip, $source_ip,
$custom_value, $custom_value,
@ -417,6 +440,11 @@ if ($update_alert || $duplicate_alert) {
$al_field13 = $alert['al_field13']; $al_field13 = $alert['al_field13'];
$al_field14 = $alert['al_field14']; $al_field14 = $alert['al_field14'];
$al_field15 = $alert['al_field15']; $al_field15 = $alert['al_field15'];
$al_field16 = $alert['al_field16'];
$al_field17 = $alert['al_field17'];
$al_field18 = $alert['al_field18'];
$al_field19 = $alert['al_field19'];
$al_field20 = $alert['al_field20'];
$max_alerts = $alert['max_alerts']; $max_alerts = $alert['max_alerts'];
$min_alerts = $alert['min_alerts']; $min_alerts = $alert['min_alerts'];
$priority = $alert['priority']; $priority = $alert['priority'];
@ -490,6 +518,11 @@ if ($update_alert || $duplicate_alert) {
$al_field13 = ''; $al_field13 = '';
$al_field14 = ''; $al_field14 = '';
$al_field15 = ''; $al_field15 = '';
$al_field16 = '';
$al_field17 = '';
$al_field18 = '';
$al_field19 = '';
$al_field20 = '';
$max_alerts = 1; $max_alerts = 1;
$min_alerts = 0; $min_alerts = 0;
$priority = 0; $priority = 0;
@ -548,9 +581,10 @@ if ($duplicate_alert) {
al_field4, al_field5, al_field6, al_field7, al_field4, al_field5, al_field6, al_field7,
al_field8, al_field9, al_field10, al_field11, al_field8, al_field9, al_field10, al_field11,
al_field12, al_field13, al_field14, al_field15, al_field12, al_field13, al_field14, al_field15,
description, alert_type, agent, custom_oid, oid, time_threshold, al_field16, al_field17, al_field18, al_field19,
times_fired, last_fired, max_alerts, min_alerts, al_field20, description, alert_type, agent, custom_oid,
internal_counter, priority, oid, time_threshold, times_fired, last_fired,
max_alerts, min_alerts, internal_counter, priority,
'.db_escape_key_identifier('_snmp_f1_').', '.db_escape_key_identifier('_snmp_f1_').',
'.db_escape_key_identifier('_snmp_f2_').', '.db_escape_key_identifier('_snmp_f2_').',
'.db_escape_key_identifier('_snmp_f3_').', '.db_escape_key_identifier('_snmp_f3_').',
@ -597,6 +631,11 @@ if ($duplicate_alert) {
$al_field13, $al_field13,
$al_field14, $al_field14,
$al_field15, $al_field15,
$al_field16,
$al_field17,
$al_field18,
$al_field19,
$al_field20,
$description, $description,
$alert_type, $alert_type,
$source_ip, $source_ip,
@ -998,6 +1037,11 @@ if ($create_alert || $update_alert) {
'al_field13' => $al_field13, 'al_field13' => $al_field13,
'al_field14' => $al_field14, 'al_field14' => $al_field14,
'al_field15' => $al_field15, 'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
]; ];
// Hidden div with help hint to fill with javascript // Hidden div with help hint to fill with javascript
@ -1421,6 +1465,11 @@ if ($create_alert || $update_alert) {
'al_field13' => $al_field13, 'al_field13' => $al_field13,
'al_field14' => $al_field14, 'al_field14' => $al_field14,
'al_field15' => $al_field15, 'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
]; ];
for ($i = 1; $i <= $config['max_macro_fields']; $i++) { for ($i = 1; $i <= $config['max_macro_fields']; $i++) {