diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f8b810d817..aa4a2d744c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.774-231213 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index fe934f5bb2..5230283cd9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231213" +pandora_version="7.0NG.774-231214" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 263b12b006..eea0bef2e7 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1039,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.774'; -use constant AGENT_BUILD => '231213'; +use constant AGENT_BUILD => '231214'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index c8b79b5432..77dd456483 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec index e15c66a2b0..d6170ca2e8 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec index c8b9c5bab9..81de81c240 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index 54311de34a..7e3809eec3 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index bfeb6b46be..6babe4a929 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index ccd8e1bbe9..6635b0c2e4 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.774" -PI_BUILD="231213" +PI_BUILD="231214" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index af055f92d2..2849d5842a 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{231213} +{231214} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 0c717e94de..d5c47e9441 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.774 Build 231213") +#define PANDORA_VERSION ("7.0NG.774 Build 231214") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index d0c4b12420..a7398b0f13 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.774(Build 231213))" + VALUE "ProductVersion", "(7.0NG.774(Build 231214))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 3db8b82868..03471ff471 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.774-231213 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index ed5bacf153..92a964b48a 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231213" +pandora_version="7.0NG.774-231214" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index c3210dc3e8..701f1af785 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -1,7 +1,1062 @@ START TRANSACTION; +ALTER TABLE `tncm_queue` +ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; + +ALTER TABLE `tncm_queue` +ADD COLUMN `snippet` TEXT NULL AFTER `scheduled`; + +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `id_agent_data_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; + +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( + `id` SERIAL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; + +ALTER TABLE `tncm_agent` +ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; + +ALTER TABLE `treport_content` +ADD COLUMN `ncm_agents` MEDIUMTEXT NULL AFTER `status_of_check`; + +-- Add needed snippet script to queue tasks. +SET @type_snippet = 6; +SELECT @id_snippet := `id` FROM `tncm_script` WHERE `type` = @type_snippet; +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_snippet, @type_snippet, 'snippet'); + +-- Add new vendor and model +SET @vendor_name = 'Cisco'; +SET @model_name = 'Cisco-Generic'; +SET @template_name = 'Cisco-Generic'; +SET @agent_data_template_name = 'Cisco-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'; +SET @script_set_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'; +SET @script_set_firmware = 'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? firmware.bin\n show flash\n reload\n expect:confirm y\n config terminal\n boot system firmware.bin\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Juniper'; +SET @model_name = 'Juniper-Generic'; +SET @template_name = 'Juniper-Generic'; +SET @agent_data_template_name = 'Juniper-Generic'; +SET @script_test = 'expect:root@% cli\n exit\n'; +SET @script_get_config = 'expect:root@% cli\n expect:root> capture:show configuration | no-more\n capture:\n quit\n expect:root@% exit\n'; +SET @script_set_config = 'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'; +SET @script_get_firmware = 'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'; +SET @script_set_firmware = 'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Palo Alto'; +SET @model_name = 'Palo Alto-Generic'; +SET @template_name = 'Palo Alto-Generic'; +SET @agent_data_template_name = 'Palo Alto-Generic'; +SET @script_test = 'sleep:1 exit\n'; +SET @script_get_config = 'set cli pager off \n capture:show config running\n exit\n'; +SET @script_set_config = 'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'; +SET @script_get_firmware = 'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'; +SET @script_set_firmware = 'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'A10'; +SET @model_name = 'A10-Generic'; +SET @template_name = 'A10-Generic'; +SET @agent_data_template_name = 'A10-Generic'; +SET @script_test = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n'; +SET @script_get_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Alcatel-Lucent Enterprise'; +SET @model_name = 'Alcatel-Generic'; +SET @template_name = 'Alcatel-Generic'; +SET @agent_data_template_name = 'Alcatel-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'; +SET @script_set_config = ''; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'; +SET @script_set_firmware = ''; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Aruba'; +SET @model_name = 'Aruba-Generic'; +SET @template_name = 'Aruba-Generic'; +SET @agent_data_template_name = 'Aruba-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'copy tftp flash _TFTP_SERVER_IP_ firmware.bin.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ firmware.bin primary\n boot system flash primary\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Mikrotik'; +SET @model_name = 'Mikrotik-Generic'; +SET @template_name = 'Mikrotik-Generic'; +SET @agent_data_template_name = 'Mikrotik-Generic'; +SET @script_test = 'sleep:1 exit\n\r'; +SET @script_get_config = 'sleep:1 capture:system resource print\n\r exit\n\r'; +SET @script_set_config = 'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'; +SET @script_get_firmware = 'sleep:1 capture:/system package print\n\r exit\n\r'; +SET @script_set_firmware = 'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + ALTER TABLE `tevento` ADD COLUMN `event_custom_id` TEXT NULL AFTER `module_status`; +-- Telegram and vonage default alerts +UPDATE talert_actions + SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' + WHERE id=9; +UPDATE talert_actions + SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' + WHERE id=11; SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmetaconsole_agent' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmetaconsole_agent` DROP COLUMN `transactional_agent`', 'SELECT ""'); diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 26bae75929..51893ca8a6 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1237,11 +1237,24 @@ if ($new_agent === false) { $actionButtons .= html_print_input_hidden('id_agente', $id_agente); if (is_management_allowed() === true) { + $clusters = agents_get_agent_belongs_cluster($id_agente); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); + } + $actionButtons .= html_print_button( __('Delete agent'), 'deleteAgent', false, - 'deleteAgentDialog('.$id_agente.')', + 'deleteAgentDialog('.$id_agente.', "'.$cluster_belongs.'")', [ 'icon' => 'delete', 'mode' => 'secondary dialog_opener', @@ -1289,10 +1302,18 @@ ui_require_jquery_file('bgiframe'); } } - function deleteAgentDialog($idAgente) { + function deleteAgentDialog($idAgente, cluster) { + var msg_cluster = ''; + if(cluster) { + msg_cluster = ""; + msg_cluster += ': '; + msg_cluster += cluster; + msg_cluster += '. '; + } + confirmDialog({ title: "", - message: "", + message: msg_cluster + "", onAccept: function() { window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente); } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index b4abfa1ad7..cad6faad62 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2258,6 +2258,28 @@ if ($update_module || $create_module || ($module_in_policy && !$module_linked) ) { if ($success_action > 0) { + if (empty($old_configuration_data) === true + && empty($configuration_data) === true && $disabled === '0' + && ($enable_module || $disable_module) + ) { + $modulo_nombre = io_safe_output( + db_get_value( + 'nombre', + 'tagente_modulo', + 'id_agente_modulo', + (empty($disable_module) === false) ? $disable_module : $enable_module + ) + ); + + $old_configuration_data = config_agents_get_module_from_conf( + $id_agente, + $modulo_nombre + ); + $configuration_data = $old_configuration_data; + + $disabled = (empty($disable_module) === false) ? true : false; + } + enterprise_hook( 'config_agents_write_module_in_conf', [ @@ -2406,7 +2428,6 @@ if ($disable_module) { $modulo_nombre = io_safe_output($modulo_nombre['nombre']); if ($result === NOERR) { - enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]); db_pandora_audit( AUDIT_LOG_MODULE_MANAGEMENT, 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias'] diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 5ea31914c6..a7ee6bf4c0 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -958,12 +958,33 @@ if ($agents !== false) { ); if ($check_aw === true && is_management_allowed() === true) { - if ($agent['id_os'] != CLUSTER_OS_ID) { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;'; - } else { - $onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;'; + $clusters = agents_get_agent_belongs_cluster($agent['id_agente']); + $cluster_belongs = ''; + if (empty($clusters) === false) { + $clusters = array_reduce( + $clusters, + function ($carry, $item) { + $carry[] = $item['name']; + return $carry; + } + ); + $cluster_belongs = implode(', ', $clusters); } + $msg = ''; + if ($agent['id_os'] == CLUSTER_OS_ID) { + $msg .= __('You are going to delete a cluster agent'); + $msg .= '. '; + } else if (empty($cluster_belongs) === false) { + $msg .= __('This agent belongs to the clusters'); + $msg .= ': '; + $msg .= $cluster_belongs; + $msg .= '. '; + } + + $msg .= __('Are you sure?'); + $onClickActionDeleteAgent = 'if (!confirm(\' '.$msg.'\')) return false;'; + $agentActionButtons[] = html_print_menu_button( [ 'href' => ui_get_full_url( diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 560de898e9..a8f7930b26 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -154,7 +154,7 @@ if ($is_management_allowed === true && $update_group === true) { $subcheck = db_get_value('name', 'tmodule_group', 'id_mg', $id_group); if ($name) { - if (!$check || $subcheck == $name) { + if ($check === false || strcasecmp($subcheck, $name) === 0) { $result = db_process_sql_update( 'tmodule_group', ['name' => $name], diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index ddc58ebc03..4eb6390fb2 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -117,6 +117,8 @@ $exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING; $exception_condition_value = 10; $modulegroup = 0; $period = SECONDS_1DAY; +$period_time_service_level = '28800'; +$show_agents = false; $search = ''; $full_text = 0; $log_number = 1000; @@ -898,6 +900,28 @@ switch ($action) { $idAgentModule = $module; break; + case 'service_level': + $description = $item['description']; + $es = json_decode($item['external_source'], true); + $period_time_service_level = $es['period_time_service_level']; + $show_agents = $es['show_agents']; + // Decode agents and modules. + $id_agents = json_decode( + io_safe_output(base64_decode($es['id_agents'])), + true + ); + $module = json_decode( + io_safe_output(base64_decode($es['module'])), + true + ); + + $recursion = $item['recursion']; + + $group = $item['id_group']; + $modulegroup = $item['id_module_group']; + $idAgentModule = $module; + break; + case 'end_of_life': $es = json_decode($item['external_source'], true); @@ -1054,7 +1078,13 @@ switch ($action) { break; case 'ncm': - $idAgent = $item['id_agent']; + $id_agent_ncm = json_decode($item['ncm_agents']); + $ncm_group = $item['id_group']; + break; + + case 'ncm_backups': + $id_agent_ncm = json_decode($item['ncm_agents']); + $ncm_group = $item['id_group']; break; case 'top_n_agents_sh': @@ -1162,6 +1192,7 @@ switch ($action) { case 'sumatory': case 'database_serialized': case 'last_value': + case 'service_level': case 'monitor_report': case 'min_value': case 'max_value': @@ -1672,6 +1703,53 @@ if (is_metaconsole() === true) { + + + + + + __('1 week'), + '172800' => __('48 hours'), + '86400' => __('24 hours'), + '43200' => __('12 hours'), + '28800' => __('8 hours'), + + ]; + html_print_select( + $fields_time_service_level, + 'period_time_service_level', + $period_time_service_level, + ); + ?> + + + + + + + + + + + + + + + + '; + $url = ui_get_full_url('ajax.php'); + html_print_input_hidden('url_ajax', $url, false, false, false, 'url_ajax'); + if (check_acl($config['id_user'], 0, 'RW')) { + html_print_select_groups( + $config['id_user'], + 'RW', + true, + 'ncm_group', + $ncm_group, + 'filterNcmAgentChange()', + ); + } else if (check_acl($config['id_user'], 0, 'RM')) { + html_print_select_groups( + $config['id_user'], + 'RM', + true, + 'ncm_group', + $ncm_group, + 'filterNcmAgentChange()', + ); + } + + echo ''; + ?> + + + + + + '; + $all_agents = agents_get_agents_selected($ncm_group); + html_print_select( + $all_agents, + 'agent_ncm[]', + $id_agent_ncm, + '', + __('Any'), + 0, + false, + true, + true, + '', + false, + 'width: 100%;', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, + ); + echo ''; + ?> + + @@ -2279,7 +2422,7 @@ if (is_metaconsole() === true) { $modulegroup, $id_agents, !$selection_a_m, - false + true ); } @@ -5999,8 +6142,13 @@ $(document).ready (function () { switch (type){ case 'agent_module': case 'agent_module_status': + case 'service_level': case 'alert_report_actions': var agents_multiple = $('#id_agents2').val(); + if (agents_multiple.length == 0) { + dialog_message('#message_no_agent'); + return false; + } var modules_multiple = $('#module').val(); $('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple)); $('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple)); @@ -6026,6 +6174,7 @@ $(document).ready (function () { case 'agent_configuration': case 'module_histogram_graph': case 'increment': + case 'service_level': if ($("#hidden-id_agent").val() == 0) { dialog_message('#message_no_agent'); return false; @@ -6186,8 +6335,13 @@ $(document).ready (function () { switch (type){ case 'agent_module': case 'agent_module_status': + case 'service_level': case 'alert_report_actions': var agents_multiple = $('#id_agents2').val(); + if (agents_multiple.length == 0) { + dialog_message('#message_no_agent'); + return false; + } var modules_multiple = $('#module').val(); $('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple)); $('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple)); @@ -6213,6 +6367,7 @@ $(document).ready (function () { case 'agent_configuration': case 'module_histogram_graph': case 'increment': + case 'service_level': if ($("#hidden-id_agent").val() == 0) { dialog_message('#message_no_agent'); return false; @@ -7208,6 +7363,9 @@ function chooseType() { $("#row_agent").hide(); $("#row_module").hide(); $("#row_search").hide(); + $("#row_period").hide(); + $("#row_period_service_level").hide(); + $("#row_show_agents").hide(); $("#row_log_number").hide(); $("#row_period1").hide(); $("#row_period2").hide(); @@ -7362,6 +7520,10 @@ function chooseType() { $('#agent_autocomplete_events').show(); + // NCM fields. + $("#row_ncm_group").hide(); + $("#row_ncm_agent").hide(); + switch (type) { case 'event_report_group': $("#row_description").show(); @@ -7922,6 +8084,22 @@ function chooseType() { } $("#row_historical_db_check").hide(); break; + + case 'service_level': + $("#row_period_service_level").show(); + $("#row_show_agents").show(); + $("#row_description").show(); + $("#row_group").show(); + $("#select_agent_modules").show(); + $("#agents_modules_row").show(); + $("#modules_row").show(); + $("#row_historical_db_check").hide(); + loadGeneralAgents(); + $("#combo_group").change(function() { + loadGeneralAgents($(this).val()); + }); + $("#row_module_group").show(); + break; case 'agent_module': $("#row_module_group").show(); @@ -8220,7 +8398,13 @@ function chooseType() { break; case 'ncm': - $("#row_agent").show(); + $("#row_ncm_group").show(); + $("#row_ncm_agent").show(); + break; + + case 'ncm_backups': + $("#row_ncm_group").show(); + $("#row_ncm_agent").show(); break; case 'top_n_agents_sh': @@ -8603,4 +8787,43 @@ $(document).ready(function () { }); }); +// Ncm agent filter by group. +function filterNcmAgentChange() { + var idGroup = $("#ncm_group").val(); + const url_ajax = $("#url_ajax").val(); + + $.ajax({ + url: url_ajax, + type: "POST", + dataType: "json", + async: false, + data: { + page: "operation/agentes/ver_agente", + get_ncm_agents: 1, + id_group: idGroup, + privilege: "AW", + keys_prefix: "_" + }, + success: function(data) { + $("#agent_ncm").empty(); + var optionAny = $("") + .attr("value",0) + .html("Any"); + // Add any option. + $("#agent_ncm").append(optionAny); + + data.map(item => { + var option = $("") + .attr("value", item.id_agent) + .html(item.alias); + // Add agents options. + $("#agent_ncm").append(option); + }); + }, + error: function(err) { + console.error(err); + } + }); +} + diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index e507d1fceb..842e05147d 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1730,10 +1730,20 @@ switch ($action) { $good_format = true; break; + case 'service_level': + $es['period_time_service_level'] = get_parameter('period_time_service_level', '28800'); + $es['show_agents'] = get_parameter('show_agents', false); case 'agent_module': case 'agent_module_status': $agents_to_report_text = get_parameter('id_agents2-multiple-text', ''); + if ($agents_to_report_text === '' || $agents_to_report_text === 'null') { + $agents_to_report_text = io_safe_input(json_encode(get_parameter('id_agents2', ''))); + } + $modules_to_report_text = get_parameter('module-multiple-text', ''); + if ($modules_to_report_text === '' || $modules_to_report_text === 'null') { + $modules_to_report_text = io_safe_input(json_encode(get_parameter('module', ''))); + } // Decode json check modules. $agents_to_report = json_decode( @@ -1745,11 +1755,16 @@ switch ($action) { true ); + $es['module'] = get_same_modules_all( $agents_to_report, $modules_to_report ); + if ((bool) is_metaconsole() === true) { + $es['module'] = $modules_to_report; + } + // Encode json modules and agents. $es['module'] = base64_encode(json_encode($es['module'])); $es['id_agents'] = base64_encode(json_encode($agents_to_report)); @@ -2046,6 +2061,20 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + + case 'ncm': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + case 'vuls_severity_graph': $values['id_group'] = get_parameter('combo_group'); $good_format = true; @@ -2116,7 +2145,10 @@ switch ($action) { break; } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); $values['id_agent_module'] = ''; @@ -2232,7 +2264,10 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ($values['server_name'] == '') { $values['server_name'] = get_parameter( @@ -2789,10 +2824,20 @@ switch ($action) { $good_format = true; break; + case 'service_level': + $es['period_time_service_level'] = get_parameter('period_time_service_level', '28800'); + $es['show_agents'] = get_parameter('show_agents', false); case 'agent_module': case 'agent_module_status': - $agents_to_report_text = get_parameter('id_agents2-multiple-text'); + $agents_to_report_text = get_parameter('id_agents2-multiple-text', ''); + if ($agents_to_report_text === '' || $agents_to_report_text === 'null') { + $agents_to_report_text = io_safe_input(json_encode(get_parameter('id_agents2', ''))); + } + $modules_to_report_text = get_parameter('module-multiple-text', ''); + if ($modules_to_report_text === '' || $modules_to_report_text === 'null') { + $modules_to_report_text = io_safe_input(json_encode(get_parameter('module', ''))); + } // Decode json check modules. $agents_to_report = json_decode( @@ -2809,11 +2854,14 @@ switch ($action) { $modules_to_report ); + if ((bool) is_metaconsole() === true) { + $es['module'] = $modules_to_report; + } + // Encode json modules and agents. $es['module'] = base64_encode(json_encode($es['module'])); $es['id_agents'] = base64_encode(json_encode($agents_to_report)); $es['show_type'] = get_parameter('show_type', 0); - $values['external_source'] = json_encode($es); $good_format = true; break; @@ -3038,6 +3086,21 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + + case 'ncm': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + case 'vuls_severity_graph': $values['id_group'] = get_parameter('combo_group'); $good_format = true; @@ -3114,7 +3177,10 @@ switch ($action) { ); } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); if (($values['type'] == 'alert_report_agent') || ($values['type'] == 'event_report_agent') @@ -3228,7 +3294,9 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ((($values['type'] == 'custom_graph') diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 0da72eacb0..c1057af585 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -896,6 +896,35 @@ echo ''.__('Mail configuration').''; echo ''; + echo '
'; + echo ''.__('NCM Configuration').''; + + $table_ncm_config = new stdClass(); + $table_ncm_config->width = '100%'; + $table_ncm_config->class = 'databox filter-table-adv'; + $table_ncm_config->size = []; + $table_ncm_config->size[0] = '50%'; + $table_ncm_config->data = []; + + $table_ncm_config->data[0][] = html_print_label_input_block( + __('FTP server IP').ui_print_help_tip(__('This value will be used by TFTP_SERVER_IP macro in NCM scripts.'), true), + html_print_input_text( + 'tftp_server_ip', + $config['tftp_server_ip'], + '', + false, + 255, + true, + false, + false, + '', + 'w50p' + ) + ); + + html_print_table($table_ncm_config); + + echo '
'; html_print_action_buttons( html_print_submit_button( diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e831022c23..d088e8c84f 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -1422,6 +1422,14 @@ class DiscoveryTaskList extends HTML $table->rowid = []; $table->data = []; + $countErrors = 1; + $tableErrors = new StdClasS(); + $tableErrors->class = 'databox data'; + $tableErrors->width = '75%'; + $tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;'; + $tableErrors->rowid = []; + $tableErrors->data = []; + if ($task['review_mode'] == DISCOVERY_RESULTS) { $agents_review = db_get_all_rows_filter( 'tdiscovery_tmp_agents', @@ -1476,11 +1484,11 @@ class DiscoveryTaskList extends HTML $countSummary = 1; if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) { foreach ($task['stats'] as $key => $summary) { - $table->data[$i][0] = ''.__('Summary').' '.$countSummary.''; - $table->data[$i][1] = ''; - $countSummary++; - $i++; if (is_array($summary) === true) { + $table->data[$i][0] = ''.__('Summary').' '.$countSummary.''; + $table->data[$i][1] = ''; + $countSummary++; + $i++; if (empty($summary['summary']) === true && empty($summary['info']) === true) { $table->data[$i][0] = json_encode($summary, JSON_PRETTY_PRINT); $table->data[$i][1] = ''; @@ -1517,8 +1525,12 @@ class DiscoveryTaskList extends HTML $i++; } } else { - $table->data[$i][0] = $summary; - $table->data[$i][1] = ''; + $tableErrors->data[$i][0] = ''.__('Error %s', $countErrors).''; + $tableErrors->data[$i][1] = ''; + $i++; + $tableErrors->data[$i][0] = $summary; + $tableErrors->data[$i][1] = ''; + $countErrors++; $i++; } } @@ -1560,12 +1572,26 @@ class DiscoveryTaskList extends HTML $table->data[$i++][1] .= ''; } } else { - $table->data[$i][0] = $task['stats']['summary']; + $tableErrors->data[$i][0] = ''.__('Error %s', $countErrors).''; + $tableErrors->data[$i][1] = ''; + $i++; + $tableErrors->data[$i][0] = $task['stats']['summary']; + $tableErrors->data[$i][1] = ''; + $countErrors++; + $i++; } } $output = '
'.__('Summary').'
'; - $output .= html_print_table($table, true).''; + if (is_array($table->data) === true && count($table->data) > 0) { + $output .= html_print_table($table, true); + } + + if (is_array($tableErrors->data) === true && count($tableErrors->data) > 0) { + $output .= html_print_table($tableErrors, true); + } + + $output .= ''; } return $output; diff --git a/pandora_console/images/donut.svg b/pandora_console/images/donut.svg new file mode 100644 index 0000000000..67c8733d33 --- /dev/null +++ b/pandora_console/images/donut.svg @@ -0,0 +1,7 @@ + + + donut + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php index 59469a16e3..5f83d79b88 100755 --- a/pandora_console/include/ajax/reporting.ajax.php +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -251,7 +251,7 @@ if ($change_custom_fields_macros_report === true) { } if ($get_agents === true) { - $agents_id = str_replace('"', '', $agents_id); + $agents_id = str_replace('"', '"', $agents_id); try { $agents_id = json_decode($agents_id, true); diff --git a/pandora_console/include/class/Heatmap.class.php b/pandora_console/include/class/Heatmap.class.php index 05d6152030..3ed4b3cc72 100644 --- a/pandora_console/include/class/Heatmap.class.php +++ b/pandora_console/include/class/Heatmap.class.php @@ -549,8 +549,12 @@ class Heatmap global $config; $filter_group = ''; - if (empty($this->filter) === false && current($this->filter) != -1) { + if (empty($this->filter) === false && current($this->filter) != -1 + && implode(',', $this->filter) !== '' + ) { $filter_group = 'AND am.id_module_group IN ('.implode(',', $this->filter).')'; + } else { + return false; } $filter_name = ''; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index a06a174ade..9ad1aa52da 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC231213'; +$build_version = 'PC231214'; $pandora_version = 'v7.0NG.774'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2d6803ccd4..7dc206711d 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3643,7 +3643,7 @@ function select_modules_for_agent_group( if (!$selection && $agents != null) { $number_agents = count($id_agents); - $selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents"; + $selection_filter = "GROUP BY nombre HAVING COUNT(id_agente_modulo) = $number_agents"; } if (tags_has_user_acl_tags(false)) { @@ -3664,7 +3664,7 @@ function select_modules_for_agent_group( $sql = "SELECT * FROM ( - SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre + SELECT (tagente_modulo.id_agente_modulo), tagente_modulo.nombre, tagente.alias FROM tagente_modulo $sql_tags_inner INNER JOIN tagente @@ -3679,7 +3679,7 @@ function select_modules_for_agent_group( $filter_not_string_modules $sql_conditions_tags ) x - GROUP BY nombre + $selection_filter"; $modules = db_get_all_rows_sql($sql); @@ -4976,13 +4976,38 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) } +/** + * agent belongs to the clusters. + * + * @param integer $idAgent + * + * @return array Names clusters. + */ +function agents_get_agent_belongs_cluster(int $idAgent): array +{ + $sql = sprintf( + 'SELECT tcluster.name + FROM tcluster + INNER JOIN tcluster_agent + ON tcluster.id = tcluster_agent.id_cluster + WHERE tcluster_agent.id_agent = %d', + $idAgent + ); + + $result = db_get_all_rows_sql($sql); + if ($result === false) { + $result = []; + } + + return $result; +} + + /** * Return an array with a list of status agents * * @return array. */ - - function agents_status_list() { $status_list = []; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index e47e84adeb..0f55153922 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -431,6 +431,10 @@ function config_update_config() if (config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist), true) === false) { $error_update[] = __('Inventory changes blacklist'); } + + if (config_update_value('tftp_server_ip', (string) get_parameter('tftp_server_ip'), true) === false) { + $error_update[] = __('Ftp server ip'); + } break; case 'enterprise': diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 747e5154ce..f34a8f6239 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -5039,7 +5039,11 @@ function events_page_general($event) $data[1] = $user_owner; } - $table_general->cellclass[3][1] = 'general_owner'; + if (is_metaconsole() === true && $event['server_name'] !== '') { + $table_general->cellclass[4][1] = 'general_owner'; + } else { + $table_general->cellclass[3][1] = 'general_owner'; + } $table_general->data[] = $data; @@ -5099,38 +5103,21 @@ function events_page_general($event) $table_general->cellclass[count($table_general->data)][1] = 'general_acknowleded'; $data = []; + + if (empty($event['server_id']) === false && (int) $event['server_id'] > 0 + && is_metaconsole() === true + ) { + $node_connect = new Node($event['server_id']); + $node_connect->connect(); + } + $data[0] = __('Acknowledged by'); + $data[1] = events_page_general_acknowledged($event['id_evento']); - if ($event['estado'] == 1 || $event['estado'] == 2) { - if (empty($event['id_usuario']) === true) { - $user_ack = __('Autovalidated'); - } else { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $event['id_usuario'] - ); - - if (empty($user_ack) === true) { - $user_ack = $event['id_usuario']; - } - } - - $data[1] = $user_ack.' ( '; - if ($event['ack_utimestamp_raw'] !== false - && $event['ack_utimestamp_raw'] !== 'false' - && empty($event['ack_utimestamp_raw']) === false - ) { - $data[1] .= date( - $config['date_format'], - $event['ack_utimestamp_raw'] - ); - } - - $data[1] .= ' ) '; - } else { - $data[1] = ''.__('N/A').''; + if (empty($event['server_id']) === false && (int) $event['server_id'] > 0 + && is_metaconsole() === true + ) { + $node_connect->disconnect(); } $table_general->cellclass[7][1] = 'general_status'; @@ -5237,15 +5224,19 @@ function events_page_general_acknowledged($event_id) $Acknowledged = ''; $event = db_get_row('tevento', 'id_evento', $event_id); if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $config['id_user'] - ); + if (empty($event['id_usuario']) === true) { + $user_ack = __('Autovalidated'); + } else { + $user_ack = db_get_value( + 'fullname', + 'tusuario', + 'id_user', + $config['id_user'] + ); - if (empty($user_ack) === true) { - $user_ack = $config['id_user']; + if (empty($user_ack) === true) { + $user_ack = $config['id_user']; + } } $Acknowledged = $user_ack.' ( '; @@ -5260,7 +5251,7 @@ function events_page_general_acknowledged($event_id) $Acknowledged .= ' ) '; } else { - $Acknowledged = 'N/A'; + $Acknowledged = ''.__('N/A').''; } return $Acknowledged; @@ -5846,7 +5837,7 @@ function events_get_field_value_by_event_id( } -function events_get_instructions($event) +function events_get_instructions($event, $max_text_length=300) { if (is_array($event) === false) { return ''; @@ -5894,17 +5885,17 @@ function events_get_instructions($event) return ''; } - $max_text_length = 300; $over_text = io_safe_output($value); if (strlen($over_text) > ($max_text_length + 3)) { $over_text = substr($over_text, 0, $max_text_length).'...'; + } else { + return $value; } $output = '
'; $output .= ''; $output .= ''; @@ -5913,7 +5904,6 @@ function events_get_instructions($event) true, ['title' => $over_text] ).''; - $output .= ''; return $output; } @@ -6472,7 +6462,12 @@ function event_print_graph( $color[] = '#82b92f'; } } else { - $interval_length = (int) ($period / $num_intervals); + if ($num_intervals > 0) { + $interval_length = (int) ($period / $num_intervals); + } else { + $interval_length = 0; + } + $intervals = []; $intervals[0] = $start_utimestamp; for ($i = 0; $i < $num_intervals; $i++) { diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 6283fdbaed..6264a75138 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -581,6 +581,9 @@ function io_output_password($password, $wrappedBy='') $output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; + // If password already decrypt return same password. + $output = (empty($plaintext) === true) ? $password : $plaintext; + return sprintf( '%s%s%s', $wrappedBy, diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 6ec74b33de..b5cf42d894 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3801,7 +3801,7 @@ function get_modules_agents( $return = array_reduce( $modules[$tserver], - function ($carry, $item) use ($tserver, $nodes) { + function ($carry, $item) use ($tserver, $nodes, $selection) { $t = []; foreach ($item as $k => $v) { $t[$k] = $v; @@ -3809,9 +3809,15 @@ function get_modules_agents( $t['id_node'] = $tserver; if ($nodes[$tserver] !== null) { - $t['nombre'] = io_safe_output( - $nodes[$tserver]->server_name().' » '.$t['nombre'] - ); + if (isset($t['alias']) === true && (bool) $selection === true) { + $t['nombre'] = io_safe_output( + $nodes[$tserver]->server_name().' » '.$t['alias'].' » '.$t['nombre'] + ); + } else { + $t['nombre'] = io_safe_output( + $nodes[$tserver]->server_name().' » '.$t['nombre'] + ); + } } $carry[] = $t; @@ -3845,9 +3851,23 @@ function get_modules_agents( $selection, false, $useName, - false, + true, $notStringModules ); + + $modules = array_reduce( + $modules, + function ($carry, $item) use ($id_agents, $selection) { + if (count($id_agents) > 1 && (bool) $selection === true) { + $carry[$item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre']; + } else { + $carry[$item['id_agente_modulo']] = $item['nombre']; + } + + return $carry; + }, + [] + ); } return $modules; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index f473961ab6..c8a794cc1d 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -804,6 +804,13 @@ function reporting_make_reporting_data( ); break; + case 'service_level': + $report['contents'][] = reporting_service_level_detail( + $report, + $content + ); + break; + case 'end_of_life': $report['contents'][] = reporting_end_of_life( $report, @@ -966,7 +973,15 @@ function reporting_make_reporting_data( break; case 'ncm': - $report['contents'][] = reporting_ncm_config( + $report['contents'][] = reporting_ncm_list( + $report, + $content, + $pdf + ); + break; + + case 'ncm_backups': + $report['contents'][] = reporting_ncm_backups( $report, $content, $pdf @@ -3707,6 +3722,60 @@ function reporting_agent_module_status($report, $content) } +/** + * Service level detail + * + * @param array $report Info Report. + * @param array $content Info content. + * + * @return array + */ +function reporting_service_level_detail($report, $content) +{ + global $config; + $return['type'] = 'service_level'; + + $module_data = []; + $interval_range = []; + $service_level_data = []; + $current_timestamp = time(); + + $return['title'] = io_safe_output($content['name']); + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + + $return['description'] = io_safe_output($content['description']); + $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + $es = json_decode($content['external_source'], true); + $return['date'] = []; + $return['date']['date'] = false; + $return['date']['period'] = $es['period_time_service_level']; + $return['show_agents'] = $es['show_agents']; + + $modules = json_decode(base64_decode($es['module']), true); + $agents = json_decode(base64_decode($es['id_agents']), true); + $interval_range['start'] = ($current_timestamp - $es['period_time_service_level']); + $interval_range['end'] = $current_timestamp; + + foreach ($modules as $module) { + $service_level_data = service_level_module_data($interval_range['start'], $interval_range['end'], $module); + $module_data[$module] = []; + $module_data[$module]['mtrs'] = ($service_level_data['mtrs'] !== false) ? human_milliseconds_to_string(($service_level_data['mtrs'] * 100), 'short') : '-'; + $module_data[$module]['mtbf'] = ($service_level_data['mtbf'] !== false) ? human_milliseconds_to_string(($service_level_data['mtbf'] * 100), 'short') : '-'; + $module_data[$module]['availability'] = ($service_level_data['availability'] !== false) ? $service_level_data['availability'] : '100'; + $module_data[$module]['warning_events'] = ($service_level_data['warning_events'] !== false) ? $service_level_data['warning_events'] : '0'; + $module_data[$module]['critical_events'] = ($service_level_data['critical_events'] !== false) ? $service_level_data['critical_events'] : '0'; + $module_data[$module]['last_status_change'] = ($service_level_data['last_status_change'] !== false) ? $service_level_data['last_status_change'] : ''; + $module_data[$module]['module_name'] = ($service_level_data['module_name'] !== false) ? $service_level_data['module_name'] : ''; + $module_data[$module]['agent_alias'] = ($service_level_data['agent_alias'] !== false) ? $service_level_data['agent_alias'] : ''; + } + + $return['data'] = $module_data; + + return reporting_check_structure_content($return); +} + + /** * OS Version End of Life * diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 5dd77769ff..c52e920e92 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -260,7 +260,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust } $table->colspan['description_row']['description'] = 3; - switch ($item['type']) { case 'availability': default: @@ -403,6 +402,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust reporting_html_agent_module_status($table, $item); break; + case 'service_level': + reporting_html_service_level($table, $item); + break; + case 'end_of_life': reporting_html_end_of_life($table, $item); break; @@ -477,7 +480,11 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust break; case 'ncm': - reporting_html_ncm_config($table, $item); + reporting_html_ncm_list($table, $item); + break; + + case 'ncm_backups': + reporting_html_ncm_backups($table, $item); break; case 'top_n_agents_sh': @@ -3080,6 +3087,85 @@ function reporting_html_agent_module_status($table, $item, $pdf=0) } +function reporting_html_service_level($table, $item, $pdf=0) +{ + global $config; + + $return_pdf = ''; + + if (empty($item['data']) === true) { + if ($pdf !== 0) { + $return_pdf .= __('No items'); + } else { + $table->colspan['group_report']['cell'] = 3; + $table->cellstyle['group_report']['cell'] = 'text-align: center;'; + $table->data['group_report']['cell'] = __('No items'); + } + } else { + $table_info = new stdClass(); + $table_info->width = '99%'; + if ($item['show_agents'] === '1') { + $show_agents = 'on'; + } else { + $show_agents = 'off'; + } + + if ($show_agents === 'on') { + $table_info->head[0] = __('Agent / Module'); + } else { + $table_info->head[0] = __('Module'); + } + + $table_info->head[1] = __('% Av.'); + $table_info->head[2] = __('MTBF'); + $table_info->head[3] = __('MTRS'); + $table_info->head[4] = __('Crit. Events').ui_print_help_tip(__('Counted only critical events generated automatic by the module'), true); + $table_info->head[5] = __('Warn. Events').ui_print_help_tip(__('Counted only warning events generated automatic by the module'), true); + $table_info->head[6] = __('Last change'); + $table_info->data = []; + $table_info->cellstyle = []; + $row = 0; + + foreach ($item['data'] as $agentmodule_id => $module_data) { + if ($show_agents === 'on') { + $table_info->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name']; + $table_info->cellstyle[$row][0] = 'text-align:left; padding-left: 30px;'; + } else { + $table_info->data[$row][0] = $module_data['module_name']; + $table_info->cellstyle[$row][0] = 'text-align:left; padding-left: 30px;'; + } + + $table_info->data[$row][1] = $module_data['availability'].'%'; + $table_info->data[$row][2] = $module_data['mtbf']; + $table_info->data[$row][3] = $module_data['mtrs']; + $table_info->data[$row][4] = $module_data['critical_events']; + $table_info->data[$row][5] = $module_data['warning_events']; + if ($module_data['last_status_change'] !== '') { + $table_info->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']); + } + + // $table_info->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']); + $row++; + } + + if ($pdf !== 0) { + $table_info->title = $item['title']; + $table_info->titleclass = 'title_table_pdf'; + $table_info->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table($table_info, true); + } else { + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: center;'; + $table->data['data']['cell'] = html_print_table($table_info, true); + } + } + + if ($pdf !== 0) { + return $return_pdf; + } +} + + /** * Html report end of life. * @@ -7665,40 +7751,146 @@ function reporting_html_permissions($table, $item, $pdf=0) /** - * HTML content for ncm configuration diff report. + * HTML content for ncm devices list. * - * @param array $item Content generated by reporting_ncm_config. + * @param array $item Content generated by reporting_ncm_list. * * @return string HTML code. */ -function reporting_html_ncm_config($table, $item, $pdf=0) +function reporting_html_ncm_list($table, $item, $pdf=0) { - $key = uniqid(); + // Create table diff. + $table_ncm = new stdClass(); + $table_ncm->width = '100%'; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->titleclass = 'title_table_pdf'; + + $table_ncm->align = []; + $table_ncm->align['name'] = 'left'; + $table_ncm->align['ip'] = 'left'; + $table_ncm->align['vendor'] = 'left'; + $table_ncm->align['model'] = 'left'; + $table_ncm->align['firmware'] = 'left'; + $table_ncm->align['last_backup_date'] = 'left'; + + $table_ncm->headstyle['name'] = 'text-align: left'; + $table_ncm->headstyle['ip'] = 'text-align: left'; + $table_ncm->headstyle['vendor'] = 'text-align: left'; + $table_ncm->headstyle['model'] = 'text-align: left'; + $table_ncm->headstyle['firmware'] = 'text-align: left'; + $table_ncm->headstyle['last_backup_date'] = 'text-align: left'; + + $table_ncm->head = []; + $table_ncm->head['name'] = __('Name'); + $table_ncm->head['ip'] = __('Ip'); + $table_ncm->head['vendor'] = __('Vendor'); + $table_ncm->head['model'] = __('Model'); + $table_ncm->head['firmware'] = __('Firmware'); + $table_ncm->head['last_backup_date'] = __('Last backup date'); + + $table_ncm->data = []; + foreach ($item['data'] as $key => $row) { + $title = $row['last_error']; + if (empty($title) === true) { + $title = null; + } + + $table_ncm->data[] = [ + $row['alias'], + $row['direccion'], + $row['vendor'], + $row['model'], + $row['firmware'], + $row['last_backup_date'], + ]; + } + if ($pdf === 0) { - ui_require_javascript_file('diff2html-ui.min'); - ui_require_css_file('diff2html.min'); - $script = "$(document).ready(function() { - const configuration = { - drawFileList: false, - collapsed: true, - matching: 'lines', - outputFormat: 'side-by-side', - }; - const diff2htmlUi = new Diff2HtmlUI( - document.getElementById('".$key."'), - atob('".base64_encode($item['data'])."'), - configuration - ); - diff2htmlUi.draw(); - });"; - $content = '
'; - $content .= ''; - $table->data[1] = $content; - $table->colspan[1][0] = 2; + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: left;'; + $table->data['data']['cell'] = html_print_table( + $table_ncm, + true + ); } else { - $content = '
'; - $content .= str_replace("\n", '
', $item['data']); - $content .= '
'; - return $content; + $table_ncm->titleclass = 'title_table_pdf'; + $table_ncm->titlestyle = 'text-align:left;'; + + return html_print_table( + $table_ncm, + true + ); } } + + +/** + * HTML content for ncm backup report. + * + * @param array $item Content generated by reporting_ncm_backups. + * + * @return string HTML code. + */ +function reporting_html_ncm_backups($table, $item, $pdf=0) +{ + ui_require_css_file('diff2html.min'); + ui_require_css_file('highlight.min'); + ui_require_css_file('highlight/vs.min'); + ui_require_javascript_file('diff2html-ui.min'); + ui_require_javascript_file('highlight.min'); + ui_require_javascript_file('highlightjs-line-numbers.min'); + ui_require_javascript_file('languages/plaintext.min'); + ui_require_javascript_file('jquery', ENTERPRISE_DIR.'/include/javascript/'); + ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); + + // Create table diff. + foreach ($item['data'] as $ncm_agent_key => $ncm_agent) { + $table_ncm = new stdClass(); + if ($pdf === 1) { + $table_ncm->width = '100%'; + } + + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->headstyle[0] = 'width: 250px'; + $table_ncm->head = []; + $table_ncm->head[0] = __('Date'); + $table_ncm->head[1] = __('Diff'); + $table_ncm->id = 'ncm_backups'; + $table_ncm->name = 'ncm_backups'; + $table_ncm->title = $ncm_agent['caption']; + $row = []; + foreach ($ncm_agent['data'] as $ncm_agent_data) { + if ($pdf === 1) { + $row[] = [ + $ncm_agent_data['updated_at'], + ($ncm_agent_data['diffstr'] === '') ? $ncm_agent_data['diff'] : str_replace("\n", '
', $ncm_agent_data['diffstr']), + ]; + } else { + $row[] = [ + $ncm_agent_data['updated_at'], + $ncm_agent_data['diff'], + ]; + } + + $table_ncm->data = $row; + } + + $table->colspan[$ncm_agent_key]['cell'] = 3; + $table->cellstyle[$ncm_agent_key]['cell'] = 'text-align: left;'; + $table->data[$ncm_agent_key]['cell'] = html_print_table( + $table_ncm, + true + ); + } + + if ($pdf === 1) { + $table->width = '100%'; + return html_print_table( + $table, + true + ); + } + +} diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 9b77eed800..bb9f57f5c3 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -777,6 +777,10 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Modules'), 'name' => __('Last value'), ]; + $types['service_level'] = [ + 'optgroup' => __('Modules'), + 'name' => __('Service Level Detailed'), + ]; $types['general'] = [ 'optgroup' => __('Grouped'), @@ -963,9 +967,14 @@ function reports_get_report_types($template=false, $not_editor=false) ]; } + $types['ncm_backups'] = [ + 'optgroup' => __('NCM'), + 'name' => __('NCM configuration changes'), + ]; + $types['ncm'] = [ 'optgroup' => __('NCM'), - 'name' => __('Network configuration changes'), + 'name' => __('NCM devices list'), ]; if (enterprise_installed() === true) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 5c9a7e90fc..3ea3e8a740 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7170,31 +7170,16 @@ function ui_print_comments($comment, $truncate_limit=255) } // Only show the last comment. If commment its too long,the comment will short with ... - // If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes. + // Forced time commentary to use copact date for optimize space in table. // Else show comments hours ago if ($comment['action'] != 'Added comment') { $comment['comment'] = $comment['action']; } + $comment['comment'] = io_safe_output($comment['comment']); + $short_comment = substr($comment['comment'], 0, 20); - if ($config['prominent_time'] == 'timestamp') { - $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$comment['comment'].''; - - if (strlen($comentario) > '200px' && $truncate_limit >= 255) { - $comentario = ''.date($config['date_format'], $comment['utimestamp']).' ('.$comment['id_user'].'): '.$short_comment.'...'; - } - } else { - $rest_time = (time() - $comment['utimestamp']); - $time_last = (($rest_time / 60) / 60); - - $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$comment['id_user'].'): '.$comment['comment'].''; - - if (strlen($comentario) > '200px' && $truncate_limit >= 255) { - $comentario = ''.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'  Hours  ('.$comment['id_user'].'): '.$short_comment.'...'; - } - } - - $comentario = io_safe_output($comentario); + $comentario = $comment['comment']; if (strlen($comentario) >= $truncate_limit) { $comentario = ui_print_truncate_text( @@ -7209,6 +7194,12 @@ function ui_print_comments($comment, $truncate_limit=255) ); } + $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px; display: contents;', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$comment['comment'].''; + + if (strlen($comentario) > '200px' && $truncate_limit >= 255) { + $comentario = ''.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px; display: contents;', 'prominent' => 'compact']).' ('.$comment['id_user'].'): '.$short_comment.'...'; + } + return $comentario; } diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 65ea9f2a75..c7b296ebaa 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1549,14 +1549,41 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { title: "Minimize" }).insertBefore(closeButton); + // Add the minimize icon to the minimize button + $("", { + class: "ui-button-icon ui-icon", + style: + "background-color: rgb(51, 51, 51); -webkit-mask: url('images/arrow-down-white.png') no-repeat / contain !important;" + }).appendTo(minimizeButton); + + $("", { + class: "ui-button-icon-space" + }) + .html(" ") + .appendTo(minimizeButton); + // Add the disengage button before the minimize button var disengageButton = $("
'; return $output; + } else { + return ''; } } diff --git a/pandora_console/include/styles/custom_field.css b/pandora_console/include/styles/custom_field.css new file mode 100644 index 0000000000..fcb12d492f --- /dev/null +++ b/pandora_console/include/styles/custom_field.css @@ -0,0 +1,85 @@ +/** + * + * Name: Default theme + * Pandora Stylesheet + * + * @category Stylesheet + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +.dt-buttons { + float: left; +} + +.dt-button.buttons-csv.buttons-html5 { + box-shadow: none; +} + +.dataTables_filter > label { + color: #000; +} + +.top { + background-color: #fff !important; + color: #000 !important; + border-radius: 5px !important; + border: 1px solid #e5e9ed !important; +} + +.bottom { + background-color: #fff !important; + color: #000 !important; + border-radius: 5px !important; + border: 1px solid #e5e9ed !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.disabled, +.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover, +.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active { + color: #000 !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.current, +.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { + color: #fff !important; + background: #14524f !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button { + background-color: #f6f7fb !important; + color: #000 !important; + border: 1px solid #cacaca; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button:hover { + background: #e2e2e2 !important; + color: #000 !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.next { + border: 1px solid #cacaca !important; +} + +.dataTables_wrapper .dataTables_paginate .paginate_button.previous { + border: 1px solid #cacaca !important; +} diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 0a0373a608..aa78d32526 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -148,7 +148,7 @@ h1 { cursor: pointer; } #modal-add-widget { - min-height: 566px !important; + min-height: 625px !important; } #modal-add-widget .container-list-widgets { display: flex; diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 1a66ba7174..78286c79f9 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -108,6 +108,35 @@ td > input[id^="checkbox-multi"] { height: 2.5em; } +.info_table.events tr > td span:not(.invisible) { + display: block; + overflow: hidden; + text-overflow: ellipsis; + max-height: 6em; + line-height: 2em; +} + +.info_table.events tr > td span:not(.invisible) { + display: block; + overflow: hidden; + text-overflow: ellipsis; + max-height: 6em; + line-height: 1.5em; +} + +th.column-estado { + padding: 0px 0px 0px 12px !important; + max-width: fit-content; +} + +.content-status { + margin: 0 auto; + max-width: fit-content; +} +table#table_events > tbody > tr > td.column-estado { + padding: 0px !important; + text-align: center; +} .sorting_desc { background: url(../../images/sort_down_green.png) no-repeat; background-position-x: left; diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index 5802fc9155..3c9104cba6 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -48,8 +48,9 @@ .ui-dialog .ui-dialog-titlebar-minimize { position: relative; height: 20px; - width: 20px; - margin-right: 1px; + bottom: 30%; + top: 0px; + background-color: #fff !important; } .ui-dialog .ui-dialog-titlebar-minimize:hover { @@ -57,10 +58,15 @@ } .ui-dialog .ui-dialog-titlebar-disengage { - position: relative; - height: 20px; - width: 20px; - margin-right: 5px; + position: absolute !important; + right: 50px; + top: -3px; + width: 40px; + margin: 0px 0 0 0; + padding: 1px; + height: 40px; + bottom: 30%; + background-color: #fff !important; } .ui-dialog .ui-dialog-titlebar-disengage:hover { @@ -359,3 +365,9 @@ input[type="submit"].ui-button-dialog { .ui_tpicker_time { margin-left: 10px !important; } + +.ui-widget-overlay { + background: #aaa !important; + opacity: 0.3 !important; + z-index: 1114; +} diff --git a/pandora_console/include/styles/ncm.css b/pandora_console/include/styles/ncm.css index 332d891431..2ed71d3338 100644 --- a/pandora_console/include/styles/ncm.css +++ b/pandora_console/include/styles/ncm.css @@ -1,10 +1,3 @@ -span.select2.select2-container.select2-container--default { - max-width: 175px !important; - width: 175px !important; -} - -.edit_discovery_input b { - display: flex; - flex-direction: row; - align-items: center; +.select2-selection__rendered { + max-width: 600px; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 25757b43a2..560965e8e0 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12624,9 +12624,10 @@ form.cfv_status_agent input:checked + label:before { float: left; margin-left: 10px; padding-right: 10px; - max-height: 890px; + max-height: 760px; overflow: auto; background-color: #f9f9f9; + margin-bottom: 20px; } .agents_custom_fields { @@ -12635,15 +12636,6 @@ form.cfv_status_agent input:checked + label:before { margin-bottom: 15px; padding: 25px 5px; } -div.agents_custom_fields #datatables_wrapper div.top, -div.agents_custom_fields #datatables_wrapper div.bottom { - background-color: #414141; - color: #ffffff; - border: none; - padding: 5px; - height: 38px; - width: 99%; -} /*Horizontal tree*/ @@ -12674,16 +12666,6 @@ div.agents_custom_fields #datatables_wrapper div.bottom { margin-top: 15px; } -.custom_fields_view { - width: 30%; - float: left; - margin-left: 10px; - padding-right: 10px; - max-height: 890px; - overflow: auto; - background-color: #f9f9f9; -} - .agents_custom_fields { width: 100%; @@ -12915,6 +12897,14 @@ tr.shown td.details-control { background-color: transparent; } +#ncm_backups > caption > h4 { + color: black; +} + +.tags_selected_container > span.select2 { + background-color: white !important; +} + .span_as_label { font-size: 13px; line-height: 16px; diff --git a/pandora_console/install.php b/pandora_console/install.php index 91de00f8a8..1864d06ed2 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
data[2][5] = html_print_submit_button( ); if (check_acl($config['id_user'], 0, 'PM')) { - // Pass the parameters to the page that generates the csv file (arrays) + // Pass the parameters to the page that generates the csv file (arrays). $decode_id_status = base64_encode(json_encode($id_status)); $decode_module_status = base64_encode(json_encode($module_status)); $decode_filters = base64_encode(json_encode($filters)); $table->data[3][5] = '
'; - /* - $table->data[3][5] .= html_print_button( - __('Export to CSV'), - 'csv_export', - false, - "blockResubmit($(this)); location.href='monitoring/custom_fields_csv.php?filters=$decode_filters&id_custom_field=$id_custom_fields&id_status=$decode_id_status&module_status=$decode_module_status'", - 'class="sub next"', - true - );*/ $table->data[3][5] .= '
'; } @@ -367,12 +358,13 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { $id_custom_field_array = $filters['id_custom_fields_data']; } - foreach ($id_custom_field_array as $value) { - /* - $table_agent = html_get_predefined_table(); - $table_agent->style = []; - $table_agent->class = 'tactical_view';*/ + $id_field = db_get_value_filter( + 'id_field', + 'tagent_custom_fields', + ['name' => $id_custom_fields] + ); + foreach ($id_custom_field_array as $value) { $table_agent = new StdClass(); $table_agent->width = '100%'; $table_agent->class = 'tactical_view'; @@ -388,7 +380,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents critical')] ); - $agent_data[1] = ""; + $agent_data[1] = ""; $agent_data[1] .= ""; $agent_data[1] .= format_numeric( $data['counters_name'][$value]['a_critical'] @@ -401,7 +393,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents warning')] ); - $agent_data[3] = ""; + $agent_data[3] = ""; $agent_data[3] .= ""; $agent_data[3] .= format_numeric( $data['counters_name'][$value]['a_warning'] @@ -414,7 +406,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents ok')] ); - $agent_data[5] = ""; + $agent_data[5] = ""; $agent_data[5] .= ""; $agent_data[5] .= format_numeric( $data['counters_name'][$value]['a_normal'] @@ -427,7 +419,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents unknown')] ); - $agent_data[7] = ""; + $agent_data[7] = ""; $agent_data[7] .= ""; $agent_data[7] .= format_numeric( $data['counters_name'][$value]['a_unknown'] @@ -440,7 +432,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true, ['title' => __('Agents not init')] ); - $agent_data[9] = ""; + $agent_data[9] = ""; $agent_data[9] .= ""; $agent_data[9] .= format_numeric( $data['counters_name'][$value]['a_not_init'] @@ -455,12 +447,6 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { $m_unknown = ($data['counters_name'][$value]['m_unknown'] <= 0) ? '0' : $data['counters_name'][$value]['m_unknown']; $m_not_init = ($data['counters_name'][$value]['m_not_init'] <= 0) ? '0' : $data['counters_name'][$value]['m_not_init']; - // Modules by status table. - /* - $table_mbs = html_get_predefined_table(); - $table_mbs->class = 'tactical_view'; - $table_mbs->style = [];*/ - $table_mbs = new StdClass(); $table_mbs->width = '100%'; $table_mbs->class = 'tactical_view'; @@ -478,7 +464,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[1] = ''.$m_critical.''; + $tdata[1] = ''.$m_critical.''; $tdata[2] = html_print_image( 'images/module_warning.png', @@ -489,7 +475,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[3] = ''.$m_warning.''; + $tdata[3] = ''.$m_warning.''; $tdata[4] = html_print_image( 'images/module_ok.png', @@ -500,7 +486,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[5] = ''.$m_normal.''; + $tdata[5] = ''.$m_normal.''; $tdata[6] = html_print_image( 'images/module_unknown.png', @@ -511,7 +497,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { false, true ); - $tdata[7] = ''.$m_unknown.''; + $tdata[7] = ''.$m_unknown.''; $tdata[8] = html_print_image( 'images/module_notinit.png', @@ -523,7 +509,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { true ); - $tdata[9] = ''.$m_not_init.''; + $tdata[9] = ''.$m_not_init.''; $table_mbs->data[] = $tdata; @@ -714,7 +700,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { echo '
'; echo "
"; - echo ""; + echo "
"; echo ''; echo ''; echo ''; @@ -755,6 +741,7 @@ if (isset($id_custom_fields_data) && is_array($id_custom_fields_data)) { echo ''; ui_require_css_file('datatables.min', 'include/styles/js/'); +ui_require_css_file('custom_field', 'include/styles/'); ui_require_javascript_file_enterprise('functions_csv'); ui_require_javascript_file('datatables.min'); ui_require_javascript_file('buttons.dataTables.min'); @@ -904,7 +891,6 @@ function dialog_filter_cf(title, type_form){ } function table_datatables(filters, indexed_descriptions, processing){ - console.log(indexed_descriptions); array_data = JSON.parse(filters); table = $('#datatables').DataTable({ processing: true, @@ -913,7 +899,6 @@ function table_datatables(filters, indexed_descriptions, processing){ searching: true, pageLength: Number(array_data.block_size), lengthMenu: [ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 75, 100], - //buttons: [{ extend: 'csvHtml5', text: 'Save as csvHtml5' }], responsive: false, ajax: { type: "POST", @@ -933,21 +918,16 @@ function table_datatables(filters, indexed_descriptions, processing){ 'paging': true, 'ordering': true, 'scrollX': true, - 'scroller': true + 'scroller': true, }, }, language: { processing: processing, lengthMenu: "Show _MENU_ items per page", zeroRecords: "Nothing found. Please change your search term", - //info: "Page _PAGE_ of _PAGES_", infoEmpty: "No results", infoFiltered: "", search: "Search:", - /*paginate:{ - next: "Next", - previous: "Next" - }*/ }, sDom: '<"top"lfp>rt<"bottom"ip><"clear">', columns: [ diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index be5f6047e3..6d969481a3 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -547,6 +547,45 @@ if (is_ajax() === true) { ); } + if (empty($tmp->tags) === false) { + $tmp->tags = ui_print_truncate_text( + $tmp->tags, + 30, + false, + true, + false, + '…', + true, + true, + ); + } + + if (empty($tmp->event_custom_id) === false) { + $tmp->event_custom_id = ui_print_truncate_text( + $tmp->event_custom_id, + 30, + false, + true, + false, + '…', + true, + true, + ); + } + + if (empty($tmp->module_custom_id) === false) { + $tmp->module_custom_id = ui_print_truncate_text( + $tmp->module_custom_id, + 30, + false, + true, + false, + '…', + true, + true, + ); + } + if (empty($tmp->comments) === false) { $tmp->comments = ui_print_comments($tmp->comments, 20); } @@ -650,19 +689,7 @@ if (is_ajax() === true) { $tmp->data = ui_print_truncate_text($tmp->data, 10); } - $tmp->instructions = events_get_instructions($item); - if (strlen($tmp->instructions) >= 20) { - $tmp->instructions = ui_print_truncate_text( - $tmp->instructions, - 20, - false, - true, - false, - '…', - true, - true, - ); - } + $tmp->instructions = events_get_instructions($item, 15); $tmp->user_comment = ui_print_comments( event_get_last_comment( @@ -899,14 +926,14 @@ if (is_ajax() === true) { true, [ 'title' => __('Unknown'), - 'class' => 'forced-title', + 'class' => 'forced-title main_menu_icon', ] ); $state = 0; break; } - $draw_state = '
'; + $draw_state = '
'; $draw_state .= ''; @@ -1199,10 +1226,10 @@ if (is_ajax() === true) { } $tmp->custom_data = $custom_data_str; - if (strlen($tmp->custom_data) >= 20) { + if (strlen($tmp->custom_data) >= 50) { $tmp->custom_data = ui_print_truncate_text( $tmp->custom_data, - 20, + 50, false, true, false, @@ -1232,15 +1259,18 @@ if (is_ajax() === true) { ); } - $data = array_values( - array_filter( - $data, - function ($item) { - return (bool) (array) $item; - } - ) - ); - $count = count($data); + if (isset($data) === true) { + $data = array_values( + array_filter( + $data, + function ($item) { + return (bool) (array) $item; + } + ) + ); + $count = count($data); + } + // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ @@ -2585,7 +2615,7 @@ try { if ($evento_id !== false) { $fields[$evento_id] = [ 'text' => 'evento', - 'class' => 'mw250px', + 'class' => 'mw180px', ]; } @@ -2594,23 +2624,24 @@ try { $fields[$comment_id] = ['text' => 'user_comment']; } - - foreach ($fields as $key => $field) { - if (is_array($field) === false) { - $fields[$key] = [ - 'text' => $field, - 'class' => 'mw100px', - ]; - } + $estado = array_search('estado', $fields); + if ($estado !== false) { + $fields[$estado] = [ + 'text' => $fields[$estado], + 'class' => 'column-estado', + ]; } + + + // Always add options column. $fields = array_merge( $fields, [ [ 'text' => 'options', - 'class' => 'table_action_buttons mw120px', + 'class' => 'table_action_buttons mw100px', ], [ 'text' => 'm', diff --git a/pandora_console/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php index 0a7754e46d..43296a1b26 100755 --- a/pandora_console/operation/inventory/inventory.php +++ b/pandora_console/operation/inventory/inventory.php @@ -675,7 +675,9 @@ $params['return'] = true; $params['show_helptip'] = true; $params['input_name'] = 'agent'; $params['value'] = $inventory_agent; -$params['javascript_is_function_select'] = true; +$params['selectbox_id'] = 'module_inventory_general_view'; +// $params['javascript_is_function_select'] = true; +// $params['javascript_function_action_after_select'] = 'this.form.submit'; $params['use_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true; $params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent'; diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index cc42d7e6ac..4bc5a05b61 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -335,6 +335,7 @@ $table2->data[0][3] = $html_menu_export; $searchForm = '
'; $searchForm .= html_print_table($table2, true); $searchForm .= html_print_input_hidden('id_report', $id_report, true); +$Actionbuttons = ''; if ((bool) is_metaconsole() === true) { $Actionbuttons .= html_print_submit_button( diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index b9ed066d68..221717d3fe 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -6,7 +6,7 @@ %define debug_package %{nil} %define name pandorafms_console %define version 7.0NG.774 -%define release 231213 +%define release 231214 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index defda9ef4d..2ad566822c 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -6,7 +6,7 @@ %define debug_package %{nil} %define name pandorafms_console %define version 7.0NG.774 -%define release 231213 +%define release 231214 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 7729b27053..0f9ab3ccad 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.774 -%define release 231213 +%define release 231214 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a4ae12c2d0..6a0f439278 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1638,6 +1638,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `cat_security_hardening` INT NOT NULL DEFAULT 0, `ignore_skipped` INT NOT NULL DEFAULT 0, `status_of_check` TINYTEXT, + `ncm_agents` MEDIUMTEXT, `check_unknowns_graph` tinyint DEFAULT '0', PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) @@ -4190,6 +4191,29 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +-- ---------------------------------------------------------------------- +-- Table `tncm_agent_data_template` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- ---------------------------------------------------------------------- +-- Table `tncm_agent_data_template_scripts` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( + `id` SERIAL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + -- ---------------------------------------------------------------------- -- Table `tncm_agent` -- ---------------------------------------------------------------------- @@ -4205,10 +4229,13 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` ( `updated_at` BIGINT NOT NULL DEFAULT 0, `config_backup_id` BIGINT UNSIGNED DEFAULT NULL, `id_template` BIGINT UNSIGNED, + `id_agent_data_template` BIGINT UNSIGNED, `execute_type` INT UNSIGNED NOT NULL DEFAULT 0, `execute` INT UNSIGNED NOT NULL DEFAULT 0, `cron_interval` VARCHAR(100) DEFAULT '', + `agent_data_cron_interval` VARCHAR(100) DEFAULT '', `event_on_change` INT UNSIGNED DEFAULT null, + `agent_data_event_on_change` INT UNSIGNED DEFAULT null, `last_error` TEXT, PRIMARY KEY (`id_agent`), FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, @@ -4225,6 +4252,7 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_data` ( `id` SERIAL, `id_agent` INT UNSIGNED NOT NULL, `script_type` INT UNSIGNED NOT NULL, + `id_agent_data` INT NOT NULL DEFAULT 0, `data` LONGBLOB, `status` INT NOT NULL DEFAULT 5, `updated_at` BIGINT NOT NULL DEFAULT 0, @@ -4238,8 +4266,10 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `id` SERIAL, `id_agent` INT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, + `id_agent_data` bigint unsigned, `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, + `snippet` TEXT NULL, FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 70f9451932..79cca53917 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -375,11 +375,11 @@ INSERT INTO `tusuario_perfil` (`id_up`, `id_usuario`, `id_perfil`, `id_grupo`, ` -- INSERT INTO `tperfil` VALUES - (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0), - (2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,0), - (3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0), - (4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), - (5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); + (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0), + (2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,0), + (3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0), + (4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), + (5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -- -- Dumping data for table `tnews` @@ -394,7 +394,7 @@ INSERT INTO tmodule VALUES (5,'Prediction module'); INSERT INTO tmodule VALUES (6,'WMI module'); INSERT INTO tmodule VALUES (7, 'Web module'); INSERT INTO tmodule VALUES (8, 'Wux module'); -INSERT INTO tmodule VALUES (9, 'Wizard module'); +INSERT INTO tmodule VALUES (9, 'Wizard module'); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (1,'OS Total process','Total process in Operating System (UNIX MIB)',13,15,0,0,300,0,'','','public','HOST-RESOURCES-MIB::hrSystemProcesses.0 ',4,2,0,NULL,NULL,NULL,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -738,11 +738,11 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (513,'MSDTC TransactionsPersec','Transactions performed per second.',22,1,0,0,300,0,'','','','select TransactionsPersec from Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator',3,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (514,'c2900InfoPeakBuffersUsed','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.1.2.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (515,'c2900InfoTotalBufferDepth','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.1.3.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (516,'c2900BandwidthUsageCurrent ','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.5.1.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (516,'c2900BandwidthUsageCurrent ','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.5.1.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (517,'Latest Message ','Get the last message sent in Syslog',2,17,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.41.1.2.3.1.5.12',1,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (518,'Latest Message date','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.41.1.2.3.1.6.12',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (519,'CPU avgBusy1min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.57.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (520,'CPU avgBusy5min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.58.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (519,'CPU avgBusy1min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.57.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (520,'CPU avgBusy5min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.58.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (521,'Software Image running ','',2,17,0,0,1800,0,'','','public','1.3.6.1.4.1.9.2.1.73.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (522,'nvRAMUsed','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.3.6.8.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (523,'Printers BytesPrintedPersec','Number of bytes per second printed on a print queue.',24,1,0,0,300,0,'','','','select BytesPrintedPersec from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -754,7 +754,7 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (529,'Printers OutofPaperErrors','Total number of out-of-paper errors in a print queue after the last restart.',24,1,0,0,300,0,'','','','select OutofPaperErrors from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (530,'Printers TotalJobsPrinted','Total number of jobs printed on a print queue after the last restart.',24,1,0,0,300,0,'','','','select TotalJobsPrinted from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (531,'Printers TotalPagesPrinted','Total number of pages printed through GDI on a print queue after the last restart.',24,1,0,0,300,0,'','','','select TotalPagesPrinted from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (532,'Printers Availability','Availability and status of the device\r\n\r\nValue Meaning\r\n\r\n10x1 Other\r\n\r\n20x2 Unknown\r\n\r\n30x3 Running or Full Power\r\n\r\n40x4 Warning\r\n\r\n50x5 In Test\r\n\r\n60x6 Not Applicable\r',24,3,0,0,300,0,'','','','select Availability from Win32_Printer',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (532,'Printers Availability','Availability and status of the device\r\n\r\nValue Meaning\r\n\r\n10x1 Other\r\n\r\n20x2 Unknown\r\n\r\n30x3 Running or Full Power\r\n\r\n40x4 Warning\r\n\r\n50x5 In Test\r\n\r\n60x6 Not Applicable\r',24,3,0,0,300,0,'','','','select Availability from Win32_Printer',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (533,'Serv_IISAdmin','IIS Administration Server service status.',26,2,0,0,300,0,'','','Running','Select State from Win32_Service WHERE name = 'IISAdmin'',3,6,0,'Administrador','6683','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (534,'Serv_MSSQL_server','Displays if MS SQL SERVER is running',27,2,0,0,0,0,'','','Running','select state from Win32_Service where name = "MSSQLSERVER"',7,6,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (535,'SQLServer_DataFilesSizeKB','Sql database size in kb ',27,1,0,0,0,0,'','','','select state from Win32_Service where name = "MSSQLSERVER"',7,6,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); @@ -1302,8 +1302,8 @@ INSERT INTO `tcontainer` SET `name` = 'Default graph container'; -- Dumping data for table `tlog_graph_models` -- INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', - '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', - 'pagina, html_err_code, _tiempo_', 1); + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status', '(.*?)\ -.*1.1"\ (\d+)\ \d+', @@ -1359,13 +1359,13 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System INSERT INTO `tpen` VALUES - (9,'cisco','Cisco System'), - (11,'hp','Hewlett Packard'), - (2021,'general_snmp','U.C. Davis, ECE Dept. Tom'), - (2636,'juniper','Juniper Networks'), - (3375,'f5','F5 Labs'), - (8072,'general_snmp','Net SNMP'), - (12356,'fortinet','Fortinet') + (9,'cisco','Cisco System'), + (11,'hp','Hewlett Packard'), + (2021,'general_snmp','U.C. Davis, ECE Dept. Tom'), + (2636,'juniper','Juniper Networks'), + (3375,'f5','F5 Labs'), + (8072,'general_snmp','Net SNMP'), + (12356,'fortinet','Fortinet') ; -- @@ -2512,7 +2512,7 @@ INSERT IGNORE INTO `tpen` VALUES (171,'dlink','D-Link Systems, Inc.'),(14988,'mi INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (1,'Cisco'), - (2, 'D-Link Systems, Inc.'), + (2, 'D-Link Systems, Inc.'), (3, 'MikroTik'), (4, 'Alcatel-Lucent Enterprise'), (5, 'Ubiquiti Networks, Inc.'), @@ -2524,21 +2524,157 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (11, 'Netlink'), (12, 'Ascom'), (13, 'Synology Inc.'), - (14, 'Fujitsu Network Communications, Inc.'); + (14, 'Fujitsu Network Communications, Inc.'), + (15, 'Juniper'), + (16, 'Palo Alto'), + (17, 'A10'), + (18, 'Aruba'); -INSERT INTO `tncm_model` VALUES (1,1,'7200'); +INSERT INTO `tncm_model` VALUES + (1,1,'7200'), + (2,1,'Cisco-Generic'), + (3,15,'Juniper-Generic'), + (4,16,'Palo Alto-Generic'), + (5,17,'A10-Generic'), + (6,4,'Alcatel-Generic'), + (7,18,'Aruba-Generic'), + (8,3,'Mikrotik-Generic'); -INSERT INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'); +INSERT INTO `tncm_template` VALUES + (1,'cisco-base','[\"1\"]','[\"1\"]'), + (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (5,'A10-Generic','[\"17\"]','[\"5\"]'), + (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (8,'Mikrotik-Generic','[\"3\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), (2,1,'enable expect:Password:\s* _enablepass_ term length 0 capture:show running-config exit '), - (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), - (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), - (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), - (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'); + (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), + (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), + (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), + (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? firmware.bin show flash reload expect:confirm y config terminal boot system firmware.bin'), + (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), + (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), + (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), + (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? firmware.bin\n show flash\n reload\n expect:confirm y\n config terminal\n boot system firmware.bin\n'), + (12,5,''), + (13,7,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), + (14,0,'expect:root@% cli\n exit\n'), + (15,1,'expect:root@% cli\n expect:root> capture:show configuration | no-more\n capture:\n quit\n expect:root@% exit\n'), + (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), + (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), + (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), + (19,5,''), + (20,7,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), + (21,0,'sleep:1 exit\n'), + (22,1,'set cli pager off \n capture:show config running\n exit\n'), + (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), + (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), + (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), + (26,5,''), + (27,7,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), + (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), + (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), + (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), + (33,5,''), + (34,7,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), + (37,2,''), + (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), + (39,4,''), + (40,5,''), + (41,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), + (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), + (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (46,4,'copy tftp flash _TFTP_SERVER_IP_ firmware.bin.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ firmware.bin primary\n boot system flash primary\n'), + (47,5,''), + (48,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (49,0,'sleep:1 exit\n\r'), + (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), + (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), + (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), + (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), + (54,5,''), + (55,7,'sleep:1 capture:/system package print\n\r exit\n\r'), + (56,6,'snippet'); -INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6); +INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES + (1,1), + (1,2), + (1,3), + (1,4), + (1,5), + (1,6), + (2,7), + (2,8), + (2,9), + (2,10), + (2,11), + (2,12), + (3,14), + (3,15), + (3,16), + (3,17), + (3,18), + (3,19), + (4,21), + (4,22), + (4,23), + (4,24), + (4,25), + (4,26), + (5,28), + (5,29), + (5,30), + (5,31), + (5,32), + (5,33), + (6,35), + (6,36), + (6,37), + (6,38), + (6,39), + (6,40), + (7,42), + (7,43), + (7,44), + (7,45), + (7,46), + (7,47), + (8,49), + (8,50), + (8,51), + (8,52), + (8,53), + (8,54); + +INSERT INTO `tncm_agent_data_template` VALUES + (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (4,'A10-Generic','[\"17\"]','[\"5\"]'), + (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (7,'Mikrotik-Generic','[\"3\"]','[\"8\"]'); + +INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES + (1,13), + (2,20), + (3,27), + (4,34), + (5,41), + (6,48), + (7,55); INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); diff --git a/pandora_console/views/cluster/view.php b/pandora_console/views/cluster/view.php index 32bcdb0736..93894ba7e5 100644 --- a/pandora_console/views/cluster/view.php +++ b/pandora_console/views/cluster/view.php @@ -151,7 +151,11 @@ $agentCountModules = html_print_div( true ); -$alive_animation = agents_get_starmap(0, 180, 30, $module_involved_ids); +$alive_animation = ''; +if (empty($module_involved_ids) === false) { + $alive_animation = agents_get_starmap(0, 180, 30, $module_involved_ids); +} + $output = '
'; $output .= '
'; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 11123e2837..fd95ec2981 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.774-231213 +Version: 7.0NG.774-231214 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 256a8b478f..e53e8e8333 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.774-231213" +pandora_version="7.0NG.774-231214" package_cpan=0 package_pandora=1 diff --git a/pandora_server/extras/pandoraPlugintools/encryption.py b/pandora_server/extras/pandoraPlugintools/encryption.py index b1ec3c9315..6e456d2fcd 100644 --- a/pandora_server/extras/pandoraPlugintools/encryption.py +++ b/pandora_server/extras/pandoraPlugintools/encryption.py @@ -39,7 +39,7 @@ def _print_debug( #### # Internal use only: Get AES cipher ######################################################################################### -def _get_cipher( +def _get_cipher_AES( password: str = _PASSWORD ) -> AES: ''' @@ -78,7 +78,7 @@ def encrypt_AES( Returns: str: The encrypted string in base64 encoding. ''' - cipher = _get_cipher(password) + cipher = _get_cipher_AES(password) try: msg_padded = pad(str_to_encrypt.encode(), AES.block_size, style='pkcs7') @@ -106,11 +106,91 @@ def decrypt_AES( Returns: str: The decrypted string. ''' - cipher = _get_cipher(password) + cipher = _get_cipher_AES(password) try: decrypted_str = unpad(cipher.decrypt(base64.b64decode(str_to_decrypt)), AES.block_size, style='pkcs7').decode().strip() except: decrypted_str = '' + return decrypted_str + +#### +# Internal use only: Get Rijndael cipher +######################################################################################### +def _get_cipher_Rijndael( + password: str = _PASSWORD + ) -> AES: + ''' + Internal use only: Get Rijndael cipher for encryption and decryption. + + Args: + password (str): The password used to derive the encryption key. + + Returns: + AES: An AES cipher instance for encryption and decryption. + ''' + key = b'' + msg = password.encode('utf-8') + hash_obj = hmac.new(key, msg, hashlib.sha256) + hash_result = hash_obj.digest() + hash_base64 = base64.b64encode(hash_result)[:16].decode() + + return AES.new(hash_base64.encode(), AES.MODE_ECB) + +#### +# Return encrypted string +######################################################################################### +def encrypt_Rijndael( + str_to_encrypt: str = "", + password: str = _PASSWORD + ) -> str: + ''' + Encrypt a string using Rijndael encryption. + + Args: + str_to_encrypt (str): The string to be encrypted. + password (str): The password used to derive the encryption key. + + Returns: + str: The encrypted string in base64 encoding. + ''' + cipher = _get_cipher_Rijndael(password) + + try: + padded_data = str_to_encrypt.encode() + missing = 16 - (len(padded_data) % 16) + padded_data += bytes([0] * missing) if missing != 16 else b'' + + b64str = base64.b64encode(cipher.encrypt(padded_data)).decode() + except: + b64str = '' + + return b64str + +#### +# Return decrypted string +######################################################################################### +def decrypt_Rijndael( + str_to_decrypt: str = "", + password: str = _PASSWORD + ) -> str: + ''' + Decrypt an encrypted string using Rijndael decryption. + + Args: + str_to_decrypt (str): The encrypted string to be decrypted. + password (str): The password used to derive the encryption key. + + Returns: + str: The decrypted string. + ''' + cipher = _get_cipher_Rijndael(password) + + try: + decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)) + decrypted_str = decrypted_data.rstrip(b'\x00').decode() + except: + decrypted_str = '' + return decrypted_str \ No newline at end of file diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 64f526f08a..7209ed0131 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -46,7 +46,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.774"; -my $pandora_build = "231213"; +my $pandora_build = "231214"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index f069b2710f..771fd75075 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.774"; -my $pandora_build = "231213"; +my $pandora_build = "231214"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 3d44ddc426..08a0661437 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 0bad40c2b6..cee1e6c579 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.774 -%define release 231213 +%define release 231214 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 8dcdf85db0..aed560fe90 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.774" -PI_BUILD="231213" +PI_BUILD="231214" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 0b74326632..c08803df7c 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.774 Build 231213"; +my $version = "7.0NG.774 Build 231214"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index afcf8b9199..02a9532ce0 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.774 Build 231213"; +my $version = "7.0NG.774 Build 231214"; # save program name for logging my $progname = basename($0);