Merge branch 'ent-6102-edicion-nombre-sincronizacion-alertas-metaconsola' into 'develop'

Ent 6102 edicion nombre sincronizacion alertas metaconsola

See merge request artica/pandorafms!3364
This commit is contained in:
Daniel Rodriguez 2020-08-20 14:43:17 +02:00
commit 0512149ee4
10 changed files with 82 additions and 41 deletions

View File

@ -0,0 +1,9 @@
START TRANSACTION;
ALTER TABLE `talert_templates` ADD COLUMN `previous_name` text;
ALTER TABLE `talert_actions` ADD COLUMN `previous_name` text;
ALTER TABLE `talert_commands` ADD COLUMN `previous_name` text;
ALTER TABLE `ttag` ADD COLUMN `previous_name` text NULL;
ALTER TABLE `tconfig_os` ADD COLUMN `previous_name` text NULL;
COMMIT;

View File

@ -1312,6 +1312,8 @@ ALTER TABLE talert_actions ADD COLUMN `field12_recovery` TEXT NOT NULL DEFAULT "
ALTER TABLE talert_actions ADD COLUMN `field13_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_actions ADD COLUMN `field14_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_actions` ADD COLUMN `previous_name` text;
ALTER TABLE `talert_actions` MODIFY COLUMN `field11` text NOT NULL,
MODIFY COLUMN `field12` text NOT NULL,
MODIFY COLUMN `field13` text NOT NULL,
@ -1325,6 +1327,7 @@ UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria IMS 
UPDATE `talert_commands` SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using:
_field1_ as destination email address, and
_field2_ as subject for message. 
_field3_ as text of message. 
_field4_ as content type (text/plain or html/text).', `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1;
ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0;
ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text;
ALTER TABLE `talert_commands` ADD COLUMN `previous_name` text;
UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1;
@ -1337,6 +1340,11 @@ ALTER TABLE `talert_commands` MODIFY COLUMN `id_group` mediumint(8) unsigned NUL
-- ---------------------------------------------------------------------
ALTER TABLE `tmap` MODIFY COLUMN `id_user` varchar(250) NOT NULL DEFAULT '';
-- ---------------------------------------------------------------------
-- Table `ttag`
-- ---------------------------------------------------------------------
ALTER TABLE `ttag` ADD COLUMN `previous_name` text NULL;
-- ---------------------------------------------------------------------
-- Table `tconfig`
-- ---------------------------------------------------------------------
@ -1381,7 +1389,9 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', '');
-- Table `tconfig_os`
-- ---------------------------------------------------------------------
INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES (100, 'Cluster', 'Cluster agent', 'so_cluster.png');
ALTER TABLE `tconfig_os` ADD COLUMN `previous_name` text NULL;
INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES (100, 'Cluster', 'Cluster agent', 'so_cluster.png', '');
UPDATE `tagente` SET `id_os` = 100 WHERE `id_os` = 21 and (select `id_os` from `tconfig_os` WHERE `id_os` = 21 and `name` = 'Cluster');
@ -2461,6 +2471,8 @@ INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES
-- Alter table `talert_templates`
-- ----------------------------------------------------------------------
ALTER TABLE `talert_templates` ADD COLUMN `previous_name` text;
ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal');
ALTER TABLE `talert_templates` MODIFY COLUMN `field11` text NOT NULL,

View File

@ -362,6 +362,7 @@ $templates = alerts_get_alert_templates(
'description',
'type',
'id_group',
'previous_name',
]
);
if ($templates === false) {

View File

@ -83,6 +83,10 @@ if ($update_command) {
$values['command'] = $command;
$values['description'] = $description;
$values['id_group'] = $id_group;
// Only for Metaconsole. Save the previous name for synchronizing.
if (is_metaconsole()) {
$values['previous_name'] = db_get_value('name', 'talert_commands', 'id', $id);
}
// Check it the new name is used in the other command.
$id_check = db_get_value('id', 'talert_commands', 'name', $name);

View File

@ -34,6 +34,9 @@ if (! check_acl($config['id_user'], 0, 'LM')) {
$duplicate_template = (bool) get_parameter('duplicate_template');
$id = (int) get_parameter('id');
$pure = get_parameter('pure', 0);
$step = (int) get_parameter('step', 1);
// We set here the number of steps.
define('LAST_STEP', 3);
// If user tries to duplicate/edit a template with group=ALL then must have "PM" access privileges
if ($duplicate_template) {
@ -56,7 +59,6 @@ if ($a_template !== false) {
if (defined('METACONSOLE')) {
alerts_meta_print_header();
} else {
$step = (int) get_parameter('step', 1);
if ($step == 1) {
$help_header = '';
} else if ($step == 2) {
@ -113,7 +115,6 @@ if ($a_template !== false) {
if (defined('METACONSOLE')) {
alerts_meta_print_header();
} else {
$step = (int) get_parameter('step', 1);
if ($step == 1) {
$help_header = '';
} else if ($step == 2) {
@ -252,24 +253,20 @@ function update_template($step)
$wizard_level = (string) get_parameter('wizard_level');
$priority = (int) get_parameter('priority');
$id_group = get_parameter('id_group');
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
$name_check = db_get_value('name', 'talert_templates', 'name', $name);
break;
case 'oracle':
$name_check = db_get_value('name', 'talert_templates', 'to_char(name)', $name);
break;
// Only for Metaconsole. Save the previous name for synchronizing.
if (is_metaconsole()) {
$previous_name = db_get_value('name', 'talert_templates', 'id', $id);
} else {
$previous_name = '';
}
$values = [
'name' => $name,
'description' => $description,
'id_group' => $id_group,
'priority' => $priority,
'wizard_level' => $wizard_level,
'name' => $name,
'description' => $description,
'id_group' => $id_group,
'priority' => $priority,
'wizard_level' => $wizard_level,
'previous_name' => $previous_name,
];
$result = alerts_update_alert_template($id, $values);

View File

@ -98,6 +98,10 @@ switch ($action) {
$values = [];
$values['name'] = $name;
$values['description'] = $description;
// Only for Metaconsole. Save the previous name for synchronizing.
if (is_metaconsole()) {
$values['previous_name'] = db_get_value('name', 'tconfig_os', 'id_os', $idOS);
}
if (($icon !== 0) && ($icon != '')) {
$values['icon_name'] = $icon;

View File

@ -79,6 +79,10 @@ if ($update_tag && $id_tag != 0) {
$values['url'] = $url_tag;
$values['email'] = $email_tag;
$values['phone'] = $phone_tag;
// Only for Metaconsole. Save the previous name for synchronizing.
if (is_metaconsole()) {
$values['previous_name'] = db_get_value('name', 'ttag', 'id_tag', $id_tag);
}
$result = false;
if ($values['name'] != '') {

View File

@ -2780,6 +2780,11 @@ function alerts_ui_update_or_create_actions($update=true)
if ($update) {
$values['name'] = $name;
$values['id_alert_command'] = $id_alert_command;
// Only for Metaconsole, save the previous name for synchronization.
if (is_metaconsole()) {
$values['previous_name'] = db_get_value('name', 'talert_actions', 'id', $id);
}
$result = (!$name) ? '' : alerts_update_alert_action($id, $values);
} else {
$name_check = db_get_value('name', 'talert_actions', 'name', $name);

View File

@ -381,6 +381,7 @@ CREATE TABLE IF NOT EXISTS `talert_commands` (
`fields_descriptions` TEXT,
`fields_values` TEXT,
`fields_hidden` TEXT,
`previous_name` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -423,6 +424,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` (
`field13_recovery` text NOT NULL,
`field14_recovery` text NOT NULL,
`field15_recovery` text NOT NULL,
`previous_name` text,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`)
ON DELETE CASCADE ON UPDATE CASCADE
@ -490,6 +492,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` (
`wizard_level` enum('basic','advanced','nowizard') default 'nowizard',
`min_alerts_reset_counter` tinyint(1) default 0,
`disable_event` tinyint(1) default 0,
`previous_name` text,
PRIMARY KEY (`id`),
KEY `idx_template_action` (`id_alert_action`),
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
@ -583,6 +586,7 @@ CREATE TABLE IF NOT EXISTS `tconfig_os` (
`name` varchar(100) NOT NULL default '',
`description` varchar(250) default '',
`icon_name` varchar(100) default '',
`previous_name` text NULL,
PRIMARY KEY (`id_os`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -2038,9 +2042,10 @@ CREATE TABLE IF NOT EXISTS `ttag` (
`id_tag` integer(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
`description` text NOT NULL,
`url` mediumtext NOT NULL,
`url` mediumtext NOT NULL,
`email` text NULL,
`phone` text NULL,
`previous_name` text NULL,
PRIMARY KEY (`id_tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -150,27 +150,27 @@ UNLOCK TABLES;
--
LOCK TABLES `tconfig_os` WRITE;
INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES
(1,'Linux','Linux: All versions','so_linux.png'),
(2,'Solaris','Sun Solaris','so_solaris.png'),
(3,'AIX','IBM AIX','so_aix.png'),
(4,'BSD','OpenBSD, FreeBSD and Others','so_bsd.png'),
(5,'HP-UX','HP-UX Unix OS','so_hpux.png'),
(7,'Cisco','CISCO IOS','so_cisco.png'),
(8,'MacOS','MAC OS','so_mac.png'),
(9,'Windows','Microsoft Windows OS','so_win.png'),
(10,'Other','Other SO','so_other.png'),
(11,'Network','Network Agent','network.png'),
(12,'Web Server','Web Server/Application','network.png'),
(13,'Sensor','Hardware Agent (Sensor)','network.png'),
(14,'Embedded','Embedded device running an agent','embedded.png'),
(15,'Android','Android agent','android.png'),
(16, 'VMware', 'VMware Architecture', 'so_vmware.png'),
(17, 'Router', 'Generic router', 'so_router.png'),
(18, 'Switch', 'Generic switch', 'so_switch.png'),
(19, 'Satellite', 'Satellite agent', 'satellite.png'),
(20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png'),
(100, 'Cluster', 'Cluster agent', 'so_cluster.png');
INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`, `previous_name`) VALUES
(1,'Linux','Linux: All versions','so_linux.png', ''),
(2,'Solaris','Sun Solaris','so_solaris.png', ''),
(3,'AIX','IBM AIX','so_aix.png', ''),
(4,'BSD','OpenBSD, FreeBSD and Others','so_bsd.png', ''),
(5,'HP-UX','HP-UX Unix OS','so_hpux.png', ''),
(7,'Cisco','CISCO IOS','so_cisco.png', ''),
(8,'MacOS','MAC OS','so_mac.png', ''),
(9,'Windows','Microsoft Windows OS','so_win.png', ''),
(10,'Other','Other SO','so_other.png', ''),
(11,'Network','Network Agent','network.png', ''),
(12,'Web Server','Web Server/Application','network.png', ''),
(13,'Sensor','Hardware Agent (Sensor)','network.png', ''),
(14,'Embedded','Embedded device running an agent','embedded.png', ''),
(15,'Android','Android agent','android.png', ''),
(16, 'VMware', 'VMware Architecture', 'so_vmware.png', ''),
(17, 'Router', 'Generic router', 'so_router.png', ''),
(18, 'Switch', 'Generic switch', 'so_switch.png', ''),
(19, 'Satellite', 'Satellite agent', 'satellite.png', ''),
(20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png', ''),
(100, 'Cluster', 'Cluster agent', 'so_cluster.png', '');
UNLOCK TABLES;
@ -1187,7 +1187,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,''),(2,'Department',0,0,''),(3,'Additional ID',0,0,''),(4,'eHorusID',0,0,'');
INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','',''),(2,'critical','Critical modules','','',''),(3,'dmz','DMZ Network Zone','','',''),(4,'performance','Performance anda capacity modules','','',''),(5,'configuration','','','','');
INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','','',''),(2,'critical','Critical modules','','','',''),(3,'dmz','DMZ Network Zone','','','',''),(4,'performance','Performance anda capacity modules','','','',''),(5,'configuration','','','','','');
INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0,90),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0,90),(5,'Restart agent','Restart the agent with using UDP protocol.

To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0,90),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0,90);