diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 90c4bf6519..10e5534459 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -54,7 +54,8 @@ AGENT_WIN_FILE="$CODEHOME/pandora_agents/win32/pandora.cc" AGENT_WIN_MPI_FILE="$CODEHOME/pandora_agents/win32/installer/pandora.mpi" AGENT_WIN_RC_FILE="$CODEHOME/pandora_agents/win32/versioninfo.rc" SATELLITE_FILE="$PANDHOME_ENT/satellite_server/satellite_server.pl" -PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl \ +PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_server/util/recon_script/vmware-plugin.pl \ +$PANDHOME_ENT/pandora_server/util/recon_script/pcm_client.pl \ $PANDHOME_ENT/pandora_plugins/NGINX/nginx_requests_queued.pl \ $PANDHOME_ENT/pandora_plugins/Sybase/sybase_plugin.pl \ $PANDHOME_ENT/pandora_plugins/SNMP/dynamic_snmp.pl \ diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index c9e01190e9..e9d22f629b 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.731-190215 +Version: 7.0NG.731-190226 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 f50b4ee8dc..64c13e926e 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.731-190215" +pandora_version="7.0NG.731-190226" 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 187f94b41d..bb7d98e310 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.731'; -use constant AGENT_BUILD => '190215'; +use constant AGENT_BUILD => '190226'; # 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 16bf75ef2f..d4e33903d4 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190215 +%define release 190226 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 1dd06bf43e..87436366bb 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190215 +%define release 190226 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 340a0c2712..3ff9b6a963 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190215" +PI_BUILD="190226" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b7dff2f2ec..abdf2e0ce4 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190215} +{190226} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 48aba959cb..01f027089d 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.731(Build 190215)") +#define PANDORA_VERSION ("7.0NG.731(Build 190226)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 2b58063706..cb30f2163d 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.731(Build 190215))" + VALUE "ProductVersion", "(7.0NG.731(Build 190226))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 12ecde5daf..fe87752dff 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.731-190215 +Version: 7.0NG.731-190226 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 0171643ae5..60d17de09e 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.731-190215" +pandora_version="7.0NG.731-190226" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql new file mode 100644 index 0000000000..0809bc486e --- /dev/null +++ b/pandora_console/extras/mr/25.sql @@ -0,0 +1,147 @@ +START TRANSACTION; + +UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget'; + +INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); + +ALTER TABLE `trecon_task` ADD COLUMN `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; +ALTER TABLE `trecon_task` ADD COLUMN `auth_strings` text; +ALTER TABLE `trecon_task` ADD COLUMN `autoconfiguration_enabled` tinyint(1) unsigned default '0'; + + +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); + +CREATE TABLE IF NOT EXISTS `tevent_extended` ( + `id` serial PRIMARY KEY, + `id_evento` bigint(20) unsigned NOT NULL, + `external_id` bigint(20) unsigned, + `utimestamp` bigint(20) NOT NULL default '0', + `description` text, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tnotification_source` ( + `id` serial, + `description` VARCHAR(255) DEFAULT NULL, + `icon` text, + `max_postpone_time` int(11) DEFAULT NULL, + `enabled` int(1) DEFAULT NULL, + `user_editable` int(1) DEFAULT NULL, + `also_mail` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `tnotification_source` +-- +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); + +-- ----------------------------------------------------- +-- Table `tmensajes` +-- ----------------------------------------------------- +ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT; +ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; +ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tmensajes` ADD INDEX (`id_source`); +UPDATE `tmensajes` SET `id_source`=(SELECT `id` FROM `tnotification_source` WHERE `description` = "Message"); +ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +CREATE TABLE IF NOT EXISTS `tnotification_user` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT(20), + `utimestamp_erased` BIGINT(20), + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tnotification_group` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_group` mediumint(4) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tnotification_source_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tnotification_source_group` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tnotification_source_group_user`( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); + +INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; +INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Apache accesses per client and status', +'(.*?)\ -.*1.1"\ (\d+)\ \d+', +'host,status', 1); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Apache time per requester and html code', +'(.*?)\ -.*1.1"\ (\d+)\ (\d+)', +'origin,respose,_time_', 1); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Count output', +'.*', +'Coincidences', 0); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Events replicated to metaconsole', +'.* (.*?) .* (\d+) events replicated to metaconsole', +'server,_events_', 0); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Pages with warnings', +'PHP Warning:.*in (.*?) on', +'page', 0); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Users login', +'Starting Session \d+\ of user (.*)', +'user', 0); + +COMMIT; diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 4a0b32de81..519b4b32a5 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -137,8 +137,8 @@ function get_logs_size($file) function get_status_logs($path) { $status_server_log = ''; - $size_server_log = get_logs_size($path); - if ($size_server_log <= 10240) { + $size_server_log = number_format(get_logs_size($path)); + if ($size_server_log <= 1048576) { $status_server_log = "Normal Status   You have less than 10 MB of logs"; } else { $status_server_log = "Warning Status   You have more than 10 MB of logs"; @@ -412,11 +412,7 @@ render_info_data( render_info_data('SELECT COUNT(*) FROM tagente_modulo', 'Total modules'); render_info_data('SELECT COUNT(*) FROM tgrupo', 'Total groups'); render_info_data('SELECT COUNT(*) FROM tagente_datos', 'Total module data records'); - // render_info_data ("SELECT COUNT(*) FROM tagente_datos_string","Total module string data records"); - // render_info_data ("SELECT COUNT(*) FROM tagente_datos_log4x","Total module log4x data records"); render_info_data('SELECT COUNT(*) FROM tagent_access', 'Total agent access record'); - // render_info ("tagente_estado"); - // render_info ("talert_template_modules"); render_info_data('SELECT COUNT(*) FROM tevento', 'Total events'); if ($config['enterprise_installed']) { @@ -700,7 +696,7 @@ render_info_data( render_row(status_values($read_rnd_buffer_size_min_rec_value, $read_rnd_buffer_size), 'Read rnd-buffer size ', 'Read rnd-buffer size '); render_row(status_values($query_cache_min_res_unit_min_rec_value, $query_cache_min_res_unit), 'Query cache min-res-unit ', 'Query cache min-res-unit '); render_row(status_values($innodb_file_per_table_min_rec_value, $innodb_file_per_table), 'InnoDB file per table ', 'InnoDB file per table '); - echo "".__('Tables fragmentation in the PandoraFMS database').''; + echo "".__('Tables fragmentation in the Pandora FMS database').''; @@ -708,14 +704,14 @@ render_info_data( render_row(number_format($tables_fragmentation, 2).'%', 'Tables fragmentation (current value)'); render_row(status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), 'Status fragmentation tables'); - echo "".__(' PandoraFMS logs dates').''; + echo "".__(' Pandora FMS logs dates').''; - render_row(number_format((get_logs_size($path_server_logs) / 1024), 2).'M', 'Size server logs (current value)'); + render_row(number_format((get_logs_size($path_server_logs) / 1048576), 3).'M', 'Size server logs (current value)'); render_row(get_status_logs($path_server_logs), 'Status server logs'); - render_row(number_format((get_logs_size($path_console_logs) / 1024), 2).'M', 'Size console logs (current value)'); + render_row(number_format((get_logs_size($path_console_logs) / 1048576), 3).'M', 'Size console logs (current value)'); render_row(get_status_logs($path_console_logs), 'Status console logs'); - echo "".__(' PandoraFMS Licence Information').''; + echo "".__(' Pandora FMS Licence Information').''; render_row(html_print_textarea('keys[customer_key]', 10, 255, $settings->customer_key, 'style="height:40px; width:450px;"', true), 'Customer key'); render_row($license['expiry_date'], 'Expires'); diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bedb9927cd..2492a9913f 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1206,6 +1206,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '731'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); -- --------------------------------------------------------------------- -- Table `tconfig_os` @@ -1406,12 +1407,16 @@ ALTER TABLE twidget_dashboard MODIFY options LONGTEXT NOT NULL default ""; ALTER TABLE trecon_task ADD `alias_as_name` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; +ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; +ALTER TABLE trecon_task ADD `auth_strings` text; +ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` -- --------------------------------------------------------------------- UPDATE twidget_dashboard SET id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_module_histogram') WHERE id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_availability'); DELETE FROM twidget WHERE unique_name = 'graph_availability'; +UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget'; -- --------------------------------------------------------------------- -- Table `tbackup` (Extension table. Modify only if exists) @@ -1816,7 +1821,30 @@ CREATE TABLE IF NOT EXISTS `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); - + +INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status', +'(.*?)\ -.*1.1"\ (\d+)\ \d+', +'host,status', 1); + +INSERT INTO tlog_graph_models VALUES (3, 'Apache time per requester and html code', +'(.*?)\ -.*1.1"\ (\d+)\ (\d+)', +'origin,respose,_time_', 1); + +INSERT INTO tlog_graph_models VALUES (4, 'Count output', +'.*', +'Coincidences', 0); + +INSERT INTO tlog_graph_models VALUES (5, 'Events replicated to metaconsole', +'.* (.*?) .* (\d+) events replicated to metaconsole', +'server,_events_', 0); + +INSERT INTO tlog_graph_models VALUES (6, 'Pages with warnings', +'PHP Warning:.*in (.*?) on', +'page', 0); + +INSERT INTO tlog_graph_models VALUES (7, 'Users login', +'Starting Session \d+\ of user (.*)', +'user', 0); -- ----------------------------------------------------- -- Add column in table `treport` -- ----------------------------------------------------- @@ -1856,6 +1884,19 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; +-- --------------------------------------------------------------------- +-- Table `tevent_extended` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tevent_extended` ( + `id` serial PRIMARY KEY, + `id_evento` bigint(20) unsigned NOT NULL, + `external_id` bigint(20) unsigned, + `utimestamp` bigint(20) NOT NULL default '0', + `description` text, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ----------------------------------------------------- -- Table `tgis_map_layer_groups` -- ----------------------------------------------------- @@ -1868,3 +1909,128 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `tnotification_source` +-- ----------------------------------------------------- +CREATE TABLE `tnotification_source` ( + `id` serial, + `description` VARCHAR(255) DEFAULT NULL, + `icon` text, + `max_postpone_time` int(11) DEFAULT NULL, + `enabled` int(1) DEFAULT NULL, + `user_editable` int(1) DEFAULT NULL, + `also_mail` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `tnotification_source` +-- +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); + +-- ----------------------------------------------------- +-- Table `tmensajes` +-- ----------------------------------------------------- +ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT; +ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; +ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +-- ---------------------------------------------------------------------- +-- Table `tnotification_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_user` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT(20), + `utimestamp_erased` BIGINT(20), + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_group` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_group` mediumint(4) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Add alert command 'Generate notification' +-- ---------------------------------------------------------------------- +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); + +-- ---------------------------------------------------------------------- +-- Update message references and pre-configure notifications +-- ---------------------------------------------------------------------- +INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; +INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; +-- ---------------------------------------------------------------------- +-- Add custom internal recon scripts +-- ---------------------------------------------------------------------- +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); diff --git a/pandora_console/general/firts_task/recon_view.php b/pandora_console/general/firts_task/recon_view.php index 026d0f5673..2377ce7c20 100755 --- a/pandora_console/general/firts_task/recon_view.php +++ b/pandora_console/general/firts_task/recon_view.php @@ -15,17 +15,17 @@ global $config; check_login(); ui_require_css_file('firts_task'); ?> - true, 'message' => __('There are no recon task defined yet.') ]); ?> + true, 'message' => __('There are no discovery tasks defined yet.') ]); ?>
- __('Recon server')]); ?> + __('Discovery server')]); ?>
-

+

ICMP (pings), SNMP (detecting the topology of networks and their interfaces), and other customized @@ -33,8 +33,8 @@ ui_require_css_file('firts_task'); ); ?>

-
- + +

diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 846f20677b..e35d401502 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -1,5 +1,4 @@ cellspacing = 0; $table->head = []; $table->data = []; - $table->style[0] = $table->style['clippy'] = $table->style[1] = $table->style[3] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = 'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;'; + $table->style['clippy'] = $table->style[1] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = $table->style['notifications'] = 'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;'; $table->style[7] = 'width: 20px; padding-right: 9px;'; $table->style['searchbar'] = 'width: 180px; min-width: 180px;'; $table->style[11] = 'padding-left: 10px; padding-right: 5px;width: 16px;'; @@ -110,27 +110,6 @@ config_check(); $table->data[0]['searchbar'] = $search_bar; } - // Servers check - $servers = []; - $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver'); - $servers['up'] = (int) servers_check_status(); - $servers['down'] = ($servers['all'] - $servers['up']); - if ($servers['up'] == 0) { - // All Servers down or no servers at all - $servers_check_img = html_print_image('images/header_down.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]); - } else if ($servers['down'] != 0) { - // Some servers down - $servers_check_img = html_print_image('images/header_warning.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]); - } else { - // All servers up - $servers_check_img = html_print_image('images/header_ready.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]); - } - - unset($servers); - // Since this is the header, we don't like to trickle down variables. - $servers_link_open = ''; - $servers_link_close = ''; - if ($config['show_qr_code_header'] == 0) { $show_qr_code_header = 'display: none;'; } else { @@ -175,12 +154,6 @@ config_check(); ).''; } - - $table->data[0][0] = $servers_link_open.$servers_check_img.$servers_link_close; - - - - // ======= Autorefresh code ============================= $autorefresh_txt = ''; $autorefresh_additional = ''; @@ -254,57 +227,8 @@ config_check(); $table->data[0][1] = $autorefresh_link_open_img.$autorefresh_img.$autorefresh_link_close; $table->data[0][2] = $autorefresh_link_open_txt.$autorefresh_txt.$autorefresh_link_close.$autorefresh_additional; // ====================================================== - $check_minor_release_available = false; $pandora_management = check_acl($config['id_user'], 0, 'PM'); - $check_minor_release_available = db_check_minor_relase_available(); - - if ($check_minor_release_available) { - if (users_is_admin($config['id_user'])) { - if ($config['language'] == 'es') { - set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. '.__('Sobre actualización de revisión menor').'', 'Revisión/es menor/es disponible/s'); - } else { - set_pandora_error_for_header('There are one or more minor releases waiting for update. '.__('About minor release update').'', 'minor release/s available'); - } - } - } - - echo ''; - - if ($config['alert_cnt'] > 0) { - $maintenance_link = 'javascript:'; - $maintenance_title = __('System alerts detected - Please fix as soon as possible'); - $maintenance_class = $maintenance_id = 'show_systemalert_dialog white'; - - $maintenance_link_open_txt = ''; - $maintenance_link_open_img = ''; - $maintenance_link_close = ''; - if (!$pandora_management) { - $maintenance_img = ''; - } else { - $maintenance_img = $maintenance_link_open_img.html_print_image( - 'images/header_yellow.png', - true, - [ - 'title' => __( - 'You have %d warning(s)', - $config['alert_cnt'] - ), - 'id' => 'yougotalert', - 'class' => 'bot', - ] - ).$maintenance_link_close; - } - } else { - if (!$pandora_management) { - $maintenance_img = ''; - } else { - $maintenance_img = html_print_image('images/header_ready.png', true, ['title' => __('There are not warnings'), 'id' => 'yougotalert', 'class' => 'bot']); - } - } - - $table->data[0][3] = $maintenance_img; - // Main help icon if (!$config['disable_help']) { $table->data[0][4] = ''.html_print_image( @@ -318,6 +242,12 @@ config_check(); ).''; } + $notifications_numbers = notifications_get_counters(); + $table->data[0]['notifications'] = notifications_print_ball( + $notifications_numbers['notifications'], + $notifications_numbers['last_id'] + ); + // Logout $table->data[0][5] = ''; $table->data[0][5] .= html_print_image('images/header_logout.png', true, ['alt' => __('Logout'), 'class' => 'bot', 'title' => __('Logout')]); @@ -341,18 +271,6 @@ config_check(); $table->data[0][8] .= ''; $table->data[0][8] .= ''; - // Messages - $msg_cnt = messages_get_count($config['id_user']); - if ($msg_cnt > 0) { - echo ''; - - $table->data[0][9] = ''; - $table->data[0][9] .= html_print_image('images/header_email.png', true, ['title' => __('You have %d unread message(s)', $msg_cnt), 'id' => 'yougotmail', 'class' => 'bot', 'style' => 'width:24px;']); - $table->data[0][9] .= ''; - } - - - html_print_table($table); unset($table); @@ -373,6 +291,9 @@ config_check(); + + + + \ No newline at end of file diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 004c947af4..143d6d880b 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -229,14 +229,14 @@ if (!$new_agent) { $table->data[0][1] .= "  ".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; } -$table->data[1][0] = __('Alias'); +$table->data[1][0] = __('Alias').ui_print_help_tip(__('Characters /,\,|,%,#,&,$ will be ignored'), true).''; $table->data[1][1] = html_print_input_text('alias', $alias, '', 50, 100, true); if ($new_agent) { $table->data[1][1] .= html_print_checkbox('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name'); } $table->data[2][0] = __('IP Address'); -$table->data[2][1] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true); +$table->data[2][1] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).html_print_checkbox('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true); if ($id_agente) { $table->data[2][1] .= '    '; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index dfa28988a8..9c10099042 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -81,6 +81,7 @@ $alias_as_name = 0; $direccion_agente = get_parameter('direccion', ''); $direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = io_safe_input($direccion_agente); +$unique_ip = 0; $intervalo = SECONDS_5MINUTES; $ff_interval = 0; $quiet_module = 0; @@ -158,9 +159,11 @@ $module_macros = []; // Create agent if ($create_agent) { $mssg_warning = 0; - $alias = (string) get_parameter_post('alias', ''); + $alias_safe_output = io_safe_output(get_parameter('alias', '')); + $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); + $unique_ip = (int) get_parameter_post('unique_ip', 0); // safe_output only validate ip $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -216,7 +219,12 @@ if ($create_agent) { $nombre_agente = $alias; } - if (!$exists_alias) { + if ($unique_ip && $direccion_agente != '') { + $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; + $exists_ip = db_get_row_sql($sql); + } + + if (!$exists_alias && !$exists_ip) { $id_agente = db_process_sql_insert( 'tagente', [ @@ -326,6 +334,8 @@ if ($create_agent) { $agent_creation_error = __('Could not be created'); if ($exists_alias) { $agent_creation_error = __('Could not be created, because name already exists'); + } else if ($exists_ip) { + $agent_creation_error = __('Could not be created, because IP already exists'); } } } @@ -755,9 +765,11 @@ if ($update_agent) { $mssg_warning = 0; $id_agente = (int) get_parameter_post('id_agente'); $nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', '')); - $alias = str_replace('`', '‘', (string) get_parameter_post('alias', '')); + $alias_safe_output = io_safe_output(get_parameter('alias', '')); + $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); + $unique_ip = (int) get_parameter_post('unique_ip', 0); // safe_output only validate ip $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -860,8 +872,15 @@ if ($update_agent) { // If there is an agent with the same name, but a different ID } + if ($unique_ip && $direccion_agente != '') { + $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; + $exists_ip = db_get_row_sql($sql); + } + if ($grupo <= 0) { ui_print_error_message(__('The group id %d is incorrect.', $grupo)); + } else if ($exists_ip) { + ui_print_error_message(__('Duplicate main IP address')); } else { // If different IP is specified than previous, add the IP if ($direccion_agente != '' @@ -915,7 +934,7 @@ if ($update_agent) { $result = db_process_sql_update('tagente', $values, ['id_agente' => $id_agente]); - if ($result == false && $update_custom_result == false) { + if ($result === false && $update_custom_result == false) { ui_print_error_message( __('There was a problem updating the agent') ); diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 0eb5fad7cd..11402c8ca6 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -128,7 +128,7 @@ $snmp_versions['2c'] = 'v. 2c'; $snmp_versions['3'] = 'v. 3'; $data = []; -$data[0] = __('SNMP community'); +$data[0] = __('SNMP community').ui_print_help_icon('column_macros', true); $adopt = false; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && isset($id_agent_module)) { $adopt = policies_is_module_adopt($id_agent_module); @@ -277,7 +277,7 @@ if (!isset($id_agent_module)) { } $data = []; -$data[0] = __('Auth user'); +$data[0] = __('Auth user').ui_print_help_icon('column_macros', true); $data[1] = html_print_input_text( 'snmp3_auth_user', $snmp3_auth_user, @@ -290,7 +290,7 @@ $data[1] = html_print_input_text( '', $classdisabledBecauseInPolicy ); -$data[2] = __('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); +$data[2] = __('Auth password').ui_print_help_icon('column_macros', true).ui_print_help_tip(__('The pass length must be eight character minimum.'), true); $data[3] = html_print_input_password( 'snmp3_auth_pass', $snmp3_auth_pass, @@ -312,7 +312,7 @@ push_table_simple($data, 'field_snmpv3_row1'); $data = []; $data[0] = __('Privacy method'); $data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', $disabledBecauseInPolicy); -$data[2] = __('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); +$data[2] = __('Privacy pass').ui_print_help_icon('column_macros', true).ui_print_help_tip(__('The pass length must be eight character minimum.'), true); $data[3] = html_print_input_password( 'snmp3_privacy_pass', $snmp3_privacy_pass, diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index e7f38447cf..d15cd6477f 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -60,7 +60,7 @@ $data[3] = html_print_input_text( push_table_simple($data, 'target_ip'); $data = []; -$data[0] = __('Username'); +$data[0] = __('Username').ui_print_help_icon('column_macros', true); $data[1] = html_print_input_text( 'plugin_user', $plugin_user, @@ -73,7 +73,7 @@ $data[1] = html_print_input_text( '', $classdisabledBecauseInPolicy ); -$data[2] = __('Password'); +$data[2] = __('Password').ui_print_help_icon('column_macros', true); $data[3] = html_print_input_password( 'plugin_pass', $plugin_pass, diff --git a/pandora_console/godmode/agentes/status_monitor_custom_fields.php b/pandora_console/godmode/agentes/status_monitor_custom_fields.php new file mode 100644 index 0000000000..7e9ae48bdd --- /dev/null +++ b/pandora_console/godmode/agentes/status_monitor_custom_fields.php @@ -0,0 +1,272 @@ + 'status_monitor_fields', + 'value' => $status_monitor_fields, + ]; + + // update 'status_monitor_fields' in tconfig table to keep the value at update. + $result = db_process_sql_update( + 'tconfig', + $values, + ['token' => 'status_monitor_fields'] + ); + + ui_print_result_message($result, __('Successfully updated'), __('Could not be updated')); + + $config['status_monitor_fields'] = $status_monitor_fields; +} + +$fields_selected = []; +$status_monitor_fields = ''; +$fields_selected = explode(',', $config['status_monitor_fields']); + +$result_selected = []; + +// show list of fields selected. +if ($fields_selected[0] != '') { + foreach ($fields_selected as $field_selected) { + switch ($field_selected) { + case 'policy': + $result = __('Policy'); + break; + + case 'agent': + $result = __('Agent'); + break; + + case 'data_type': + $result = __('Data type'); + break; + + case 'module_name': + $result = __('Module name'); + break; + + case 'server_type': + $result = __('Server type'); + break; + + case 'interval': + $result = __('Interval'); + break; + + case 'status': + $result = __('Status'); + break; + + case 'graph': + $result = __('Graph'); + break; + + case 'warn': + $result = __('Warn'); + break; + + case 'data': + $result = __('Data'); + break; + + case 'timestamp': + $result = __('Timestamp'); + break; + + case 'to_critical': + $result = __('Last status change'); + break; + } + + $result_selected[$field_selected] = $result; + } +} + +echo '

'.__('Show monitor detail fields').'

'; + +$table = new stdClass(); +$table->width = '100%'; +$table->class = 'databox filters'; + +$table->size = []; +// ~ $table->size[0] = '20%'; +$table->size[1] = '10px'; +// ~ $table->size[2] = '20%'; +$table->style[0] = 'text-align:center;'; +$table->style[2] = 'text-align:center;'; + +$table->data = []; + +$fields_available = []; + +$fields_available['policy'] = __('Policy'); +$fields_available['agent'] = __('Agent'); +$fields_available['data_type'] = __('Data type'); +$fields_available['module_name'] = __('Module name'); +$fields_available['server_type'] = __('Server type'); +$fields_available['interval'] = __('Interval'); +$fields_available['status'] = __('Status'); +$fields_available['graph'] = __('Graph'); +$fields_available['warn'] = __('Warn'); +$fields_available['data'] = __('Data'); +$fields_available['timestamp'] = __('Timestamp'); +$fields_available['to_critical'] = __('Last status change'); + +// remove fields already selected +foreach ($fields_available as $key => $available) { + foreach ($result_selected as $selected) { + if ($selected == $available) { + unset($fields_available[$key]); + } + } +} + +$table->data[0][0] = ''.__('Fields available').''; +$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); +$table->data[1][1] = ''.html_print_image( + 'images/darrowright.png', + true, + [ + 'id' => 'right', + 'title' => __('Add fields to select'), + ] +).''; +$table->data[1][1] .= '



'.html_print_image( + 'images/darrowleft.png', + true, + [ + 'id' => 'left', + 'title' => __('Delete fields to select'), + ] +).''; + +$table->data[0][1] = ''; +$table->data[0][2] = ''.__('Fields selected').''; +$table->data[1][2] = html_print_select( + $result_selected, + 'fields_selected[]', + true, + '', + '', + 0, + true, + true, + false, + '', + false, + 'width: 300px' +); + +echo '
'; +html_print_table($table); + +echo '
'; + html_print_submit_button(__('Update'), 'upd_button', false, 'class="sub upd"'); +echo ''; +echo '
'; +?> + + diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 69ec49cfce..0ed041d680 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -21,6 +21,21 @@ require_once 'include/functions_menu.php'; $menu_godmode = []; $menu_godmode['class'] = 'godmode'; + +if (check_acl($config['id_user'], 0, 'PM')) { + $sub = []; + $sub['godmode/servers/discovery']['text'] = __('Discover'); + $sub['godmode/servers/discovery']['id'] = 'Discover'; + $sub['godmode/servers/discovery']['subsecs'] = ['godmode/servers/discovery']; + + // Add to menu. + $menu_godmode['discover']['text'] = __('Discovery'); + $menu_godmode['discover']['sec2'] = 'godmode/servers/discovery'; + $menu_godmode['discover']['id'] = 'god-discovery'; + $menu_godmode['discover']['sub'] = $sub; +} + + $sub = []; if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'AD')) { $sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents'); @@ -200,6 +215,7 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, ' $menu_godmode['gservers']['id'] = 'god-servers'; $sub = []; + if (check_acl($config['id_user'], 0, 'AW')) { $sub['godmode/servers/modificar_server']['text'] = __('Manage servers'); $sub['godmode/servers/modificar_server']['id'] = 'Manage servers'; @@ -269,6 +285,9 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); + $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; + if ($config['activate_gis']) { $sub2['godmode/setup/gis']['text'] = __('Map conections GIS'); } diff --git a/pandora_console/godmode/modules/manage_network_components_form_network.php b/pandora_console/godmode/modules/manage_network_components_form_network.php index 329d8d1405..8befa28555 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_network.php +++ b/pandora_console/godmode/modules/manage_network_components_form_network.php @@ -57,16 +57,16 @@ $data = []; $data[0] = __('SNMP Enterprise String'); $data[1] = html_print_input_text('snmp_oid', $snmp_oid, '', 30, 400, true); // $table->colspan['snmp_2'][1] = 3; -$data[2] = __('SNMP community'); +$data[2] = __('SNMP community').ui_print_help_icon('column_macros', true); $data[3] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true); push_table_row($data, 'snmp_2'); $data = []; -$data[0] = __('Auth user'); +$data[0] = __('Auth user').ui_print_help_icon('column_macros', true); $data[1] = html_print_input_text('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); -$data[2] = __('Auth password'); +$data[2] = __('Auth password').ui_print_help_icon('column_macros', true); $data[3] = html_print_input_password('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); $data[3] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mncfn', true); push_table_row($data, 'field_snmpv3_row1'); @@ -74,7 +74,7 @@ push_table_row($data, 'field_snmpv3_row1'); $data = []; $data[0] = __('Privacy method'); $data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); -$data[2] = __('Privacy pass'); +$data[2] = __('Privacy pass').ui_print_help_icon('column_macros', true); $data[3] = html_print_input_password('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true); push_table_row($data, 'field_snmpv3_row2'); diff --git a/pandora_console/godmode/modules/manage_network_components_form_wmi.php b/pandora_console/godmode/modules/manage_network_components_form_wmi.php index 35b846250e..f88441f5d5 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_wmi.php +++ b/pandora_console/godmode/modules/manage_network_components_form_wmi.php @@ -44,9 +44,9 @@ $data[3] = html_print_input_text('tcp_send', $tcp_send, '', 25, 255, true); push_table_row($data, 'wmi_2'); $data = []; -$data[0] = __('Username'); +$data[0] = __('Username').ui_print_help_icon('column_macros', true); $data[1] = html_print_input_text('plugin_user', $plugin_user, '', 15, 255, true); -$data[2] = __('Password'); +$data[2] = __('Password').ui_print_help_icon('column_macros', true); $data[3] = html_print_input_password('plugin_pass', $plugin_pass, '', 25, 255, true); push_table_row($data, 'wmi_3'); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 38584d6b6a..aef5ac71a2 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -2720,7 +2720,7 @@ function edit_custom_graph() { } }); - window.location.href = server_url + "/index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data; + window.location.href = server_url + "index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index abab21b8fe..7253b931d4 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1116,8 +1116,13 @@ switch ($action) { $name_it = (string) get_parameter('name'); $values['name'] = reporting_label_macro($items_label, $name_it); - // Added support for projection graphs, prediction date and SLA reports - // 'top_n_value','top_n' and 'text' fields will be reused for these types of report + /* + Added support for projection graphs, + prediction date and SLA reports + 'top_n_value','top_n' and 'text' + fields will be reused for these types of report + */ + switch ($values['type']) { case 'projection_graph': $values['period'] = get_parameter('period1'); @@ -1127,7 +1132,8 @@ switch ($action) { break; case 'event_report_log': - $agents_to_report = get_parameter('id_agents2'); + + $agents_to_report = get_parameter('id_agents3'); $source = get_parameter('source', ''); $search = get_parameter('search', ''); $log_number = get_parameter('log_number', ''); @@ -1525,7 +1531,7 @@ switch ($action) { break; case 'event_report_log': - $agents_to_report = get_parameter('id_agents2'); + $agents_to_report = get_parameter('id_agents3'); $source = get_parameter('source', ''); $search = get_parameter('search', ''); $log_number = get_parameter('log_number', ''); @@ -1632,17 +1638,6 @@ switch ($action) { $values['server_name'] = get_parameter('combo_server'); } - - if (is_metaconsole()) { - // For SQL Query check if it is setted in the meta - if ($values['type'] == 'sql') { - if (empty($values['server_name'])) { - $good_format = false; - } - } - } - - $values['id_agent'] = get_parameter('id_agent'); $values['id_gs'] = get_parameter('id_custom_graph'); if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent') or ($values['type'] == 'agent_configuration') or ($values['type'] == 'group_configuration')) { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 1ab1916927..6744d2fb2d 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -231,6 +231,21 @@ function is_metaconsole() { else return false; } +function dialog_message(message_id) { + $(message_id) + .css("display", "inline") + .dialog({ + modal: true, + show: "blind", + hide: "blind", + buttons: { + Close: function() { + $(this).dialog("close"); + } + } + }); +} + function update_button_palette_callback() { var values = {}; @@ -240,14 +255,11 @@ function update_button_palette_callback() { switch (selectedItem) { case "background": if (values["width"] < 1024 || values["height"] < 768) { - alert("Min allowed size is 1024x768"); + dialog_message("#message_min_allowed_size"); return false; } - - if (values["width"] == 0 && values["height"] == 0) { - values["width"] = $("#hidden-background_original_width").val(); - values["height"] = $("#hidden-background_original_height").val(); - } + $("#hidden-background_width").val(values["width"]); + $("#hidden-background_height").val(values["height"]); $("#background").css("width", values["width"]); $("#background").css("height", values["height"]); @@ -259,11 +271,25 @@ function update_button_palette_callback() { break; case "box_item": if ($("input[name=width_box]").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); + return false; + } + if ( + parseInt($("input[name='width_box']").val()) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); return false; } if ($("input[name=height_box]").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + return false; + } + if ( + parseInt($("input[name='height_box']").val()) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_height"); return false; } @@ -288,7 +314,7 @@ function update_button_palette_callback() { values["label"] == "" && values["show_statistics"] == false ) { - alert("Undefined image"); + dialog_message("#message_alert_no_image"); return false; } @@ -428,18 +454,32 @@ function update_button_palette_callback() { break; case "static_graph": if ($("input[name=width]").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); + return false; + } + if ( + parseInt($("input[name='width']").val()) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); return false; } if ($("input[name=height]").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + return false; + } + if ( + parseInt($("input[name='height']").val()) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_height"); return false; } if ( (values["image"] == "" || values["image"] == "none") && values["label"] == "" ) { - alert("Undefined image"); + dialog_message("#message_alert_no_image"); return false; } @@ -555,13 +595,27 @@ function update_button_palette_callback() { break; case "percentile_bar": case "percentile_item": - if ($("input[name=width_percentile]").val() == "") { - alert("Undefined width"); + if ($("input[name=height_percentile]").val() == "") { + dialog_message("#message_alert_no_height"); return false; } - - if ($("input[name=height_percentile]").val() == "") { - alert("Undefined height"); + if ($("input[name=width_percentile]").val() == "") { + dialog_message("#message_alert_no_width"); + return false; + } + if ( + $("input[name=width_percentile]").val() > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + return false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); return false; } @@ -604,7 +658,6 @@ function update_button_palette_callback() { return false; } } - if ($("#dir_items").html() == "vertical") { if ( parseInt($("#text-top").val()) + @@ -621,20 +674,41 @@ function update_button_palette_callback() { return false; } } - + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + return false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); + return false; + } if ($("input[name=width_module_graph]").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); return false; } if ($("input[name=height_module_graph]").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + return false; + } + if ( + parseInt(values["width_module_graph"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + if ( + parseInt($("input[name=height_module_graph]").val()) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); return false; } if ( $("#custom_graph_row").css("display") != "none" && $("#custom_graph option:selected").html() == "None" ) { - alert("Undefined graph"); + dialog_message("#message_alert_no_custom_graph"); return false; } @@ -644,12 +718,19 @@ function update_button_palette_callback() { break; case "bars_graph": if ($("input[name=width_percentile]").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); return false; } - if ($("input[name=bars_graph_height]").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + return false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + return false; + } + if (values["agent_string"] == "") { + dialog_message("#message_alert_no_agent"); return false; } @@ -660,18 +741,48 @@ function update_button_palette_callback() { break; case "clock": + if ( + parseInt(values["width_percentile"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + $("#text_" + idItem).html(values["label"]); $("#image_" + idItem).attr("src", "images/spinner.gif"); setClock(idItem, values); break; case "auto_sla_graph": - if ($("input[name=width]").val() == "") { - alert("Undefined width"); + if (values["height"] == "") { + dialog_message("#message_alert_no_height"); return false; } - if ($("input[name=height]").val() == "") { - alert("Undefined height"); + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + return false; + } + if (values["width"] == "") { + dialog_message("#message_alert_no_width"); + return false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + return false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); return false; } $("#text_" + idItem).html(values["label"]); @@ -680,8 +791,22 @@ function update_button_palette_callback() { setEventsBar(idItem, values); break; case "donut_graph": + if ( + parseInt(values["width_percentile"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module_string_type"); + return false; + } + if (values["agent_string"] == "") { + dialog_message("#message_alert_no_agent"); + return false; + } $("#image_" + idItem).attr("src", "images/spinner.gif"); - setDonutsGraph(idItem, values); break; case "simple_value": @@ -718,21 +843,47 @@ function update_button_palette_callback() { "" ); } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + return false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); + return false; + } break; case "label": + if (values["label"] == "") { + dialog_message("#message_alert_no_label"); + return false; + } $("#text_" + idItem).html(values["label"]); break; case "icon": if ($("input[name=width]").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); + return false; + } + if ( + parseInt($("input[name=width]").val()) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); return false; } if ($("input[name=height]").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + return false; + } + if ( + parseInt($("input[name=height]").val()) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); return false; } if (values["image"] == "" || values["image"] == "none") { - alert("Undefined image"); + dialog_message("#message_alert_no_image"); return false; } $("#image_" + idItem).attr("src", "images/spinner.gif"); @@ -779,13 +930,70 @@ function update_button_palette_callback() { var image = values["image"] + ".png"; set_image("image", idItem, image); break; + case "line_item": + if ( + parseInt(values["line_width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + break; + case "color_cloud": + if ( + parseInt(values["diameter"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + return false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + return false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); + return false; + } + break; + case "service": + if (values["height"] == "" || values["height_module_graph"] == 0) { + dialog_message("#message_alert_no_height"); + return false; + } + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + return false; + } + if (values["width"] == "" || values["width_module_graph"] == 0) { + dialog_message("#message_alert_no_width"); + return false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + return false; + } + if ( + $("select[name=service]").val() == "" || + $("select[name=service]").val() == "none" + ) { + dialog_message("#message_alert_no_service"); + return false; + } + break; default: if ($("input[name=width]").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); return false; } if ($("input[name=height]").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); return false; } //Maybe save in any Enterprise item. @@ -1018,149 +1226,356 @@ function create_button_palette_callback() { switch (creationItem) { case "box_item": if ($("input[name='width_box']").val() == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt($("input[name='width_box']").val()) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); validate = false; } if ($("input[name='height_box']").val() == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + validate = false; + } + if ( + parseInt($("input[name='height_box']").val()) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); validate = false; } break; case "group_item": + if (values["height"] == "") { + dialog_message("#message_alert_no_height"); + validate = false; + } + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + validate = false; + } + if (values["width"] == "") { + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } if ( (values["image"] == "" || values["image"] == "none") && values["label"] == "" && values["show_statistics"] == false ) { - alert("Undefined images"); + dialog_message("#message_alert_no_image"); validate = false; } break; case "static_graph": - if (values["width"] == "") { - alert("Undefined width"); + if (values["height"] == "") { + dialog_message("#message_alert_no_height"); validate = false; } - if (values["height"] == "") { - alert("Undefined height"); + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + validate = false; + } + if (values["width"] == "") { + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); validate = false; } if ( (values["image"] == "" || values["image"] == "none") && values["label"] == false ) { - alert("Undefined image"); + dialog_message("#message_alert_no_image"); validate = false; } break; case "auto_sla_graph": + if (values["height"] == "") { + dialog_message("#message_alert_no_height"); + validate = false; + } + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + validate = false; + } + if (values["width"] == "") { + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + validate = false; + } if (values["agent"] == "") { - alert($("#message_alert_no_agent").html()); + dialog_message("#message_alert_no_agent"); validate = false; } break; case "donut_graph": + if ( + parseInt(values["width_percentile"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module_string_type"); + validate = false; + } if (values["agent_string"] == "") { - alert($("#message_alert_no_agent").html()); + dialog_message("#message_alert_no_agent"); validate = false; } break; case "label": if (values["label"] == "") { - alert($("#message_alert_no_label").html()); + dialog_message("#message_alert_no_label"); validate = false; } break; case "icon": if (values["width"] == "") { - alert("Undefined width"); + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); validate = false; } if (values["height"] == "") { - alert("Undefined height"); + dialog_message("#message_alert_no_height"); + validate = false; + } + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); validate = false; } if (values["image"] == "" || values["image"] == "none") { - alert($("#message_alert_no_image").html()); + dialog_message("#message_alert_no_image"); validate = false; } break; case "percentile_bar": case "percentile_item": - if (values["width"] == "") { - alert("Undefined width"); - validate = false; - } - if (values["agent"] == "") { - alert($("#message_alert_no_agent").html()); - validate = false; - } - if (values["module"] == 0) { - alert($("#message_alert_no_module").html()); - validate = false; - } - if (values["max_percentile"] == "") { - alert($("#message_alert_no_max_percentile").html()); + if ( + parseInt(values["width_percentile"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); validate = false; } if (values["width_percentile"] == "") { - alert($("#message_alert_no_width_percentile").html()); + dialog_message("#message_alert_no_width"); validate = false; } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + validate = false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); + validate = false; + } + + if (values["max_percentile"] == "") { + dialog_message("#message_alert_no_max_percentile"); + validate = false; + } + break; case "module_graph": - if (values["width_module_graph"] == "") { - alert("Undefined width"); - validate = false; - } - if (values["height_module_graph"] == "") { - alert("Undefined height"); + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); validate = false; } if (values["id_custom_graph"] == 0) { if (values["agent"] == "") { - alert($("#message_alert_no_agent").html()); - validate = false; - } - if (values["module"] == 0) { - alert($("#message_alert_no_module").html()); + dialog_message("#message_alert_no_agent"); validate = false; } if (values["period"] == 0) { - alert($("#message_alert_no_period").html()); + dialog_message("#message_alert_no_period"); validate = false; } } - break; - case "bars_graph": - if (values["agent_string"] == "") { - alert($("#message_alert_no_agent").html()); + if ( + values["height_module_graph"] == "" || + values["height_module_graph"] == 0 + ) { + dialog_message("#message_alert_no_height"); validate = false; } - if (values["module"] == 0) { - alert($("#message_alert_no_module").html()); + if ( + parseInt(values["height_module_graph"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + validate = false; + } + if ( + values["width_module_graph"] == "" || + values["width_module_graph"] == 0 + ) { + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt(values["width_module_graph"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + break; + case "bars_graph": + if (values["bars_graph_height"] == "") { + dialog_message("#message_alert_no_height"); + validate = false; + } + if ( + parseInt(values["bars_graph_height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); validate = false; } if (values["width_percentile"] == "") { - alert($("#message_alert_no_width_percentile").html()); + dialog_message("#message_alert_no_width"); validate = false; } - if (values["bars_graph_height"] == "") { - alert($("#message_alert_no_bars_graph_height").html()); + if ( + parseInt(values["width_percentile"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + validate = false; + } + if (values["agent_string"] == "") { + dialog_message("#message_alert_no_agent"); validate = false; } break; case "simple_value": - if (values["agent"] == "") { - alert($("#message_alert_no_agent").html()); + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); validate = false; } - if (values["module"] == 0) { - alert($("#message_alert_no_module").html()); + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); validate = false; } break; + case "clock": + if ( + parseInt(values["width_percentile"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + break; + case "line_item": + if ( + parseInt(values["line_width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + break; + case "color_cloud": + if ( + parseInt(values["diameter"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + validate = false; + } + if (values["module"] == 0) { + dialog_message("#message_alert_no_module"); + validate = false; + } + if (values["agent"] == "") { + dialog_message("#message_alert_no_agent"); + validate = false; + } + break; + case "service": + if (values["height"] == "" || values["height_module_graph"] == 0) { + dialog_message("#message_alert_no_height"); + validate = false; + } + if ( + parseInt(values["height"]) > + parseInt($("#hidden-background_height").val()) + ) { + dialog_message("#message_alert_max_height"); + validate = false; + } + if (values["width"] == "" || values["width_module_graph"] == 0) { + dialog_message("#message_alert_no_width"); + validate = false; + } + if ( + parseInt(values["width"]) > + parseInt($("#hidden-background_width").val()) + ) { + dialog_message("#message_alert_max_width"); + validate = false; + } + if ( + $("select[name=service]").val() == "" || + $("select[name=service]").val() == "none" + ) { + dialog_message("#message_alert_no_service"); + validate = false; + } + break; + default: //Maybe save in any Enterprise item. if (typeof enterprise_create_button_palette_callback == "function") { @@ -3714,17 +4129,7 @@ function createItem(type, values, id_data) { .attr("height", values["height"]); } } - // else{ - // $('#image_'+id_data).css('width', values['width']+'px'); - // $('#image_'+id_data).css('height', values['height']+'px'); - // } - /* - var $span = $('') - .attr('id', 'text_' + id_data) - .attr('class', 'text') - .append(values['label']); - -*/ + var $input = $("") .attr("id", "hidden-status_" + id_data) .attr("type", "hidden") @@ -4489,7 +4894,6 @@ function createItem(type, values, id_data) { case "clock": sizeStyle = ""; imageSize = ""; - if (values["label_position"] == "up") { item = $( '
'; echo '
'; diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 7f88982a14..6ee8577367 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -122,6 +122,12 @@ $buttons['ehorus'] = [ 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', ]; +// FIXME: Not definitive icon +$buttons['notifications'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'', +]; + $help_header = ''; if (enterprise_installed()) { $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); @@ -159,6 +165,11 @@ switch ($section) { $buttons['ehorus']['active'] = true; $subpage = ' » '.__('eHorus'); break; + + case 'notifications': + $buttons['notifications']['active'] = true; + $subpage = ' » '.__('Notifications'); + break; } // Header. @@ -199,6 +210,10 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; + case 'notifications': + include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; + break; + default: enterprise_hook('setup_enterprise_select_tab', [$section]); break; diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 4d5eeb07ff..3ff5cb305b 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -134,7 +134,8 @@ if (is_ajax()) { set_unless_defined($config['double_auth_enabled'], false); $row = []; $row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true); - $row['control'] = html_print_checkbox_toogle_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true); + $row['control'] = html_print_input_hidden('double_auth_enabled', 0); + $row['control'] .= html_print_checkbox_toogle_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true); $table->data['double_auth_enabled'] = $row; // Session timeout diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 8196d98873..9cac70c763 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -269,7 +269,13 @@ $table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory $table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); $table->data[38][0] = __('Set alias as name by default in agent creation'); -$table->data[38][1] = html_print_checkbox_toogle_switch('alias_as_name', 1, $config['alias_as_name'], true); +$table->data[38][1] = __('Yes').'   '.html_print_radio_button('alias_as_name', 1, '', $config['alias_as_name'], true).'  '; +$table->data[38][1] .= __('No').'   '.html_print_radio_button('alias_as_name', 0, '', $config['alias_as_name'], true); + +$table->data[39][0] = __('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true); +$table->data[39][1] = __('Yes').'   '.html_print_radio_button('unique_ip', 1, '', $config['unique_ip'], true).'  '; +$table->data[39][1] .= __('No').'   '.html_print_radio_button('unique_ip', 0, '', $config['unique_ip'], true); + echo '
'; echo '
'; @@ -332,6 +338,11 @@ $(document).ready (function () { $("#zone").attr("hidden", false); $("#timezone").attr("hidden", false); }); + + if ($("input[name=use_cert]").is(':checked')) { + $('#setup_general-13').show(); + } + $("input[name=use_cert]").change(function () { if( $(this).is(":checked") ) $('#setup_general-13').show(); diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php new file mode 100644 index 0000000000..9ee95f78cc --- /dev/null +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -0,0 +1,413 @@ + $res]; + echo json_encode($result); + return; +} + +if (get_parameter('remove_source_on_database', 0)) { + $res = ($is_users) ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements); + $result = ['result' => $res]; + echo json_encode($result); + return; +} + +if (get_parameter('update_config', 0)) { + $element = (string) get_parameter('element', ''); + $value = (int) get_parameter('value', 0); + + // Update the label value. + ob_clean(); + $res = false; + switch ($element) { + // All users has other action. + case 'all_users': + $res = ($value) ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]); + break; + + default: + $res = (bool) db_process_sql_update( + 'tnotification_source', + [$element => $value], + ['id' => $source] + ); + break; + } + + echo json_encode(['result' => $res]); + return; +} + +if (get_parameter('check_new_notifications', 0)) { + $last_id_ui = (int) get_parameter('last_id', 0); + $counters = notifications_get_counters(); + if ((int) $last_id_ui === (int) $counters['last_id']) { + echo json_encode(['has_new_notifications' => false]); + return; + } + + if (messages_get_count() == 0) { + return; + } + + $messages = messages_get_overview( + 'timestamp', + 'ASC', + false, + true, + 0, + ['id_mensaje' => '>'.$last_id_ui] + ); + if ($messages === false) { + $messages = []; + } + + // If there is new messages, get the info. + echo json_encode( + [ + 'has_new_notifications' => true, + 'new_ball' => base64_encode( + notifications_print_ball( + $counters['notifications'], + $counters['last_id'] + ) + ), + 'new_notifications' => array_map( + function ($elem) { + $elem['full_url'] = messages_get_url($elem['id_mensaje']); + return $elem; + }, + $messages + ), + ] + ); + return; +} + +if (get_parameter('mark_notification_as_read', 0)) { + $message = (int) get_parameter('message', 0); + messages_process_read($message); + // TODO check read. + $url = messages_get_url($message); + // Return false if cannot get the URL. + if ($url === false) { + echo json_encode(['result' => false]); + return; + } + + // If there is new messages, get the info. + echo json_encode( + [ + 'result' => true, + 'url' => $url, + ] + ); + return; +} + +if (get_parameter('get_notifications_dropdown', 0)) { + echo notifications_print_dropdown(); + return; +} + +// Notification table. It is just a wrapper. +$table_content = new StdClass(); +$table_content->data = []; +$table_content->width = '100%'; +$table_content->id = 'notifications-wrapper'; +$table_content->class = 'databox filters'; +$table_content->size['name'] = '30%'; + +// Print each source configuration. +$table_content->data = array_map( + function ($source) { + return notifications_print_global_source_configuration($source); + }, + notifications_get_all_sources() +); + +html_print_table($table_content); + +?> + diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index c4d09fd75c..677a283854 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -751,7 +751,7 @@ if ($create_alert || $update_alert) { // echo '' . __('Alert filters') . ui_print_help_icon("snmp_alert_filters", true) . ''; // OID - echo ''.''.__('Enterprise String').''.''; + echo ''.''.__('Enterprise String').ui_print_help_tip(__('Matches substrings. End the string with $ for exact matches.'), true).''.''; html_print_input_text('oid', $oid, '', 50, 255); echo ''; diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php new file mode 100644 index 0000000000..9f7c416854 --- /dev/null +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -0,0 +1,984 @@ +setBreadcrum([]); + + $this->task = []; + $this->msg = $msg; + $this->icon = $icon; + $this->label = __($label); + $this->page = $page; + $this->url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist' + ); + + return $this; + } + + + /** + * Implements run method. + * + * @return mixed Returns null if wizard is ongoing. Result if done. + */ + public function run($message='', $status=null) + { + global $config; + // Load styles. + parent::run(); + + $this->prepareBreadcrum( + [ + [ + 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery', + 'label' => 'Discovery', + ], + ] + ); + + $this->printHeader(); + + // Show redirected messages from discovery.php. + if ($status === 0) { + ui_print_success_message($message); + } else if ($status !== null) { + ui_print_error_message($message); + } + + $force_run = (bool) get_parameter('force_run'); + if ($force_run === true) { + return $this->forceConsoleTask(); + } + + $delete_console_task = (bool) get_parameter('delete_console_task'); + if ($delete_console_task === true) { + return $this->deleteConsoleTask(); + } + + $delete = (bool) get_parameter('delete', false); + if ($delete === true) { + return $this->deleteTask(); + } + + if (enterprise_installed()) { + // This check only applies to enterprise users. + // Check if DiscoveryCronTasks is running. Warn user if not. + if ($config['cron_last_run'] == 0 + || (get_system_time() - $config['cron_last_run']) > 3600 + ) { + $message_conf_cron = __('DiscoveryConsoleTasks is not running properly').'. '; + if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { + $message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service'); + $message_conf_cron .= '. '.__('Please, add the following line to your crontab file:'); + $message_conf_cron .= '
* * * * * <user> wget -q -O - --no-check-certificate ';
+                    $message_conf_cron .= str_replace(
+                        ENTERPRISE_DIR.'/meta/',
+                        '',
+                        ui_get_full_url(false)
+                    );
+                    $message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
+                    $message_conf_cron .= '/cron/cron.php >> ';
+                    $message_conf_cron .= $config['homedir'].'/pandora_console.log
'; + } + + if (isset($config['cron_last_run']) === true + && $config['cron_last_run'] > 0 + ) { + $message_conf_cron .= '

'.__('Last execution').': '; + $message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']).'

'; + $message_conf_cron .= '

'; + $message_conf_cron .= __('Please check process is no locked.').'

'; + } + + ui_print_warning_message($message_conf_cron, '', false); + } + } + + $ret = $this->showListConsoleTask(); + $ret2 = $this->showList(); + + if ($ret === false && $ret2 === false) { + include_once $config['homedir'].'/general/firts_task/recon_view.php'; + } + + return $ret; + } + + + /** + * Implements load method. + * + * @return mixed Skeleton for button. + */ + public function load() + { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + + ]; + + } + + + /** + * Delete a recon task. + * + * @return void + */ + public function deleteTask() + { + global $config; + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $task = get_parameter('task', null); + + if ($task !== null) { + $result = db_process_sql_delete( + 'trecon_task', + ['id_rt' => $task] + ); + + if ($result == 1) { + return [ + 'result' => 0, + 'msg' => __('Task successfully deleted'), + 'id' => false, + ]; + } + + // Trick to avoid double execution. + header('Location: '.$this->url); + } + + } + + + /** + * Force console task. + * + * @return void + */ + public function forceConsoleTask() + { + global $config; + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $id_console_task = (int) get_parameter('id_console_task'); + + if ($id_console_task !== null) { + cron_task_run($id_console_task, true); + // Trick to avoid double execution. + header('Location: '.$this->url); + } + + } + + + /** + * Delete a Console task. + * + * @return void + */ + public function deleteConsoleTask() + { + global $config; + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $id_console_task = (int) get_parameter('id_console_task'); + + if ($id_console_task !== null) { + $result = db_process_sql_delete( + 'tuser_task_scheduled', + ['id' => $id_console_task] + ); + + if ($result == 1) { + return [ + 'result' => 0, + 'msg' => __('Console Task successfully deleted'), + 'id' => false, + ]; + } + + // Trick to avoid double execution. + header('Location: '.$this->url); + } + + } + + + /** + * Show complete list of running tasks. + * + * @return boolean Success or not. + */ + public function showList() + { + global $config; + + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return false; + } + + // Get all recon servers. + $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3'); + if ($servers === false) { + $servers = []; + ui_print_error_message(__('Discovery Server is disabled')); + return false; + } else { + $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); + if ($recon_task === false) { + return false; + } else { + include_once $config['homedir'].'/include/functions_graph.php'; + include_once $config['homedir'].'/include/functions_servers.php'; + include_once $config['homedir'].'/include/functions_network_profiles.php'; + + $modules_server = 0; + $total_modules = 0; + $total_modules_data = 0; + + // -------------------------------- + // FORCE A RECON TASK + // -------------------------------- + if (check_acl($config['id_user'], 0, 'PM')) { + if (isset($_GET['force'])) { + $id = (int) get_parameter_get('force', 0); + servers_force_recon_task($id); + header( + 'Location: '.ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist' + ) + ); + } + } + + foreach ($servers as $serverItem) { + $id_server = $serverItem['id_server']; + $server_name = servers_get_name($id_server); + $recon_tasks = db_get_all_rows_field_filter( + 'trecon_task', + 'id_recon_server', + $id_server + ); + + $user_groups = implode(',', array_keys(users_get_groups())); + $defined_tasks = db_get_all_rows_filter( + 'tuser_task_scheduled', + 'id_grupo IN ('.$user_groups.')' + ); + + if (isset($tasks_console) === true + && is_array($tasks_console) === true + ) { + foreach ($tasks_console as $key => $value) { + $value['parameters'] = unserialize( + $value['parameters'] + ); + + $value['type'] = 'Cron'; + array_push($recon_tasks, $value); + } + } + + // Show network tasks for Recon Server. + if ($recon_tasks === false) { + $recon_tasks = []; + } + + $table = new StdClass(); + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->width = '100%'; + $table->class = 'databox data'; + $table->head = []; + $table->data = []; + $table->align = []; + $table->headstyle = []; + for ($i = 0; $i < 9; $i++) { + $table->headstyle[$i] = 'text-align: left;'; + } + + $table->head[0] = __('Force'); + $table->align[0] = 'left'; + + $table->head[1] = __('Task name'); + $table->align[1] = 'left'; + + $table->head[2] = __('Interval'); + $table->align[2] = 'left'; + + $table->head[3] = __('Network'); + $table->align[3] = 'left'; + + $table->head[4] = __('Status'); + $table->align[4] = 'left'; + + $table->head[5] = __('Task type'); + $table->align[5] = 'left'; + + $table->head[6] = __('Progress'); + $table->align[6] = 'left'; + + $table->head[7] = __('Updated at'); + $table->align[7] = 'left'; + + $table->head[8] = __('Operations'); + $table->align[8] = 'left'; + + foreach ($recon_tasks as $task) { + $data = []; + + if ($task['disabled'] == 0) { + $data[0] = ''; + $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); + $data[0] .= ''; + } else if ($task['disabled'] == 2) { + $data[0] = ui_print_help_tip( + __('This task has not been completely defined, please edit it'), + true + ); + } else { + $data[0] = ''; + } + + $data[1] = ''.$task['name'].''; + + if ($task['interval_sweep'] > 0) { + $data[2] = human_time_description_raw( + $task['interval_sweep'] + ); + } else { + $data[2] = __('Manual'); + } + + if ($task['id_recon_script'] == 0) { + $data[3] = $task['subnet']; + } else { + $data[3] = '-'; + } + + if ($task['status'] <= 0) { + $data[4] = __('Done'); + } else { + $data[4] = __('Pending'); + } + + if ($task['id_recon_script'] == 0) { + // Discovery NetScan. + $data[5] = html_print_image( + 'images/network.png', + true, + ['title' => __('Discovery NetScan')] + ).'  '; + $data[5] .= network_profiles_get_name( + $task['id_network_profile'] + ); + } else { + // APP recon task. + $data[5] = html_print_image( + 'images/plugin.png', + true + ).'  '; + $data[5] .= db_get_sql( + sprintf( + 'SELECT name FROM trecon_script WHERE id_recon_script = %d', + $task['id_recon_script'] + ) + ); + } + + if ($task['status'] <= 0 || $task['status'] > 100) { + $data[6] = '-'; + } else { + $data[6] = progress_bar( + $task['status'], + 100, + 20, + __('Progress').':'.$task['status'].'%', + 1 + ); + } + + if ($task['utimestamp'] > 0) { + $data[7] = ui_print_timestamp( + $task['utimestamp'], + true + ); + } else { + $data[7] = __('Not executed yet'); + } + + if (check_acl( + $config['id_user'], + $task['id_group'], + 'PM' + ) + ) { + // Check if is a H&D, Cloud or Application. + $data[8] = ''.html_print_image( + 'images/config.png', + true + ).''; + $data[8] .= ''.html_print_image( + 'images/cross.png', + true + ).''; + } else { + $data[8] = ''; + } + + array_push($table->data, $data); + } + + if (empty($table->data)) { + echo '
'.__('Server').' '.$server_name.' '.__('has no recon tasks assigned').'
'; + } else { + echo '

'.__('Server task').'

'; + html_print_table($table); + } + + unset($table); + } + } + } + + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ), + ], + 'inputs' => [ + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + + return true; + } + + + /** + * Show complete list of running tasks. + * + * @return boolean Success or not. + */ + public function showListConsoleTask() + { + global $config; + + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return false; + } + + $read_perms = check_acl( + $config['id_user'], + 0, + 'RR' + ); + $write_perms = check_acl( + $config['id_user'], + 0, + 'RW' + ); + $manage_perms = check_acl( + $config['id_user'], + 0, + 'RM' + ); + $manage_pandora = check_acl( + $config['id_user'], + 0, + 'PM' + ); + + $url = 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&'; + + $user_groups = implode( + ',', + array_keys(users_get_groups()) + ); + + $defined_tasks = db_get_all_rows_filter( + 'tuser_task_scheduled', + 'id_grupo IN ('.$user_groups.')' + ); + + if (!check_acl($config['id_user'], 0, 'PM')) { + $read_tasks = []; + foreach ($defined_tasks as $task) { + $function_name = db_get_value( + 'function_name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + if (($function_name != 'cron_task_execute_custom_script') + && ($function_name != 'cron_task_do_backup') + ) { + $read_tasks[] = $task; + } + } + + $defined_tasks = $read_tasks; + + if (empty($defined_tasks)) { + $defined_tasks = false; + } + } + + if ($defined_tasks !== false) { + echo '

'.__('Console task').'

'; + + $table = new stdClass(); + $table->class = 'databox data'; + $table->width = '100%'; + $table->data = []; + $table->head = []; + $table->head[0] = ''; + $table->head[1] = __('User'); + $table->head[2] = __('Task'); + $table->head[3] = __('Scheduled'); + $table->head[4] = __('Next execution'); + $table->head[5] = __('Last run'); + $table->head[6] = __('Group'); + $table->head[7] = __('Operations'); + $table->align[7] = 'left'; + + foreach ($defined_tasks as $task) { + $data = []; + + $function_name = db_get_value( + 'function_name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + switch ($function_name) { + case 'cron_task_generate_report': + if ($write_perms || $manage_pandora) { + $data[0] = ''; + $data[0] .= html_print_image( + 'images/target.png', + true, + ['title' => __('Force run')] + ); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = $task['id_usuario']; + $data[2] = db_get_value( + 'name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + $args = unserialize($task['args']); + $report = reports_get_report($args[0]); + + // Check ACL in reports_get_report return false. + if ($report === false) { + continue; + } + + $email = $args[1]; + $data[2] .= '
- '.__('Report').": "; + $data[2] .= $report['name'].''; + $data[2] .= '
- '.__('Email').": "; + $data[2] .= ui_print_truncate_text( + $email, + 60, + false + ).''; + break; + + case 'cron_task_generate_report_by_template': + if ($write_perms || $manage_pandora) { + $data[0] = ''; + $data[0] .= html_print_image( + 'images/target.png', + true, + ['title' => __('Force run')] + ); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = $task['id_usuario']; + $data[2] = db_get_value( + 'name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + $args = unserialize($task['args']); + + $filter = []; + $filter['id_report'] = $args[0]; + $template = db_get_row_filter( + 'treport_template', + $filter, + false + ); + + // Check ACL in reports_get_report return false. + if ($template === false) { + continue; + } + + $agents_id = $args[1]; + $id_group = $args[2]; + $report_per_agent = $args[0]; + $report_name = $args[3]; + $email = $args[4]; + $data[2] .= '
- '.__('Template').": ".$template['name'].''; + $data[2] .= '
- '.__('Agents').': '.$agents_id.''; + $data[2] .= '
- '.__('Report per agent').': '.$report_per_agent.''; + $data[2] .= '
- '.__('Report name').': '.$report_name.''; + $data[2] .= '
- '.__('Email').": ".$email.''; + break; + + case 'cron_task_execute_custom_script': + if ($manage_pandora) { + $data[0] = ''; + $data[0] .= html_print_image( + 'images/target.png', + true, + ['title' => __('Force run')] + ); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = $task['id_usuario']; + $data[2] = db_get_value( + 'name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + $args = unserialize($task['args']); + $data[2] .= '
- '.__('Custom script').': '.$args[0]; + break; + + case 'cron_task_save_report_to_disk': + if ($write_perms || $manage_pandora) { + $data[0] = ''; + $data[0] .= html_print_image( + 'images/target.png', + true, + ['title' => __('Force run')] + ); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = $task['id_usuario']; + $data[2] = db_get_value( + 'name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + $args = unserialize($task['args']); + $report = reports_get_report($args[0]); + + // Check ACL in reports_get_report return false. + if ($report === false) { + continue; + } + + $path = $args[1]; + $data[2] .= '
- '.__('Report').": ".$report['name'].''; + $data[2] .= '
- '.__('Path').': '.$path.''; + break; + + case 'cron_task_save_xml_report_to_disk': + if ($write_perms || $manage_pandora) { + $data[0] = ''; + $data[0] .= html_print_image( + 'images/target.png', + true, + ['title' => __('Force run')] + ); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = $task['id_usuario']; + $data[2] = db_get_value('name', 'tuser_task', 'id', $task['id_user_task']); + $args = unserialize($task['args']); + $report = reports_get_report($args[0]); + + // Check ACL in reports_get_report return false. + if ($report === false) { + continue; + } + + $path = $args[1]; + $data[2] .= '
- '.__('Report').": ".$report['name'].''; + $data[2] .= '
- '.__('Path').': '.$path.''; + break; + + case 'cron_task_do_backup': + if ($manage_pandora) { + $data[0] = ''; + $data[0] .= html_print_image( + 'images/target.png', + true, + ['title' => __('Force run')] + ); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = $task['id_usuario']; + $data[2] = db_get_value( + 'name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + $args = unserialize($task['args']); + break; + + default: + // Ignore. + break; + } + + $data[3] = cron_get_scheduled_string($task['scheduled']); + $data[4] = date('Y/m/d H:i:s', $args['first_execution']); + $data[5] = empty($task['last_run']) ? __('Never') : date('Y/m/d H:i:s', $task['last_run']); + + $data[6] = ui_print_group_icon($task['id_grupo'], true); + + if ($function_name == 'cron_task_do_backup' || $function_name == 'cron_task_execute_custom_script') { + if ($manage_pandora) { + $data[7] = ''; + $data[7] .= html_print_image( + 'images/config.png', + true, + ['title' => __('Edit')] + ).''; + } + + if ($manage_pandora) { + $data[7] .= ''; + $data[7] .= html_print_image( + 'images/cross.png', + true, + ['title' => __('Delete')] + ); + $data[7] .= ''; + } + } else { + if ($write_perms || $manage_pandora) { + $data[7] = ''; + $data[7] .= html_print_image( + 'images/config.png', + true, + ['title' => __('Edit')] + ).''; + } + + if ($manage_perms || $manage_pandora) { + $data[7] .= ''; + $data[7] .= html_print_image( + 'images/cross.png', + true, + ['title' => __('Delete')] + ); + $data[7] .= ''; + } + } + + array_push($table->data, $data); + } + + html_print_table($table); + } else { + return false; + } + + return true; + } + + + /** + * Return target url sub-string to edit target task. + * + * @param array $task With all data. + * + * @return string + */ + public function getTargetWiz($task) + { + // TODO: Do not use description. Use recon_script ID instead. + switch ($task['description']) { + case 'Discovery.Application.VMware': + return 'wiz=app&mode=vmware&page=0'; + + case CLOUDWIZARD_AWS_DESCRIPTION: + return 'wiz=cloud&mode=amazonws&page=1'; + + case 'console_task': + return 'wiz=ctask'; + + default: + return 'wiz=hd&mode=netscan'; + } + } + + +} diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php new file mode 100755 index 0000000000..aa5c94666c --- /dev/null +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -0,0 +1,1134 @@ +setBreadcrum([]); + + $this->task = []; + $this->msg = $msg; + $this->icon = $icon; + $this->label = $label; + $this->page = $page; + $this->url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd' + ); + + return $this; + } + + + /** + * Run wizard manager. + * + * @return mixed Returns null if wizard is ongoing. Result if done. + */ + public function run() + { + global $config; + + // Load styles. + parent::run(); + + $mode = get_parameter('mode', null); + + if ($mode === null) { + $buttons = []; + $buttons[] = [ + 'url' => $this->url.'&mode=netscan', + 'icon' => 'images/wizard/netscan.png', + 'label' => __('Net Scan'), + ]; + if (enterprise_installed()) { + $buttons[] = [ + 'url' => $this->url.'&mode=importcsv', + 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png', + 'label' => __('Import CSV'), + ]; + } + + $this->prepareBreadcrum( + [ + [ + 'link' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ), + 'label' => __('Discovery'), + ], + ] + ); + + $this->printHeader(); + + $this->printBigButtonsList($buttons); + return; + } + + if (enterprise_installed()) { + if ($mode == 'importcsv') { + $csv_importer = new CSVImportAgents($this->page, $this->breadcrum); + return $csv_importer->runCSV(); + } + } + + if ($mode == 'netscan') { + return $this->runNetScan(); + } + + return null; + } + + + // Extra methods. + + + /** + * Retrieves and validates information given by user in NetScan wizard. + * + * @return boolean Data OK or not. + */ + public function parseNetScan() + { + if ($this->page == 0) { + // Check if we're updating a task. + $task_id = get_parameter('task', null); + + if (isset($task_id) === true) { + // We're updating this task. + $task = db_get_row( + 'trecon_task', + 'id_rt', + $task_id + ); + + if ($task !== false) { + $this->task = $task; + } + } + + return true; + } + + // Validate response from page 0. No, not a bug, we're always 1 page + // from 'validation' page. + if ($this->page == 1) { + $task_id = get_parameter('task', null); + $taskname = get_parameter('taskname', ''); + $comment = get_parameter('comment', ''); + $server_id = get_parameter('id_recon_server', ''); + $network = get_parameter('network', ''); + $id_group = get_parameter('id_group', ''); + $interval = get_parameter('interval', 0); + + if (isset($task_id) === true) { + // We're updating this task. + $task = db_get_row( + 'trecon_task', + 'id_rt', + $task_id + ); + + if ($task !== false) { + $this->task = $task; + } + } else if (isset($taskname) === true + && isset($network) === true + ) { + // Avoid double creation. + $task = db_get_row_filter( + 'trecon_task', + [ + 'name' => $taskname, + 'subnet' => $network, + ] + ); + + if ($task !== false) { + $this->task = $task; + $this->msg = __('This network scan task has been already defined. Please edit it or create a new one.'); + return false; + } + } + + if ($task_id !== null + && $taskname == null + && $server_id == null + && $id_group == null + && $server == null + && $datacenter == '' + && $user == '' + && $pass == '' + && $encrypt == null + && $interval == 0 + ) { + // Default values, no data received. + // User is accesing directly to this page. + if (users_is_admin() !== true && check_acl( + $config['id_usuario'], + $this->task['id_group'], + 'PM' + ) !== true + ) { + $this->msg = __('You have no access to edit this task.'); + return false; + } + } else { + if (isset($this->task['id_rt']) === false) { + // Disabled 2 Implies wizard non finished. + $this->task['disabled'] = 2; + } + + if ($taskname == '') { + $this->msg = __('You must provide a task name.'); + return false; + } + + if ($server_id == '') { + $this->msg = __('You must select a Discovery Server.'); + return false; + } + + if ($network == '') { + // XXX: Could be improved validating provided network. + $this->msg = __('You must provide a valid network.'); + return false; + } + + if ($id_group == '') { + $this->msg = __('You must select a valid group.'); + return false; + } + + // Assign fields. + $this->task['name'] = $taskname; + $this->task['description'] = $comment; + $this->task['subnet'] = $network; + $this->task['id_recon_server'] = $server_id; + $this->task['id_group'] = $id_group; + $this->task['interval_sweep'] = $interval; + + if (isset($this->task['id_rt']) === false) { + // Create. + $this->task['id_rt'] = db_process_sql_insert( + 'trecon_task', + $this->task + ); + } else { + // Update. + db_process_sql_update( + 'trecon_task', + $this->task, + ['id_rt' => $this->task['id_rt']] + ); + } + } + + return true; + } + + // Validate response from page 1. + if ($this->page == 2) { + $id_rt = get_parameter('task', -1); + + $task = db_get_row( + 'trecon_task', + 'id_rt', + $id_rt + ); + + if ($task !== false) { + $this->task = $task; + } else { + $this->msg = __('Failed to find network scan task.'); + return false; + } + + $id_network_profile = get_parameter('id_network_profile', null); + $autoconf_enabled = get_parameter_switch( + 'autoconfiguration_enabled' + ); + $snmp_enabled = get_parameter_switch('snmp_enabled'); + $os_detect = get_parameter_switch('os_detect'); + $parent_detection = get_parameter_switch('parent_detection'); + $parent_recursion = get_parameter_switch('parent_recursion'); + $vlan_enabled = get_parameter_switch('vlan_enabled'); + $wmi_enabled = get_parameter_switch('wmi_enabled'); + $resolve_names = get_parameter_switch('resolve_names'); + $snmp_version = get_parameter('snmp_version', null); + $community = get_parameter('community', null); + $snmp_context = get_parameter('snmp_context', null); + $snmp_auth_user = get_parameter('snmp_auth_user', null); + $snmp_auth_pass = get_parameter('snmp_auth_pass', null); + $snmp_privacy_method = get_parameter('snmp_privacy_method', null); + $snmp_privacy_pass = get_parameter('snmp_privacy_pass', null); + $snmp_auth_method = get_parameter('snmp_auth_method', null); + $snmp_security_level = get_parameter('snmp_security_level', null); + $auth_strings = get_parameter('auth_strings', null); + + if ($snmp_version == 3) { + $this->task['snmp_community'] = $snmp_context; + } else { + $this->task['snmp_community'] = $community; + } + + $this->task['autoconfiguration_enabled'] = $autoconf_enabled; + $this->task['id_network_profile'] = $id_network_profile; + $this->task['snmp_enabled'] = $snmp_enabled; + $this->task['os_detect'] = $os_detect; + $this->task['parent_detection'] = $parent_detection; + $this->task['parent_recursion'] = $parent_recursion; + $this->task['vlan_enabled'] = $vlan_enabled; + $this->task['wmi_enabled'] = $wmi_enabled; + $this->task['resolve_names'] = $resolve_names; + $this->task['snmp_version'] = $snmp_version; + $this->task['snmp_auth_user'] = $snmp_auth_user; + $this->task['snmp_auth_pass'] = $snmp_auth_pass; + $this->task['snmp_privacy_method'] = $snmp_privacy_method; + $this->task['snmp_privacy_pass'] = $snmp_privacy_pass; + $this->task['snmp_auth_method'] = $snmp_auth_method; + $this->task['snmp_security_level'] = $snmp_security_level; + $this->task['auth_strings'] = $auth_strings; + + if ($this->task['disabled'] == 2) { + // Wizard finished. + $this->task['disabled'] = 0; + } + + // Update. + $res = db_process_sql_update( + 'trecon_task', + $this->task, + ['id_rt' => $this->task['id_rt']] + ); + + return true; + } + + if ($this->page == 3) { + // Wizard ended. Load data and return control to Discovery. + $id_rt = get_parameter('task', -1); + + $task = db_get_row( + 'trecon_task', + 'id_rt', + $id_rt + ); + + if ($task !== false) { + $this->task = $task; + } else { + $this->msg = __('Failed to find network scan task.'); + return false; + } + + return true; + } + + return false; + } + + + /** + * Undocumented function + * + * @return void + */ + public function runNetScan() + { + global $config; + + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access Agent Management' + ); + include 'general/noaccess.php'; + return; + } + + if ($this->parseNetScan() === false) { + // Error. + ui_print_error_message( + $this->msg + ); + + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => $this->url.'&mode=netscan&page='.($this->page - 1).'&task='.$this->task['id_rt'], + ], + 'inputs' => [ + [ + 'arguments' => [ + 'type' => 'hidden', + 'name' => 'task', + 'value' => $this->task['id_rt'], + ], + ], + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + // Check ACL. If user is not able to manage target task, + // redirect him to main page. + if (users_is_admin() !== true && check_acl( + $config['id_usuario'], + $this->task['id_group'], + 'PM' + ) !== true + ) { + $form['form']['action'] = $this->url.'&mode=netscan&page='.($this->page - 1); + } + + $this->printForm($form); + return null; + } + + $task_url = ''; + if (isset($this->task['id_rt'])) { + $task_url = '&task='.$this->task['id_rt']; + } + + $breadcrum[] = [ + 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd', + 'label' => __($this->label), + ]; + for ($i = 0; $i < $this->maxPagesNetScan; $i++) { + $breadcrum[] = [ + 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page='.$i.$task_url, + 'label' => $this->pageLabelsNetScan[$i], + 'selected' => (($i == $this->page) ? 1 : 0), + ]; + } + + if ($this->page < $this->maxPagesNetScan) { + // Avoid to print header out of wizard. + $this->prepareBreadcrum($breadcrum); + $this->printHeader(); + } + + if (isset($this->page) === true + && $this->page != 0 + && isset($this->task['id_rt']) === false + ) { + // Error. + ui_print_error_message( + __('Internal error, please re-run this wizard.') + ); + + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => $this->url.'&mode=netscan&page=0', + ], + 'inputs' => [ + [ + 'arguments' => [ + 'type' => 'hidden', + 'name' => 'page', + 'value' => 0, + ], + ], + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + return null; + } + + // -------------------------------. + // Page 0. wizard starts HERE. + // -------------------------------. + if (isset($this->page) === true || $this->page == 0) { + if (isset($this->page) === false + || $this->page == 0 + ) { + $form = []; + + // Input task name. + $form['inputs'][] = [ + 'label' => ''.__('Task name').'', + 'arguments' => [ + 'name' => 'taskname', + 'value' => $this->task['name'], + 'type' => 'text', + 'size' => 25, + ], + ]; + + if (isset($this->task['id_rt']) === true) { + // Propagate id. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'task', + 'value' => $this->task['id_rt'], + 'type' => 'hidden', + ], + ]; + } + + // Input task name. + $form['inputs'][] = [ + 'label' => ''.__('Comment').'', + 'arguments' => [ + 'name' => 'comment', + 'value' => $this->task['description'], + 'type' => 'text', + 'size' => 25, + ], + ]; + + // Input Discovery Server. + $form['inputs'][] = [ + 'label' => ''.__('Discovery server').''.ui_print_help_tip( + __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), + true + ), + 'arguments' => [ + 'type' => 'select_from_sql', + 'sql' => sprintf( + 'SELECT id_server, name + FROM tserver + WHERE server_type = %d + ORDER BY name', + SERVER_TYPE_DISCOVERY + ), + 'name' => 'id_recon_server', + 'selected' => $this->task['id_recon_server'], + 'return' => true, + ], + ]; + + // Input Network. + $form['inputs'][] = [ + + 'label' => ''.__('Network').''.ui_print_help_tip( + __('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), + true + ), + 'arguments' => [ + 'name' => 'network', + 'value' => $this->task['subnet'], + 'type' => 'text', + 'size' => 25, + ], + ]; + + // Input Group. + $form['inputs'][] = [ + 'label' => ''.__('Group').'', + 'arguments' => [ + 'name' => 'id_group', + 'returnAllGroup' => false, + 'privilege' => 'PM', + 'type' => 'select_groups', + 'selected' => $this->task['id_group'], + 'return' => true, + ], + ]; + + // Interval and schedules. + $interv_manual = 0; + if ((int) $this->task['interval_sweep'] == 0) { + $interv_manual = 1; + } + + // Schedule. + $form['inputs'][] = [ + 'label' => ''.__('Interval').''.ui_print_help_tip( + __('Manual interval means that it will be executed only On-demand'), + true + ), + 'arguments' => [ + 'type' => 'select', + 'selected' => $interv_manual, + 'fields' => [ + 0 => __('Defined'), + 1 => __('Manual'), + ], + 'name' => 'interval_manual_defined', + 'return' => true, + ], + 'extra' => ''.html_print_extended_select_for_time( + 'interval', + $this->task['interval_sweep'], + '', + '', + '0', + false, + true, + false, + false + ).ui_print_help_tip( + __('The minimum recomended interval for Recon Task is 5 minutes'), + true + ).'', + ]; + + $str = __('Next'); + + if (isset($this->task['id_rt']) === true) { + $str = __('Update and continue'); + } + + // Submit button. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'submit', + 'label' => $str, + 'type' => 'submit', + 'attributes' => 'class="sub next"', + 'return' => true, + ], + ]; + + $task_url = ''; + if (isset($this->task['id_rt'])) { + $task_url = '&task='.$this->task['id_rt']; + } + + $form['form'] = [ + 'method' => 'POST', + 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url, + ]; + + // Default. + $interval = 600; + $unit = 60; + if (isset($this->task['interval_sweep']) === true) { + $interval = $this->task['interval_sweep']; + $unit = $this->getTimeUnit($interval); + } + + $form['js'] = ' +$("select#interval_manual_defined").change(function() { + if ($("#interval_manual_defined").val() == 1) { + $("#interval_manual_container").hide(); + $("#text-interval_text").val(0); + $("#hidden-interval").val(0); + } + else { + $("#interval_manual_container").show(); + $("#text-interval_text").val(10); + $("#hidden-interval").val('.$interval.'); + $("#interval_units").val('.$unit.'); + } +}).change();'; + + // XXX: Could be improved validating inputs before continue (JS) + // Print NetScan page 0. + $this->printForm($form); + } + } + + if ($this->page == 1) { + // Page 1. + $form = []; + // Hidden, id_rt. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'task', + 'value' => $this->task['id_rt'], + 'type' => 'hidden', + 'return' => true, + ], + ]; + + // Hidden, page. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'page', + 'value' => ($this->page + 1), + 'type' => 'hidden', + 'return' => true, + ], + ]; + + $form['inputs'][] = [ + 'extra' => '

Please, configure task '.io_safe_output($this->task['name']).'

', + ]; + + // Input: Module template. + $form['inputs'][] = [ + 'label' => __('Module template'), + 'arguments' => [ + 'name' => 'id_network_profile', + 'type' => 'select_from_sql', + 'sql' => 'SELECT id_np, name + FROM tnetwork_profile + ORDER BY name', + 'return' => true, + 'selected' => $this->task['id_network_profile'], + 'nothing_value' => 0, + 'nothing' => __('None'), + + ], + ]; + + if (enterprise_installed() === true) { + // Input: Enable auto configuration. + $form['inputs'][] = [ + 'label' => __('Apply autoconfiguration rules').ui_print_help_tip( + __( + 'System is able to auto configure detected host & devices by applying your defined configuration rules.' + ), + true + ), + 'arguments' => [ + 'name' => 'autoconfiguration_enabled', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['autoconfiguration_enabled'])) ? $this->task['autoconfiguration_enabled'] : 0, + + ], + ]; + } + + // Feature configuration. + // Input: SNMP enabled. + $form['inputs'][] = [ + 'label' => __('SNMP enabled'), + 'arguments' => [ + 'name' => 'snmp_enabled', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1, + 'onclick' => 'extraSNMP();', + + ], + ]; + + // SNMP CONFIGURATION. + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_extra', + 'block_content' => [ + [ + 'label' => __('SNMP version'), + 'arguments' => [ + 'name' => 'snmp_version', + 'fields' => [ + '1' => 'v. 1', + '2c' => 'v. 2c', + '3' => 'v. 3', + ], + 'type' => 'select', + 'script' => 'SNMPExtraShow(this.value)', + 'selected' => $this->task['snmp_version'], + 'return' => true, + ], + ], + ], + ]; + + // SNMP Options pack v1. + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_options_basic', + 'block_content' => [ + [ + 'label' => ''.__('SNMP Default community').''.ui_print_help_tip( + __( + 'You can specify several values, separated by commas, for example: public,mysecret,1234' + ), + true + ), + 'arguments' => [ + 'name' => 'community', + 'type' => 'text', + 'value' => $this->task['snmp_community'], + 'size' => 25, + 'return' => true, + + ], + ], + ], + ]; + + // SNMP Options pack v3. + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_options_v3', + 'block_content' => [ + [ + 'label' => ''.__('Context').'', + 'arguments' => [ + 'name' => 'snmp_context', + 'type' => 'text', + 'value' => $this->task['snmp_community'], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Auth user').'', + 'arguments' => [ + 'name' => 'snmp_auth_user', + 'type' => 'text', + 'value' => $this->task['snmp_auth_user'], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Auth password').''.ui_print_help_tip( + __( + 'The pass length must be eight character minimum.' + ), + true + ), + 'arguments' => [ + 'name' => 'snmp_auth_pass', + 'type' => 'password', + 'value' => $this->task['snmp_auth_pass'], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Privacy method').'', + 'arguments' => [ + 'name' => 'snmp_privacy_method', + 'type' => 'select', + 'fields' => [ + 'DES' => __('DES'), + 'AES' => __('AES'), + ], + 'selected' => $this->task['snmp_privacy_method'], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Privacy pass').''.ui_print_help_tip( + __( + 'The pass length must be eight character minimum.' + ), + true + ), + 'arguments' => [ + 'name' => 'snmp_privacy_pass', + 'type' => 'password', + 'value' => $this->task['snmp_privacy_pass'], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Auth method').'', + 'arguments' => [ + 'name' => 'snmp_auth_method', + 'type' => 'select', + 'fields' => [ + 'MD5' => __('MD5'), + 'SHA' => __('SHA'), + ], + 'selected' => $this->task['snmp_auth_method'], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Security level').'', + 'arguments' => [ + 'name' => 'snmp_security_level', + 'type' => 'select', + 'fields' => [ + 'noAuthNoPriv' => __('Not auth and not privacy method'), + 'authNoPriv' => __('Auth and not privacy method'), + 'authPriv' => __('Auth and privacy method'), + ], + 'selected' => $this->task['snmp_security_level'], + 'size' => 15, + 'return' => true, + + ], + ], + + ], + ]; + + // Input: WMI enabled. + $form['inputs'][] = [ + 'label' => __('WMI enabled'), + 'arguments' => [ + 'name' => 'wmi_enabled', + 'type' => 'switch', + 'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0, + 'return' => true, + 'onclick' => 'toggleWMI();', + + ], + ]; + + // WMI CONFIGURATION. + $form['inputs'][] = [ + 'block_id' => 'wmi_extra', + 'hidden' => 1, + 'block_content' => [ + [ + 'label' => ''.__('WMI Auth. strings').''.ui_print_help_tip( + __( + 'Auth strings must be defined as user%pass, comma separated as many you need.' + ), + true + ), + 'arguments' => [ + 'name' => 'auth_strings', + 'type' => 'text', + 'value' => $this->task['auth_strings'], + 'return' => true, + ], + ], + ], + ]; + + // Input: Enforce os detection. + $form['inputs'][] = [ + 'label' => __('OS detection'), + 'arguments' => [ + 'name' => 'os_detect', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['os_detect'])) ? $this->task['os_detect'] : 1, + + ], + ]; + + // Input: Name resolution. + $form['inputs'][] = [ + 'label' => __('Name resolution'), + 'arguments' => [ + 'name' => 'resolve_names', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 0, + ], + ]; + + // Input: Parent detection. + $form['inputs'][] = [ + 'label' => __('Parent detection'), + 'arguments' => [ + 'name' => 'parent_detection', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['parent_detection'])) ? $this->task['parent_detection'] : 1, + ], + ]; + + // Input: Parent recursion. + $form['inputs'][] = [ + 'label' => __('Parent recursion'), + 'arguments' => [ + 'name' => 'parent_recursion', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['parent_recursion'])) ? $this->task['parent_recursion'] : 1, + ], + ]; + + // Input: VLAN enabled. + $form['inputs'][] = [ + 'label' => __('VLAN enabled'), + 'arguments' => [ + 'name' => 'vlan_enabled', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['vlan_enabled'])) ? $this->task['vlan_enabled'] : 1, + ], + ]; + + // Submit button. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Finish'), + 'type' => 'submit', + 'attributes' => 'class="sub next"', + 'return' => true, + ], + ]; + + $form['js'] = ' +function SNMPExtraShow(target) { + $("#snmp_options_basic").hide(); + $("#snmp_options_v3").hide(); + if (document.getElementsByName("snmp_enabled")[0].checked) { + $("#snmp_extra").show(); + if (target == 3) { + $("#snmp_options_v3").show(); + } else { + $("#snmp_options_basic").show(); + } + } + +} + +function extraSNMP() { + if (document.getElementsByName("snmp_enabled")[0].checked) { + SNMPExtraShow($("#snmp_version").val()); + $("#snmp_extra").show(); + } else { + // Hide unusable sections + $("#snmp_extra").hide(); + $("#snmp_options_basic").hide(); + $("#snmp_options_v3").hide(); + + // Disable snmp dependant checks + if (document.getElementsByName("parent_recursion")[0].checked) + $("input[name=parent_recursion]").click(); + + if (document.getElementsByName("parent_detection")[0].checked) + $("input[name=parent_detection]").click(); + + if (document.getElementsByName("vlan_enabled")[0].checked) + $("input[name=vlan_enabled]").click(); + + } +} + +function toggleWMI() { + if (document.getElementsByName("wmi_enabled")[0].checked) + $("#wmi_extra").show(); + else + $("#wmi_extra").hide(); +} + +$(function() { + SNMPExtraShow($("#snmp_version").val()); + toggleWMI(); +}); + '; + + $form['form'] = [ + 'method' => 'POST', + 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'], + ]; + + $this->printForm($form); + } + + if ($this->page == 2) { + if ($this->task['id_rt']) { + // 0 - Is OK. + $this->result = 0; + $this->msg = __('Task configured.'); + } else { + // 1 - Is NOT OK. + $this->result = 1; + $this->msg = __('Wizard failed. Cannot configure task.'); + } + + return [ + 'result' => $this->result, + 'id' => $this->task['id_rt'], + 'msg' => $this->msg, + ]; + } + } + + +} diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php new file mode 100644 index 0000000000..c584e6a9b7 --- /dev/null +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -0,0 +1,678 @@ +breadcrum = $str; + } + + + /** + * Getter for breadcrum + * + * @return array Breadcrum. + */ + public function getBreadcrum() + { + return $this->breadcrum; + } + + + /** + * Add an element to breadcrum array. + * + * @param string $breads Elements to add to breadcrum. + * + * @return void + */ + protected function addBreadcrum($breads) + { + if (empty($breads)) { + return; + } + + $this->breadcrum = array_merge($this->breadcrum, $breads); + } + + + /** + * Setter for label + * + * @param string $str Label. + * + * @return void + */ + public function setLabel(string $str) + { + $this->label = $str; + } + + + /** + * Getter for label + * + * @return array Breadcrum. + */ + public function getLabel() + { + return $this->label; + } + + + /** + * Return units associated to target interval (in seconds). + * + * @param integer $interval Target interval. + * + * @return integer Unit. + */ + public function getTimeUnit($interval) + { + $units = [ + 1, + 60, + 3600, + 86400, + 604800, + 2592000, + 31104000, + ]; + + $size = count($units); + for ($i = 0; $i < $size; $i++) { + if ($interval < $units[$i]) { + if (($i - 1) < 0) { + return 1; + } + + return $units[($i - 1)]; + } + } + + return $units[-1]; + } + + + /** + * Builder for breadcrum + * + * @param array $urls Array of urls to be stored in breadcrum. + * @param boolean $add True if breadcrum should be added instead of + * overwrite it. + * + * @return void + */ + public function prepareBreadcrum(array $urls, bool $add=false) + { + $bc = []; + $i = 0; + foreach ($urls as $url) { + if ($url['selected'] == 1) { + $class = 'selected'; + } else { + $class = ''; + } + + $bc[$i] = ''; + $bc[$i] .= '
'.$url['label']; + $bc[$i++] .= '
'; + } + + if ($add === true) { + $this->addBreadcrum($bc); + } else { + $this->setBreadcrum($bc); + } + + } + + + /** + * To be overwritten. + * + * @return void + */ + public function run() + { + ui_require_css_file('wizard'); + } + + + /** + * Checks if environment is ready, + * returns array + * icon: icon to be displayed + * label: label to be displayed + * + * @return array With data. + **/ + public function load() + { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + ]; + } + + + /** + * Print breadcrum to follow flow. + * + * @return string Breadcrum HTML code. + */ + public function printBreadcrum() + { + return '

'.implode('', $this->breadcrum).'

'; + } + + + /** + * Prints a header for current wizard. + * + * @param boolean $return Return HTML or print it. + * + * @return string HTML code for header. + */ + public function printHeader(bool $return=false) + { + $output = $this->printBreadcrum(); + if ($return === false) { + echo $output; + } + + return $output; + } + + + /** + * Print input using functions html lib. + * + * @param array $data Input definition. + * + * @return string HTML code for desired input. + */ + public function printInput($data) + { + if (is_array($data) === false) { + return ''; + } + + switch ($data['type']) { + case 'text': + return html_print_input_text( + $data['name'], + $data['value'], + ((isset($data['alt']) === true) ? $data['alt'] : ''), + ((isset($data['size']) === true) ? $data['size'] : 50), + ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), + ((isset($data['return']) === true) ? $data['return'] : true), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['required']) === true) ? $data['required'] : false), + ((isset($data['function']) === true) ? $data['function'] : ''), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['onChange']) === true) ? $data['onChange'] : ''), + ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '') + ); + + case 'image': + return html_print_input_image( + $data['name'], + $data['src'], + $data['value'], + ((isset($data['style']) === true) ? $data['style'] : ''), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['options']) === true) ? $data['options'] : false) + ); + + case 'text_extended': + return html_print_input_text_extended( + $data['name'], + $data['value'], + $data['id'], + $data['alt'], + $data['size'], + $data['maxlength'], + $data['disabled'], + $data['script'], + $data['attributes'], + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['password']) === true) ? $data['password'] : false), + ((isset($data['function']) === true) ? $data['function'] : '') + ); + + case 'password': + return html_print_input_password( + $data['name'], + $data['value'], + ((isset($data['alt']) === true) ? $data['alt'] : ''), + ((isset($data['size']) === true) ? $data['size'] : 50), + ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['required']) === true) ? $data['required'] : false), + ((isset($data['class']) === true) ? $data['class'] : '') + ); + + case 'text': + return html_print_input_text( + $data['name'], + $data['value'], + ((isset($data['alt']) === true) ? $data['alt'] : ''), + ((isset($data['size']) === true) ? $data['size'] : 50), + ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['required']) === true) ? $data['required'] : false), + ((isset($data['function']) === true) ? $data['function'] : ''), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['onChange']) === true) ? $data['onChange'] : ''), + ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '') + ); + + case 'image': + return html_print_input_image( + $data['name'], + $data['src'], + $data['value'], + ((isset($data['style']) === true) ? $data['style'] : ''), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['options']) === true) ? $data['options'] : false) + ); + + case 'hidden': + return html_print_input_hidden( + $data['name'], + $data['value'], + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['class']) === true) ? $data['class'] : false) + ); + + case 'hidden_extended': + return html_print_input_hidden_extended( + $data['name'], + $data['value'], + $data['id'], + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['class']) === true) ? $data['class'] : false) + ); + + case 'color': + return html_print_input_color( + $data['name'], + $data['value'], + ((isset($data['class']) === true) ? $data['class'] : false), + ((isset($data['return']) === true) ? $data['return'] : false) + ); + + case 'file': + return html_print_input_file( + $data['name'], + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['options']) === true) ? $data['options'] : false) + ); + + case 'select': + return html_print_select( + $data['fields'], + $data['name'], + ((isset($data['selected']) === true) ? $data['selected'] : ''), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['option_style']) === true) ? $data['option_style'] : false), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['modal']) === true) ? $data['modal'] : false), + ((isset($data['message']) === true) ? $data['message'] : ''), + ((isset($data['select_all']) === true) ? $data['select_all'] : false) + ); + + case 'select_from_sql': + return html_print_select_from_sql( + $data['sql'], + $data['name'], + ((isset($data['selected']) === true) ? $data['selected'] : ''), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT) + ); + + case 'select_groups': + return html_print_select_groups( + ((isset($data['id_user']) === true) ? $data['id_user'] : false), + ((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'), + ((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true), + $data['name'], + ((isset($data['selected']) === true) ? $data['selected'] : ''), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['option_style']) === true) ? $data['option_style'] : false), + ((isset($data['id_group']) === true) ? $data['id_group'] : false), + ((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'), + ((isset($data['strict_user']) === true) ? $data['strict_user'] : false), + ((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false), + ((isset($data['include_groups']) === true) ? $data['include_groups'] : false) + ); + + case 'submit': + return '
'.html_print_submit_button( + ((isset($data['label']) === true) ? $data['label'] : 'OK'), + ((isset($data['name']) === true) ? $data['name'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['attributes']) === true) ? $data['attributes'] : ''), + ((isset($data['return']) === true) ? $data['return'] : false) + ).'
'; + + case 'checkbox': + return html_print_checkbox( + $data['name'], + $data['value'], + ((isset($data['checked']) === true) ? $data['checked'] : false), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false) + ); + + case 'switch': + return html_print_switch($data); + + case 'interval': + return html_print_extended_select_for_time( + $data['name'], + $data['value'], + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['style']) === true) ? $data['selected'] : false), + ((isset($data['unique']) === true) ? $data['unique'] : false) + ); + + case 'textarea': + return html_print_textarea( + $data['name'], + $data['rows'], + $data['columns'], + ((isset($data['value']) === true) ? $data['value'] : ''), + ((isset($data['attributes']) === true) ? $data['attributes'] : ''), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['class']) === true) ? $data['class'] : '') + ); + + default: + // Ignore. + break; + } + + return ''; + } + + + /** + * Prints a go back button redirecting to main page. + * + * @return void + */ + public function printGoBackButton($url=null) + { + if (isset($url) === false) { + $url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ); + } + + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => $url, + ], + 'inputs' => [ + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + } + + + /** + * Print a block of inputs. + * + * @param array $input Definition of target block to be printed. + * @param boolean $return Return as string or direct output. + * + * @return string HTML content. + */ + public function printBlock(array $input, bool $return=false) + { + $output = ''; + if ($input['hidden'] == 1) { + $class = ' class="hidden"'; + } else { + $class = ''; + } + + if (is_array($input['block_content']) === true) { + // Print independent block of inputs. + $output .= '
  • '; + $output .= '
      '; + foreach ($input['block_content'] as $input) { + $output .= $this->printBlock($input, $return); + } + + $output .= '
  • '; + } else { + if ($input['arguments']['type'] != 'hidden') { + $output .= '
  • '; + $output .= ''; + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + $output .= '
  • '; + } else { + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + } + } + + if ($return === false) { + echo $output; + } + + return $output; + } + + + /** + * Print a form. + * + * @param array $data Definition of target form to be printed. + * @param boolean $return Return as string or direct output. + * + * @return string HTML code. + */ + public function printForm(array $data, bool $return=false) + { + $form = $data['form']; + $inputs = $data['inputs']; + $js = $data['js']; + $cb_function = $data['cb_function']; + $cb_args = $data['cb_args']; + + $output_head = ''; + + if ($return === false) { + echo $output_head; + } + + try { + if (isset($cb_function) === true) { + call_user_func_array( + $cb_function, + (isset($cb_args) === true) ? $cb_args : [] + ); + } + } catch (Exception $e) { + error_log('Error executing wizard callback: ', $e->getMessage()); + } + + $output = '
      '; + + foreach ($inputs as $input) { + $output .= $this->printBlock($input, true); + } + + $output .= '
    '; + $output .= ''; + $output .= ''; + + if ($return === false) { + echo $output; + } + + return $output_head.$output; + + } + + + /** + * Print a big button element (huge image, big text and link). + * + * @param array $data Element data (link, image...). + * + * @return void Only prints the element. + */ + public static function printBigButtonElement($data) + { + if (isset($data['url']) === false) { + $data['url'] = '#'; + } + + ?> +
  • + +
    + +
    +
    +
    +
  • + '; + array_map('self::printBigButtonElement', $list_data); + echo ''; + } + + +} diff --git a/pandora_console/godmode/wizards/index.php b/pandora_console/godmode/wizards/index.php new file mode 100755 index 0000000000..d825d5121d --- /dev/null +++ b/pandora_console/godmode/wizards/index.php @@ -0,0 +1,7 @@ +load(); diff --git a/pandora_console/images/discovery-100.png b/pandora_console/images/discovery-100.png new file mode 100644 index 0000000000..7ec755e7eb Binary files /dev/null and b/pandora_console/images/discovery-100.png differ diff --git a/pandora_console/images/discovery_green-100.png b/pandora_console/images/discovery_green-100.png new file mode 100644 index 0000000000..bcda80e4dd Binary files /dev/null and b/pandora_console/images/discovery_green-100.png differ diff --git a/pandora_console/images/gm_discovery.menu.png b/pandora_console/images/gm_discovery.menu.png new file mode 100644 index 0000000000..0f396c08c6 Binary files /dev/null and b/pandora_console/images/gm_discovery.menu.png differ diff --git a/pandora_console/images/gm_discovery_green.menu.png b/pandora_console/images/gm_discovery_green.menu.png new file mode 100644 index 0000000000..f4a387c201 Binary files /dev/null and b/pandora_console/images/gm_discovery_green.menu.png differ diff --git a/pandora_console/images/tree_events.png b/pandora_console/images/tree_events.png new file mode 100644 index 0000000000..7628d6a80d Binary files /dev/null and b/pandora_console/images/tree_events.png differ diff --git a/pandora_console/images/tree_service_map.png b/pandora_console/images/tree_service_map.png new file mode 100644 index 0000000000..16005f1c98 Binary files /dev/null and b/pandora_console/images/tree_service_map.png differ diff --git a/pandora_console/images/wizard/hostdevices.png b/pandora_console/images/wizard/hostdevices.png new file mode 100644 index 0000000000..bc60d6125c Binary files /dev/null and b/pandora_console/images/wizard/hostdevices.png differ diff --git a/pandora_console/images/wizard/netscan.png b/pandora_console/images/wizard/netscan.png new file mode 100644 index 0000000000..c90f4ddc5d Binary files /dev/null and b/pandora_console/images/wizard/netscan.png differ diff --git a/pandora_console/images/wizard/tasklist.png b/pandora_console/images/wizard/tasklist.png new file mode 100644 index 0000000000..3250311b69 Binary files /dev/null and b/pandora_console/images/wizard/tasklist.png differ diff --git a/pandora_console/images/wizard/verde/hostdevices.png b/pandora_console/images/wizard/verde/hostdevices.png new file mode 100644 index 0000000000..8b8fa022ec Binary files /dev/null and b/pandora_console/images/wizard/verde/hostdevices.png differ diff --git a/pandora_console/images/wizard/verde/tasklist.png b/pandora_console/images/wizard/verde/tasklist.png new file mode 100644 index 0000000000..4c6669e89d Binary files /dev/null and b/pandora_console/images/wizard/verde/tasklist.png differ diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 5f6f62568b..af05a8c07f 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1,16 +1,31 @@ > '; switch ($event_response['type']) { case 'command': - - if ($massive) { echo "
    "; - echo $prompt.sprintf("(Event #$event_id) ".__('Executing command: %s', $command)); + echo $prompt.sprintf( + '(Event #'.$event_id.') '.__( + 'Executing command: %s', + $command + ) + ); echo '

    '; echo "'; @@ -242,7 +259,11 @@ if ($dialogue_event_response) { case 'url': $command = str_replace('localhost', $_SERVER['SERVER_NAME'], $command); - echo ""; + echo ""; + break; + + default: + // Ignore. break; } } @@ -319,10 +340,10 @@ if ($get_extended_event) { $readonly = true; } - // Clean url from events and store in array + // Clean url from events and store in array. $event['clean_tags'] = events_clean_tags($event['tags']); - // If the event is not found, we abort + // If the event is not found, we abort. if (empty($event)) { ui_print_error_message('Event not found'); return false; @@ -341,42 +362,62 @@ if ($get_extended_event) { $event['timestamp_last'] = $timestamp_last; $event['event_rep'] = $event_rep; - // Check ACLs + // Check ACLs. if (is_user_admin($config['id_user'])) { - // Do nothing if you're admin, you get full access + // Do nothing if you're admin, you get full access. + $__ignored_line = 0; } else if ($config['id_user'] == $event['owner_user']) { - // Do nothing if you're the owner user, you get access + // Do nothing if you're the owner user, you get access. + $__ignored_line = 0; } else if ($event['id_grupo'] == 0) { - // If the event has access to all groups, you get access + // If the event has access to all groups, you get access. + $__ignored_line = 0; } else { - // Get your groups + // Get your groups. $groups = users_get_groups($config['id_user'], 'ER'); if (in_array($event['id_grupo'], array_keys($groups))) { - // If the event group is among the groups of the user, you get access + // If event group is among the groups of the user, you get access. + $__ignored_line = 0; } else { - // If all the access types fail, abort + // If all the access types fail, abort. echo 'Access denied'; return false; } } - // Print group_rep in a hidden field to recover it from javascript + // Print group_rep in a hidden field to recover it from javascript. html_print_input_hidden('group_rep', (int) $group_rep); if ($event === false) { return; } - // Tabs + // Tabs. $tabs = "'; - // Get criticity image + // Get criticity image. switch ($event['criticity']) { default: case 0: @@ -419,7 +460,19 @@ if ($get_extended_event) { } if (!$readonly - && ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids))) + && ((tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EM', + $event['clean_tags'], + $childrens_ids + )) || (tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EW', + $event['clean_tags'], + $childrens_ids + ))) ) { $responses = events_page_responses($event, $childrens_ids); } else { @@ -427,7 +480,7 @@ if ($get_extended_event) { } $console_url = ''; - // If metaconsole switch to node to get details and custom fields + // If metaconsole switch to node to get details and custom fields. if ($meta) { $server = metaconsole_get_connection_by_id($server_id); metaconsole_connect($server); @@ -437,7 +490,12 @@ if ($get_extended_event) { $details = events_page_details($event, $server); - // Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct node connection was lost + if (events_has_extended_info($event['id_evento']) === true) { + $related = events_page_related($event, $server); + } + + // Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct + // node connection was lost. if ($meta) { $server = metaconsole_get_connection_by_id($server_id); metaconsole_connect($server); @@ -464,7 +522,7 @@ if ($get_extended_event) { $loading = ''; - $out = '
    '.$tabs.$notifications.$loading.$general.$details.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'
    '; + $out = '
    '.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'
    '; $js = ''; + $js .= '});'; + + if (events_has_extended_info($event['id_evento']) === true) { + $js .= ' + $("#link_related").click(function (){ + $.post ({ + url : "ajax.php", + data : { + page: "include/ajax/events_extended", + get_extended_info: 1, + id_event: '.$event['id_evento'].' + }, + dataType : "html", + success: function (data) { + $("#related_data").html(data); + console.log("vamos puta"); + } + }); + });'; + } + + $js .= ''; echo $out.$js; } @@ -543,6 +628,10 @@ if ($get_events_details) { $img = ui_get_full_url('images/hourglass.png', false, false, false); $title = __('Event in process'); break; + + default: + // Ignore. + break; } $out .= ''; @@ -594,7 +683,8 @@ if ($table_events) { $id_agente = (int) get_parameter('id_agente', 0); $all_events_24h = (int) get_parameter('all_events_24h', 0); - // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) + // Fix: for tag functionality groups have to be all user_groups + // (propagate ACL funct!). $groups = users_get_groups($config['id_user']); $tags_condition = tags_get_acl_tags( @@ -612,7 +702,7 @@ if ($table_events) { if ($all_events_24h) { events_print_event_table( - "utimestamp > $date_subtract_day", + 'utimestamp > '.$date_subtract_day, 200, '100%', false, @@ -621,7 +711,7 @@ if ($table_events) { ); } else { events_print_event_table( - "estado <> 1 $tags_condition", + 'estado <> 1 '.$tags_condition, 200, '100%', false, diff --git a/pandora_console/include/ajax/events_extended.php b/pandora_console/include/ajax/events_extended.php new file mode 100644 index 0000000000..4993014ddf --- /dev/null +++ b/pandora_console/include/ajax/events_extended.php @@ -0,0 +1,104 @@ +width = '100%'; + $table->data = []; + $table->head = []; + $table->style[0] = 'min-width:120px; text-align: left;'; + $table->style[1] = 'text-align: left;'; + $table->cellspacing = 2; + $table->cellpadding = 2; + $table->class = 'alternate rounded_cells'; + + $output = []; + $output[] = ''.__('Timestamp').''; + $output[] = ''.__('Description').''; + $table->data[] = $output; + + foreach ($extended_info as $data) { + $output = []; + $output[] = date('Y/m/d H:i:s', $data['utimestamp']); + $output[] = io_safe_output($data['description']); + $table->data[] = $output; + } + + html_print_table($table); +} diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php index a5737ea71e..55ed7dd216 100755 --- a/pandora_console/include/ajax/reporting.ajax.php +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -198,12 +198,7 @@ if ($get_metaconsole_hash_data) { $console_password = $auth_serialized['console_password']; } - $pwd = $auth_token; - // Create HASH login info - $user = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = "&loginhash=auto&loginhash_data=$hashdata&loginhash_user=$user"; + $url_hash = metaconsole_get_servers_url_hash($server); echo $url_hash; return; diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 6c8365a924..9ea0a86e8e 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -43,6 +43,7 @@ if (is_ajax()) { include_once $config['homedir'].'/include/class/TreeModule.class.php'; include_once $config['homedir'].'/include/class/TreeTag.class.php'; include_once $config['homedir'].'/include/class/TreeGroup.class.php'; + include_once $config['homedir'].'/include/class/TreeService.class.php'; include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php'; enterprise_include_once('include/class/TreePolicies.class.php'); enterprise_include_once('include/class/TreeGroupMeta.class.php'); @@ -120,6 +121,10 @@ if (is_ajax()) { $tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); break; + case 'services': + $tree = new TreeService($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + default: // FIXME. No error handler return; @@ -127,6 +132,7 @@ if (is_ajax()) { $tree->setFilter($filter); ob_clean(); + echo json_encode(['success' => 1, 'tree' => $tree->getArray()]); return; } diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 69e848d805..aab0b4c9e4 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -1369,8 +1369,12 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $tls = ' -ZZ '; } - $ldap_host = ' -h '.$ldap_host; - $ldap_port = ' -p '.$ldap_port; + if (stripos($ldap_host, 'ldap') !== false) { + $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; + } else { + $ldap_host = ' -h '.$ldap_host.' -p '.$ldap_port; + } + $ldap_version = ' -P '.$ldap_version; if (!empty($ldap_admin_user)) { $ldap_admin_user = " -D '".$ldap_admin_user."'"; @@ -1382,7 +1386,7 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $dn = " -b '".$dn."'"; - $shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_port.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"')); + $shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"')); foreach ($shell_ldap_search as $line) { $values = explode('=>', $line); if (!empty($values[0]) && !empty($values[1])) { diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 96124afa4c..e7133fd79e 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -88,16 +88,13 @@ if (file_exists('languages/'.$user_language.'.mo')) { $params['menu'] = false; if ((!isset($params['width']) || ($params['width'] <= 0))) { - $params['width'] = 1048; + $params['width'] = 650; } $params_combined = json_decode($_REQUEST['data_combined'], true); $module_list = json_decode($_REQUEST['data_module_list'], true); $type_graph_pdf = $_REQUEST['type_graph_pdf']; - $aux_font_size = $config['font_size']; - $config['font_size'] = ($config['font_size'] + 3); - echo '
    '; switch ($type_graph_pdf) { case 'combined': @@ -216,7 +213,6 @@ if (file_exists('languages/'.$user_language.'.mo')) { echo '
    '; - $config['font_size'] = $aux_font_size; ?> '; + '; } @@ -2322,10 +2856,31 @@ function reporting_html_text(&$table, $item) } -function reporting_html_availability(&$table, $item) +/** + * Report availability + * + * @param string $table Reference table in pdf a false. + * @param array $item Parameters for item pdf. + * @param boolean $pdf Send pdf. + * + * @return html + */ +function reporting_html_availability($table, $item, $pdf=0) { - $style = db_get_value('style', 'treport_content', 'id_rc', $item['id_rc']); - $style = json_decode(io_safe_output($style), true); + $retun_pdf = ''; + + $style = db_get_value( + 'style', + 'treport_content', + 'id_rc', + $item['id_rc'] + ); + + $style = json_decode( + io_safe_output($style), + true + ); + $same_agent_in_resume = ''; global $config; @@ -2338,7 +2893,7 @@ function reporting_html_availability(&$table, $item) $table1->head = []; $table1->head[0] = __('Agent'); // HACK it is saved in show_graph field. - // Show interfaces instead the modules + // Show interfaces instead the modules. if ($item['kind_availability'] == 'address') { $table1->head[1] = __('IP Address'); } else { @@ -2381,7 +2936,7 @@ function reporting_html_availability(&$table, $item) $table2->head = []; $table2->head[0] = __('Agent'); // HACK it is saved in show_graph field. - // Show interfaces instead the modules + // Show interfaces instead the modules. if ($item['kind_availability'] == 'address') { $table2->head[1] = __('IP Address'); } else { @@ -2392,7 +2947,7 @@ function reporting_html_availability(&$table, $item) $table2->head[3] = __('Checks failed'); $table2->head[4] = __('Checks OK'); $table2->head[5] = __('Checks Uknown'); - // $table2->head[6] = __('% Ok'); + $table2->headstyle = []; $table2->headstyle[0] = 'text-align: left'; $table2->headstyle[1] = 'text-align: left'; @@ -2400,53 +2955,73 @@ function reporting_html_availability(&$table, $item) $table2->headstyle[3] = 'text-align: right'; $table2->headstyle[4] = 'text-align: right'; $table2->headstyle[5] = 'text-align: right'; - // $table2->headstyle[6] = 'text-align: right'; + $table2->style[0] = 'text-align: left'; $table2->style[1] = 'text-align: left'; $table2->style[2] = 'text-align: right'; $table2->style[3] = 'text-align: right'; $table2->style[4] = 'text-align: right'; $table2->style[5] = 'text-align: right'; - // $table2->style[6] = 'text-align: right'; + foreach ($item['data'] as $row) { - $the_first_men_time = get_agent_first_time(io_safe_output($row['agent'])); + $the_first_men_time = get_agent_first_time( + io_safe_output($row['agent']) + ); $table_row = []; $table_row[] = $row['agent']; $table_row[] = $row['availability_item']; if ($row['time_total'] != 0) { - $table_row[] = human_time_description_raw($row['time_total'], true); + $table_row[] = human_time_description_raw( + $row['time_total'], + true + ); } else { $table_row[] = '--'; } if ($row['time_error'] != 0) { - $table_row[] = human_time_description_raw($row['time_error'], true); + $table_row[] = human_time_description_raw( + $row['time_error'], + true + ); } else { $table_row[] = '--'; } if ($row['time_ok'] != 0) { - $table_row[] = human_time_description_raw($row['time_ok'], true); + $table_row[] = human_time_description_raw( + $row['time_ok'], + true + ); } else { $table_row[] = '--'; } if ($row['time_unknown'] != 0) { - $table_row[] = human_time_description_raw($row['time_unknown'], true); + $table_row[] = human_time_description_raw( + $row['time_unknown'], + true + ); } else { $table_row[] = '--'; } if ($row['time_not_init'] != 0) { - $table_row[] = human_time_description_raw($row['time_not_init'], true); + $table_row[] = human_time_description_raw( + $row['time_not_init'], + true + ); } else { $table_row[] = '--'; } if ($row['time_downtime'] != 0) { - $table_row[] = human_time_description_raw($row['time_downtime'], true); + $table_row[] = human_time_description_raw( + $row['time_downtime'], + true + ); } else { $table_row[] = '--'; } @@ -2469,16 +3044,30 @@ function reporting_html_availability(&$table, $item) $table->data['error']['cell'] = __('There are no Agent/Modules defined'); } - $table->colspan[1][0] = 2; - $table->colspan[2][0] = 2; - $data = []; - $data[0] = html_print_table($table1, true); - array_push($table->data, $data); + if ($pdf === 0) { + $table->colspan[1][0] = 2; + $table->colspan[2][0] = 2; + $data = []; + $data[0] = html_print_table($table1, true); + array_push($table->data, $data); + } else { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table($table1, true); + } if ($item['resume']['resume']) { - $data2 = []; - $data2[0] = html_print_table($table2, true); - array_push($table->data, $data2); + if ($pdf === 0) { + $data2 = []; + $data2[0] = html_print_table($table2, true); + array_push($table->data, $data2); + } else { + $table2->title = $item['title']; + $table2->titleclass = 'title_table_pdf'; + $table2->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table($table2, true); + } } if ($item['resume']['resume'] && !empty($item['data'])) { @@ -2508,27 +3097,60 @@ function reporting_html_availability(&$table, $item) $table1->data[] = [ 'max_text' => $item['resume']['max_text'], - 'max' => sla_truncate($item['resume']['max'], $config['graph_precision']).'%', + 'max' => sla_truncate( + $item['resume']['max'], + $config['graph_precision'] + ).'%', 'min_text' => $item['resume']['min_text'], - 'min' => sla_truncate($item['resume']['min'], $config['graph_precision']).'%', + 'min' => sla_truncate( + $item['resume']['min'], + $config['graph_precision'] + ).'%', 'avg' => ''.sla_truncate($item['resume']['avg'], $config['graph_precision']).'%', ]; - $table->colspan[3][0] = 3; - $data = []; - $data[0] = html_print_table($table1, true); - array_push($table->data, $data); + if ($pdf === 0) { + $table->colspan[3][0] = 3; + $data = []; + $data[0] = html_print_table( + $table1, + true + ); + array_push($table->data, $data); + } else { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table( + $table1, + true + ); + } } } + + if ($pdf !== 0) { + return $return_pdf; + } } -function reporting_html_availability_graph(&$table, $item, $pdf=0) +/** + * The availability report shows in detail the reached + * status of a module in a given time interval. + * + * @param string $table Reference table in pdf a false. + * @param array $item Parameters for item pdf. + * @param boolean $pdf Send pdf. + * + * @return html + */ +function reporting_html_availability_graph($table, $item, $pdf=0) { global $config; $metaconsole_on = is_metaconsole(); - if ($metaconsole_on) { + if ($metaconsole_on !== false) { $hack_metaconsole = '../../'; } else { $hack_metaconsole = ''; @@ -2570,7 +3192,10 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) break; } - $sla_value = sla_truncate($chart['sla_value'], $config['graph_precision']).'%'; + $sla_value = sla_truncate( + $chart['sla_value'], + $config['graph_precision'] + ).'%'; $checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')'; } @@ -2578,11 +3203,14 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) $table1->data[0][1] = $chart['chart']; $table1->data[0][2] = "".$sla_value.''; $table1->data[0][3] = $checks_resume; - $tables_chart .= html_print_table($table1, true); + $tables_chart .= html_print_table( + $table1, + true + ); } if ($item['type'] == 'availability_graph') { - // table_legend_graphs; + // Table_legend_graphs. $table2 = new stdClass(); $table2->width = '99%'; $table2->data = []; @@ -2618,22 +3246,62 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) $table2->data[0][11] = ''.__('Ignore time').''; } - $table->colspan['charts']['cell'] = 2; - $table->data['charts']['cell'] = $tables_chart; - $table->colspan['legend']['cell'] = 2; - $table->data['legend']['cell'] = html_print_table($table2, true); - - if ($pdf) { - return $tables_chart.'
    '.html_print_table($table2, true); + if ($pdf !== 0) { + $tables_chart .= html_print_table( + $table2, + true + ); + return $tables_chart; + } else { + $table->colspan['charts']['cell'] = 2; + $table->data['charts']['cell'] = $tables_chart; + $table->colspan['legend']['cell'] = 2; + $table->data['legend']['cell'] = html_print_table( + $table2, + true + ); } } -function reporting_html_general(&$table, $item) +/** + * Function for first time data agent. + * + * @param string $agent_name Agent name. + * + * @return array + */ +function get_agent_first_time($agent_name) { + $id = agents_get_agent_id($agent_name, true); + + $utimestamp = db_get_all_rows_sql( + 'SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN + (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.') + ORDER BY utimestamp ASC LIMIT 1' + ); + $utimestamp = $utimestamp[0]['utimestamp']; + + return $utimestamp; +} + + +/** + * Function to print to HTML General report. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return html + */ +function reporting_html_general($table, $item, $pdf=0) +{ + $return_pdf = ''; if (!empty($item['data'])) { $data_in_same_row = $item['show_in_same_row']; switch ($item['subtype']) { + default: case REPORT_GENERAL_NOT_GROUP_BY_AGENT: if (!$data_in_same_row) { $table1 = new stdClass(); @@ -2652,14 +3320,14 @@ function reporting_html_general(&$table, $item) $table1->style[2] = 'text-align: left'; $table1->style[3] = 'text-align: left'; - // Begin - Order by agent + // Begin - Order by agent. foreach ($item['data'] as $key => $row) { $aux[$key] = $row['agent']; } array_multisort($aux, SORT_ASC, $item['data']); - // End - Order by agent + // End - Order by agent. foreach ($item['data'] as $row) { if ($row['id_module_type'] == 6 || $row['id_module_type'] == 9 || $row['id_module_type'] == 18 || $row['id_module_type'] == 2) { $row['formated_value'] = round($row['formated_value'], 0, PHP_ROUND_HALF_DOWN); @@ -2723,7 +3391,6 @@ function reporting_html_general(&$table, $item) } } break; - case REPORT_GENERAL_GROUP_BY_AGENT: $list_modules = []; foreach ($item['data'] as $modules) { @@ -2754,12 +3421,23 @@ function reporting_html_general(&$table, $item) break; } - $table->colspan['data']['cell'] = 3; - $table->cellstyle['data']['cell'] = 'text-align: center;'; - $table->data['data']['cell'] = html_print_table($table1, true); + if ($pdf !== 0) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table($table1, true); + } else { + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: center;'; + $table->data['data']['cell'] = html_print_table($table1, true); + } } else { - $table->colspan['error']['cell'] = 3; - $table->data['error']['cell'] = __('There are no Agent/Modules defined'); + if ($pdf !== 0) { + $return_pdf .= __('There are no Agent/Modules defined'); + } else { + $table->colspan['error']['cell'] = 3; + $table->data['error']['cell'] = __('There are no Agent/Modules defined'); + } } if ($item['resume'] && !empty($item['data'])) { @@ -2789,34 +3467,44 @@ function reporting_html_general(&$table, $item) $table_summary->data[0][3] = $item['max']['agent'].' - '.$item['max']['module']; $table_summary->data[0][4] = $item['max']['formated_value']; - $table->colspan['summary_title']['cell'] = 3; - $table->data['summary_title']['cell'] = ''.__('Summary').''; - $table->colspan['summary_table']['cell'] = 3; - $table->data['summary_table']['cell'] = html_print_table($table_summary, true); + if ($pdf !== 0) { + $return_pdf .= html_print_table($table_summary, true); + } else { + $table->colspan['summary_title']['cell'] = 3; + $table->data['summary_title']['cell'] = ''.__('Summary').''; + $table->colspan['summary_table']['cell'] = 3; + $table->data['summary_table']['cell'] = html_print_table( + $table_summary, + true + ); + } + } + + if ($pdf !== 0) { + return $return_pdf; } } -function get_agent_first_time($agent_name) -{ - $id = agents_get_agent_id($agent_name, true); - - $utimestamp = db_get_all_rows_sql( - 'SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN - (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.') - ORDER BY utimestamp ASC LIMIT 1' - ); - $utimestamp = $utimestamp[0]['utimestamp']; - - return $utimestamp; -} - - -function reporting_html_sql(&$table, $item) +/** + * Function to print to HTML query sql. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf If it comes from pdf. + * + * @return html + */ +function reporting_html_sql($table, $item, $pdf=0) { + $return_pdf = ''; if (!$item['correct']) { - $table->colspan['error']['cell'] = 3; - $table->data['error']['cell'] = $item['error']; + if ($pdf === 0) { + $table->colspan['error']['cell'] = 3; + $table->data['error']['cell'] = $item['error']; + } else { + $return_pdf .= $item['error']; + } } else { $first = true; @@ -2825,10 +3513,10 @@ function reporting_html_sql(&$table, $item) $table2->width = '100%'; foreach ($item['data'] as $row) { - if ($first) { + if ($first === true) { $first = false; - // Print the header + // Print the header. foreach ($row as $key => $value) { $table2->head[] = $key; } @@ -2837,18 +3525,44 @@ function reporting_html_sql(&$table, $item) $table2->data[] = $row; } - $table->colspan['data']['cell'] = 3; - $table->cellstyle['data']['cell'] = 'text-align: center;'; - $table->data['data']['cell'] = html_print_table($table2, true); + if ($pdf === 0) { + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: center;'; + $table->data['data']['cell'] = html_print_table( + $table2, + true + ); + } else { + $table2->title = $item['title']; + $table2->titleclass = 'title_table_pdf'; + $table2->titlestyle = 'text-align:left;'; + $return_pdf .= html_print_table( + $table2, + true + ); + } + } + + if ($pdf !== 0) { + return $return_pdf; } } +/** + * Function for stats. + * + * @param array $data Array item. + * @param integer $graph_width Items data. + * @param integer $graph_height If it comes from pdf. + * + * @return html + */ function reporting_get_stats_summary($data, $graph_width, $graph_height) { global $config; - // Alerts table + // Alerts table. $table_sum = html_get_predefined_table(); $tdata = []; @@ -2868,25 +3582,33 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) $table_sum->cellstyle[count($table_sum->data)][2] = 'text-align: center;'; if ($data['monitor_checks'] > 0) { - // Fixed width non interactive charts + // Fixed width non interactive charts. $status_chart_width = $graph_width; - $tdata[0] = '
    '.'
    '.graph_agent_status(false, $graph_width, $graph_height, true, true).'
    '.'
    '; + $tdata[0] = '
    '.graph_agent_status(false, $graph_width, $graph_height, true, true).'
    '; } else { - $tdata[2] = html_print_image('images/image_problem_area_small.png', true, ['width' => $graph_width]); + $tdata[2] = html_print_image( + 'images/image_problem_area_small.png', + true, + ['width' => $graph_width] + ); } if ($data['monitor_alerts'] > 0) { $tdata[2] = '
    '.graph_alert_status($data['monitor_alerts'], $data['monitor_alerts_fired'], $graph_width, $graph_height, true, true).'
    '; } else { - $tdata[2] = html_print_image('images/image_problem_area_small.png', true, ['width' => $graph_width]); + $tdata[2] = html_print_image( + 'images/image_problem_area_small.png', + true, + ['width' => $graph_width] + ); } $table_sum->rowclass[] = ''; $table_sum->data[] = $tdata; $output = '
    - '.__('Summary').''.html_print_table($table_sum, true).'
    '; + '.__('Summary').''.html_print_table($table_sum, true).'
    '; return $output; } @@ -2898,10 +3620,11 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) * It construct a table object with all the events happened in a group * during a period of time. * - * @param int Group id to get the report. - * @param int Period of time to get the report. - * @param int Beginning date of the report - * @param int Flag to return or echo the report table (echo by default). + * @param integer $id_group Group id to get the report. + * @param integer $period Period of time to get the report. + * @param integer $date Beginning date of the report. + * @param boolean $return Flag to return or echo the + * report table (echo by default). * * @return object A table object */ @@ -2934,7 +3657,7 @@ function reporting_event_reporting($id_group, $period, $date=0, $return=false) } $data[1] = $event['evento']; - $data[2] = $event['id_usuario'] != '0' ? $event['id_usuario'] : ''; + $data[2] = ($event['id_usuario'] != '0') ? $event['id_usuario'] : ''; $data[3] = $event['timestamp']; array_push($table->data, $data); } @@ -2950,8 +3673,9 @@ function reporting_event_reporting($id_group, $period, $date=0, $return=false) /** * Get a table report from a alerts fired array. * - * @param array Alerts fired array. - * @see function get_alerts_fired () + * @param array $alerts_fired Alerts fired array. + * + * @see function get_alerts_fired () * * @return object A table object with a report of the fired alerts. */ @@ -2966,7 +3690,7 @@ function reporting_get_fired_alerts_table($alerts_fired) $alert_module = alerts_get_alert_agent_module($id_alert); $template = alerts_get_alert_template($id_alert); - // Add alerts fired to $agents_fired_alerts indexed by id_agent + // Add alerts fired to $agents_fired_alerts indexed by id_agent. $id_agent = db_get_value( 'id_agente', 'tagente_modulo', @@ -3012,8 +3736,9 @@ function reporting_get_fired_alerts_table($alerts_fired) /** * Get a report table with all the monitors down. * - * @param array An array with all the monitors down - * @see function modules_get_monitors_down() + * @param array $monitors_down An array with all the monitors down. + * + * @see Function modules_get_monitors_down(). * * @return object A table object with a monitors down report. */ @@ -3027,7 +3752,7 @@ function reporting_get_monitors_down_table($monitors_down) $agents = []; if ($monitors_down) { foreach ($monitors_down as $monitor) { - // Add monitors fired to $agents_fired_alerts indexed by id_agent + // Add monitors fired to $agents_fired_alerts indexed by id_agent. $id_agent = $monitor['id_agente']; if (!isset($agents[$id_agent])) { $agents[$id_agent] = []; @@ -3067,8 +3792,8 @@ function reporting_get_monitors_down_table($monitors_down) * * It shows the number of agents and no more things right now. * - * @param int Group to get the report - * @param bool Flag to return or echo the report (by default). + * @param integer $id_group Group to get the report. + * @param boolean $return Flag to return or echo the report (by default). * * @return HTML string with group report */ @@ -3088,9 +3813,10 @@ function reporting_print_group_reporting($id_group, $return=false) /** * Get a report table of the fired alerts group by agents. * - * @param int Agent id to generate the report. - * @param int Period of time of the report. - * @param int Beginning date of the report in UNIX time (current date by default). + * @param integer $id_agent Agent id to generate the report. + * @param integer $period Period of time of the report. + * @param integer $date Beginning date of the report in + * UNIX time (current date by default). * * @return object A table object with the alert reporting.. */ @@ -3123,6 +3849,7 @@ function reporting_get_agent_alerts_table($id_agent, $period=0, $date=0) switch ($template['type']) { case 'regex': + default: if ($template['matches_value']) { $data[2] = '≃ "'.$template['value'].'"'; } else { @@ -3133,23 +3860,19 @@ function reporting_get_agent_alerts_table($id_agent, $period=0, $date=0) case 'equal': case 'not_equal': $data[2] = $template['value']; - break; case 'max-min': $data[2] = __('Min.').': '.$template['min_value'].' '; $data[2] .= __('Max.').': '.$template['max_value'].' '; - break; case 'max': $data[2] = $template['max_value']; - break; case 'min': $data[2] = $template['min_value']; - break; } @@ -3167,9 +3890,10 @@ function reporting_get_agent_alerts_table($id_agent, $period=0, $date=0) /** * Get a report of monitors in an agent. * - * @param int Agent id to get the report - * @param int Period of time of the report. - * @param int Beginning date of the report in UNIX time (current date by default). + * @param integer $id_agent Agent id to get the report. + * @param integer $period Period of time of the report. + * @param integer $date Beginning date of the report in UNIX time + * (current date by default). * * @return object A table object with the report. */ @@ -3187,7 +3911,11 @@ function reporting_get_agent_monitors_table($id_agent, $period=0, $date=0) } foreach ($monitors as $monitor) { - $downs = modules_get_monitor_downs_in_period($monitor['id_agente_modulo'], $period, $date); + $downs = modules_get_monitor_downs_in_period( + $monitor['id_agente_modulo'], + $period, + $date + ); if (! $downs) { continue; } @@ -3199,7 +3927,11 @@ function reporting_get_agent_monitors_table($id_agent, $period=0, $date=0) $data[0] = $monitor['nombre']; } - $data[1] = modules_get_last_down_timestamp_in_period($monitor['id_agente_modulo'], $period, $date); + $data[1] = modules_get_last_down_timestamp_in_period( + $monitor['id_agente_modulo'], + $period, + $date + ); array_push($table->data, $data); } @@ -3210,9 +3942,10 @@ function reporting_get_agent_monitors_table($id_agent, $period=0, $date=0) /** * Get a report of all the modules in an agent. * - * @param int Agent id to get the report. - * @param int Period of time of the report - * @param int Beginning date of the report in UNIX time (current date by default). + * @param integer $id_agent Agent id to get the report. + * @param integer $period Period of time of the report. + * @param integer $date Beginning date of the report in UNIX time + * (current date by default). * * @return object */ @@ -3244,19 +3977,24 @@ function reporting_get_agent_modules_table($id_agent, $period=0, $date=0) /** * Get a detailed report of an agent * - * @param int Agent to get the report. - * @param int Period of time of the desired report. - * @param int Beginning date of the report in UNIX time (current date by default). - * @param bool Flag to return or echo the report (by default). + * @param integer $id_agent Agent to get the report. + * @param integer $period Period of time of the desired report. + * @param integer $date Beginning date of the report in UNIX time + * (current date by default). + * @param boolean $return Flag to return or echo the report (by default). * * @return string */ -function reporting_get_agent_detailed($id_agent, $period=0, $date=0, $return=false) -{ +function reporting_get_agent_detailed( + $id_agent, + $period=0, + $date=0, + $return=false +) { $output = ''; $n_a_string = __('N/A(*)'); - // Show modules in agent + // Show modules in agent. $output .= '
    '; $output .= '

    '.__('Agent').' - '.agents_get_alias($id_agent).'

    '; $output .= '

    '.__('Modules').'

    '; @@ -3264,17 +4002,17 @@ function reporting_get_agent_detailed($id_agent, $period=0, $date=0, $return=fal $table_modules->width = '99%'; $output .= html_print_table($table_modules, true); - // Show alerts in agent + // Show alerts in agent. $table_alerts = reporting_get_agent_alerts_table($id_agent, $period, $date); $table_alerts->width = '99%'; - if (sizeof($table_alerts->data)) { + if (count($table_alerts->data)) { $output .= '

    '.__('Alerts').'

    '; $output .= html_print_table($table_alerts, true); } - // Show monitor status in agent (if any) + // Show monitor status in agent (if any). $table_monitors = reporting_get_agent_monitors_table($id_agent, $period, $date); - if (sizeof($table_monitors->data) == 0) { + if (count($table_monitors->data) == 0) { $output .= '
    '; if (! $return) { echo $output; @@ -3467,12 +4205,12 @@ function reporting_get_agents_by_status($data, $graph_width=250, $graph_height=1 if (!defined('METACONSOLE')) { $agents_data = '
    - '.__('Agents by status').''.html_print_table($table_agent, true).'
    '; + '.__('Agents by status').''.html_print_table($table_agent, true).'
    '; } else { $table_agent->style = []; $table_agent->class = 'tactical_view'; $agents_data = '
    - '.__('Agents by status').''.html_print_table($table_agent, true).'
    '; + '.__('Agents by status').''.html_print_table($table_agent, true).''; } return $agents_data; @@ -3495,7 +4233,7 @@ function reporting_get_total_agents_and_monitors($data, $graph_width=250, $graph $total_data[3] = $total_module <= 0 ? '-' : $total_module; $table_total->data[] = $total_data; $total_agent_module = '
    - '.__('Total agents and monitors').''.html_print_table($table_total, true).'
    '; + '.__('Total agents and monitors').''.html_print_table($table_total, true).''; return $total_agent_module; } @@ -3514,12 +4252,12 @@ function reporting_get_total_servers($num_servers) if (!defined('METACONSOLE')) { $node_overview = '
    - '.__('Node overview').''.html_print_table($table_node, true).'
    '; + '.__('Node overview').''.html_print_table($table_node, true).''; } else { $table_node->style = []; $table_node->class = 'tactical_view'; $node_overview = '
    - '.__('Node overview').''.html_print_table($table_node, true).'
    '; + '.__('Node overview').''.html_print_table($table_node, true).''; } return $node_overview; @@ -3563,7 +4301,7 @@ function reporting_get_events($data, $links=false) if (!defined('METACONSOLE')) { $event_view = '
    - '.__('Events by severity').''.html_print_table($table_events, true).'
    '; + '.__('Events by severity').''.html_print_table($table_events, true).''; } else { $table_events->class = 'tactical_view'; $table_events->styleTable = 'text-align:center;'; @@ -3573,7 +4311,7 @@ function reporting_get_events($data, $links=false) $table_events->size[3] = '10%'; $event_view = '
    - '.__('Important Events by Criticity').''.html_print_table($table_events, true).'
    '; + '.__('Important Events by Criticity').''.html_print_table($table_events, true).''; } return $event_view; @@ -3605,9 +4343,9 @@ function reporting_get_last_activity() case 'mysql': $sql = sprintf( 'SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp - FROM tsesion - WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") - AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", + FROM tsesion + WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") + AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", $config['id_user'] ); break; @@ -3615,9 +4353,9 @@ function reporting_get_last_activity() case 'postgresql': $sql = sprintf( "SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion, utimestamp - FROM tsesion - WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.") - AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", + FROM tsesion + WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.") + AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", $config['id_user'] ); break; @@ -3625,9 +4363,9 @@ function reporting_get_last_activity() case 'oracle': $sql = sprintf( "SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp - FROM tsesion - WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.") - AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", + FROM tsesion + WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.") + AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config['id_user'] ); break; @@ -3805,7 +4543,7 @@ function reporting_get_event_histogram($events, $text_header_event=false) if (!defined('METACONSOLE')) { if (!$text_header_event) { $event_graph = '
    - '.$text_header_event.''.html_print_table($table, true).'
    '; + '.$text_header_event.''.html_print_table($table, true).''; } else { $table->class = 'noclass'; $event_graph = html_print_table($table, true); @@ -3903,9 +4641,9 @@ function reporting_get_event_histogram_meta($width) $time_condition = 'utimestamp > '.$bottom.' AND utimestamp < '.$top; $sql = sprintf( 'SELECT criticity,utimestamp - FROM tmetaconsole_event - WHERE %s %s %s - ORDER BY criticity DESC', + FROM tmetaconsole_event + WHERE %s %s %s + ORDER BY criticity DESC', $time_condition, $groups_condition, $status_condition @@ -3989,7 +4727,7 @@ function reporting_get_event_histogram_meta($width) if (!$text_header_event) { $event_graph = '
    - '.$text_header_event.''.html_print_table($table, true).'
    '; + '.$text_header_event.''.html_print_table($table, true).''; } else { $table->class = 'noclass'; $event_graph = html_print_table($table, true); diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 3081e076b6..ba6659ddc1 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1,22 +1,33 @@ __('Recon server')]); + case SERVER_TYPE_DISCOVERY: + $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Discovery server')]); $server['type'] = 'recon'; $id_modulo = 0; break; @@ -589,11 +600,11 @@ function servers_get_info($id_server=-1) $server['lag'] = 0; $server['module_lag'] = 0; } - // Recon server - else if ($server['server_type'] == SERVER_TYPE_RECON) { + // Discovery server + else if ($server['server_type'] == SERVER_TYPE_DISCOVERY) { $server['name'] = ''.$server['name'].''; - // Total jobs running on this recon server + // Total jobs running on this Discovery server $server['modules'] = db_get_sql( 'SELECT COUNT(id_rt) FROM trecon_task @@ -921,3 +932,64 @@ function servers_get_status($id_server) $serverinfo = servers_get_info($id_server); return $serverinfo[$id_server]; } + + +/** + * Return server name based on identifier. + * + * @param integer $server Server identifier. + * + * @return string Server name + */ +function servers_get_server_string_name(int $server) +{ + switch ($server) { + case SERVER_TYPE_DATA: + return __('Data server'); + + case SERVER_TYPE_NETWORK: + return __('Network server'); + + case SERVER_TYPE_SNMP: + return __('SNMP server'); + + case SERVER_TYPE_ENTERPRISE_ICMP: + return __('Enterprise ICMP server'); + + case SERVER_TYPE_ENTERPRISE_SNMP: + return __('Enterprise SNMP server'); + + case SERVER_TYPE_PLUGIN: + return __('Plugin server'); + + case SERVER_TYPE_PREDICTION: + return __('Prediction Server'); + + case SERVER_TYPE_WMI: + return __('WMI server'); + + case SERVER_TYPE_WEB: + return __('Web server'); + + case SERVER_TYPE_EXPORT: + return __('Export server'); + + case SERVER_TYPE_INVENTORY: + return __('Inventory server'); + + case SERVER_TYPE_EVENT: + return __('Event server'); + + case SERVER_TYPE_DISCOVERY: + return __('Discovery server'); + + case SERVER_TYPE_SYSLOG: + return __('Syslog server'); + + case SERVER_TYPE_WUX: + return __('WUX server'); + + default: + return __('N/A'); + } +} diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 57bc416c76..4920816c89 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -27,7 +27,7 @@ $nfdump_date_format = 'Y/m/d.H:i:s'; * @param id string Level ID. Do not set, used for recursion. * @param depth string Branch depth. Do not set, used for recursion. */ -function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]) +function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[], $sufix=false, $checked=[]) { static $url = false; @@ -52,13 +52,13 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] } foreach ($tree['__LEAVES__'] as $level => $sub_level) { - // Id used to expand leafs + // Id used to expand leafs. $sub_id = time().rand(0, getrandmax()); - // Display the branch + // Display the branch. echo "
  • "; - // Indent sub branches + // Indent sub branches. for ($i = 1; $i <= $depth; $i++) { if ($last_array[$i] == 1) { echo ''; @@ -67,7 +67,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] } } - // Branch + // Branch. if (! empty($sub_level['__LEAVES__'])) { echo ""; if ($depth == 0 && $count == 0) { @@ -84,7 +84,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] echo ''; } - // Leave + // Leave. else { if ($depth == 0 && $count == 0) { if ($count == $total) { @@ -106,15 +106,18 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] echo ''; } - echo html_print_checkbox("create_$sub_id", 0, false, true, false, '').' '.$level.''; + $checkbox_name_sufix = ($sufix === true) ? '_'.$level : ''; + $checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix; + $status = (!empty($checked) && isset($checked[$level])); + echo html_print_checkbox($checkbox_name, 0, $status, true, false, '').' '.$level.''; if (isset($sub_level['__VALUE__'])) { echo ''; } echo '
  • '; - // Recursively print sub levels - snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array); + // Recursively print sub levels. + snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix, $checked); $count++; } @@ -838,7 +841,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500 if ($(this).is(':checked') ) { $('input[name*=create_network_component]').show(); var id_input = $(this).attr("id"); - id_input = id_input.split("checkbox-create_"); + id_input = id_input.match("checkbox-create_([0-9]+)"); var checks = $('#ul_'+id_input[1]).find('input').map(function(){ if(this.id.indexOf('checkbox-create_')!=-1){ return this.id; @@ -851,7 +854,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500 } else { var id_input = $(this).attr("id"); - id_input = id_input.split("checkbox-create_"); + id_input = id_input.match("checkbox-create_([0-9]+)"); var checks = $('#ul_'+id_input[1]).find('input').map(function(){ if(this.id.indexOf('checkbox-create_')!=-1){ return this.id; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 2969a80dcd..ebbc2ac376 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -748,7 +748,7 @@ function tags_get_acl_tags( $id_user = $config['id_user']; } - if (is_user_admin($id_user)) { + if (is_user_admin($id_user) && empty($childrens_ids)) { switch ($return_mode) { case 'data': return []; @@ -797,7 +797,8 @@ function tags_get_acl_tags( // Return the condition of the tags for tagente_modulo table $condition = tags_get_acl_tags_module_condition( $acltags, - $query_table + $query_table, + empty($childrens_ids) ? [] : $childrens_ids ); if (!empty($condition)) { return " $query_prefix ".$condition; @@ -825,7 +826,7 @@ function tags_get_acl_tags( * * @return string SQL condition for tagente_module */ -function tags_get_acl_tags_module_condition($acltags, $modules_table='') +function tags_get_acl_tags_module_condition($acltags, $modules_table='', $force_tags=[]) { if (!empty($modules_table)) { $modules_table .= '.'; @@ -839,6 +840,17 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='') // The acltags array contains the groups with the acl propagation applied // after the changes done into the 'tags_get_user_groups_and_tags' function. foreach ($acltags as $group_id => $group_tags) { + if (empty($group_tags)) { + $group_tags = []; + if (!empty($force_tags)) { + $group_tags = $force_tags; + } + } + + if (!empty($group_tags)) { + $group_tags = array_intersect($force_tags, $group_tags); + } + $tag_join = ''; if (!empty($group_tags)) { $tag_join = sprintf('AND ttag_module.id_tag IN (%s)', is_array($group_tags) ? implode(',', $group_tags) : $group_tags); @@ -849,7 +861,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='') } $group_conditions[] = $agent_condition; - } else { + } else if (!empty($force_tags)) { $without_tags[] = $group_id; } } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 45713c8f24..151014cd01 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -1313,20 +1313,79 @@ function visual_map_editor_print_hack_translate_strings() echo ''; echo ''; - // Hack to translate messages in javascript - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + // Hack to translate messages in javascript. + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; + + echo "'; - echo ''; - echo ''; } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 0460b55c99..dd6fb0645e 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -856,11 +856,12 @@ function pandoraFlotSlicebar( } var font_size = parseInt(font_size); - var font = font - .split("/") - .pop() - .split(".") - .shift(); + if (font != undefined) + var font = font + .split("/") + .pop() + .split(".") + .shift(); // Check possible adapt_keys on classes check_adaptions(graph_id); diff --git a/pandora_console/include/help/en/help_column_macros.php b/pandora_console/include/help/en/help_column_macros.php new file mode 100644 index 0000000000..85fe72f39f --- /dev/null +++ b/pandora_console/include/help/en/help_column_macros.php @@ -0,0 +1,14 @@ + +

    Module macros

    + +

    +The following macros are available: +

    +

    +

    diff --git a/pandora_console/include/help/en/help_reconscript_definition.php b/pandora_console/include/help/en/help_reconscript_definition.php index 3259b34dd2..f7562acbfc 100644 --- a/pandora_console/include/help/en/help_reconscript_definition.php +++ b/pandora_console/include/help/en/help_reconscript_definition.php @@ -7,7 +7,7 @@

    The "ReconScripts" allows to work with more flexible capabilities. The recon scripts are developped in an individual way with completely specific targets, such as the network plugins or the agent plugins. Each ReconScript is different and has one purpose.

    -

    Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Recon Server.

    +

    Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Discovery Server.

    A field with importance is:

    diff --git a/pandora_console/include/help/en/help_recontask.php b/pandora_console/include/help/en/help_recontask.php index 0223d66e5b..b56a0a85c6 100644 --- a/pandora_console/include/help/en/help_recontask.php +++ b/pandora_console/include/help/en/help_recontask.php @@ -11,9 +11,9 @@ If you choose to edit or create a new task of network recon, then you should fil Name of the discovery task. It's only a descriptive value to could distinguish the task in case it would have several of them with different values of filter or template.

    -Recon server
    +Discovery server
    -Recon Server assigned to the task. If you have several Recon Servers, then you have to select here which of them you want to do the recon task.

    +Discovery Server assigned to the task. If you have several Discovery Servers, then you have to select here which of them you want to do the recon task.

    Mode
    diff --git a/pandora_console/include/help/en/help_response_macros.php b/pandora_console/include/help/en/help_response_macros.php index 38aae0eeab..37abe115fa 100644 --- a/pandora_console/include/help/en/help_response_macros.php +++ b/pandora_console/include/help/en/help_response_macros.php @@ -32,7 +32,8 @@ The accepted macros are:
  • Event associated module name: _module_name_
  • Event owner user: _owner_user_
  • User ID: _user_id_
  • - +
  • Id of the user who fires the response: _current_user_
  • +

    Custom fields

    diff --git a/pandora_console/include/help/es/help_column_macros.php b/pandora_console/include/help/es/help_column_macros.php new file mode 100644 index 0000000000..b34ede1555 --- /dev/null +++ b/pandora_console/include/help/es/help_column_macros.php @@ -0,0 +1,13 @@ + +

    Macros de módulos

    + +

    +Las siguientes macros están disponibles: +

    + diff --git a/pandora_console/include/help/es/help_response_macros.php b/pandora_console/include/help/es/help_response_macros.php index adc43b4f48..5a860f1548 100644 --- a/pandora_console/include/help/es/help_response_macros.php +++ b/pandora_console/include/help/es/help_response_macros.php @@ -33,6 +33,7 @@ Las macros aceptadas son las siguientes:
  • Nombre del módulo asociado al evento: _module_name_
  • Usuario propietario del evento: _owner_user_
  • Id del usuario: _user_id_
  • +
  • Id del usuario que ejecuta la respuesta: _current_user_
  • Campos personalizados

    diff --git a/pandora_console/include/help/ja/help_column_macros.php b/pandora_console/include/help/ja/help_column_macros.php new file mode 100644 index 0000000000..9d925b1193 --- /dev/null +++ b/pandora_console/include/help/ja/help_column_macros.php @@ -0,0 +1,15 @@ + +

    モジュールマクロ

    + +

    +次のマクロが利用できます: +

    + +

    +

    diff --git a/pandora_console/include/help/ja/help_recontask.php b/pandora_console/include/help/ja/help_recontask.php index 790c2cdb48..182b249653 100644 --- a/pandora_console/include/help/ja/help_recontask.php +++ b/pandora_console/include/help/ja/help_recontask.php @@ -12,7 +12,7 @@ 検出タスクの名前です。フィルターやテンプレートとは異なり、タスクを区別しやすい説明を入れるだけです。

    -自動検出サーバ(Recon server)
    +自動検出サーバ(Discovery server)
    タスクを割り当てる自動検出サーバです。複数の自動検出サーバがある場合は、自動検出タスクをどのサーバで実行するかを選択します。

    diff --git a/pandora_console/include/help/ja/help_response_macros.php b/pandora_console/include/help/ja/help_response_macros.php index 1aa60b38a4..8beebc7a8d 100644 --- a/pandora_console/include/help/ja/help_response_macros.php +++ b/pandora_console/include/help/ja/help_response_macros.php @@ -32,6 +32,7 @@
  • Event associated module name: _module_name_
  • Event owner user: _owner_user_
  • User ID: _user_id_
  • +
  • Id of the user who fires the response: _current_user_
  • Custom fields

    diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 37a9987812..c30736cd8b 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -503,6 +503,14 @@ function module_changed_by_multiple_modules(event, id_module, selected) { selection_mode = "common"; } + var tags_selected = []; + + var tags_to_search = $("#tags").val(); + if (tags_to_search != null) { + if (tags_to_search[0] != -1) { + tags_selected = tags_to_search; + } + } jQuery.post( "ajax.php", { @@ -510,7 +518,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) { get_agents_json_for_multiple_modules: 1, status_module: status_module, "module_name[]": idModules, - selection_mode: selection_mode + selection_mode: selection_mode, + tags: tags_selected }, function(data) { $("#agents").append( diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index e3f7260de4..1ce416e770 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -115,8 +115,21 @@ var TreeController = { } }; + var serviceCounterTitles = { + total_services: { + totals: "Services" + }, + total_agents: { + totals: "Agents" + }, + total_modules: { + totals: "Modules" + } + }; + try { var title = ""; + switch (elementType) { case "group": if ( @@ -144,6 +157,9 @@ var TreeController = { title = defaultCounterTitles[counterType].modules; } break; + case "services": + title = serviceCounterTitles[counterType].totals; + break; default: if ( typeof controller.counterTitles != "undefined" && @@ -169,109 +185,227 @@ var TreeController = { } } - var $counters = $("
    "); - $counters.addClass("tree-node-counters"); - - if (typeof counters.total != "undefined" && counters.total >= 0) { - var $totalCounter = $("
    "); - $totalCounter - .addClass("tree-node-counter") - .addClass("total") - .html(counters.total); - - _processNodeCounterTitle($totalCounter, type, "total"); - - // Open the parentheses - $counters.append(" ("); - - $counters.append($totalCounter); + if (type == "services") { + var $counters = $("
    "); + $counters.addClass("tree-node-counters"); if ( - typeof counters.alerts != "undefined" && - counters.alerts > 0 + counters.total_services + + counters.total_agents + + counters.total_modules > + 0 ) { - var $firedCounter = $("
    "); - $firedCounter - .addClass("tree-node-counter") - .addClass("alerts") - .addClass("orange") - .html(counters.alerts); + // Open the parentheses + $counters.append(" ("); - _processNodeCounterTitle($firedCounter, type, "alerts"); + if ( + typeof counters.total_services != "undefined" && + counters.total_services >= 0 + ) { + var $servicesCounter = $("
    "); + $servicesCounter + .addClass("tree-node-counter") + .addClass("total") + .html(counters.total_services); - $counters.append(" : ").append($firedCounter); + _processNodeCounterTitle( + $servicesCounter, + type, + "total_services" + ); + + $counters.append($servicesCounter); + } else { + var $servicesCounter = $("
    "); + $servicesCounter + .addClass("tree-node-counter") + .addClass("total") + .html("0"); + + _processNodeCounterTitle( + $servicesCounter, + type, + "total_services" + ); + + $counters.append($servicesCounter); + } + + if ( + typeof counters.total_agents != "undefined" && + counters.total_agents > 0 + ) { + var $agentsCounter = $("
    "); + $agentsCounter + .addClass("tree-node-counter") + .html(counters.total_agents); + + _processNodeCounterTitle( + $agentsCounter, + type, + "total_agents" + ); + + $counters.append(" : ").append($agentsCounter); + } else { + var $agentsCounter = $("
    "); + $agentsCounter + .addClass("tree-node-counter") + .addClass("total") + .html("0"); + + _processNodeCounterTitle( + $agentsCounter, + type, + "total_agents" + ); + + $counters.append(" : ").append($agentsCounter); + } + + if ( + typeof counters.total_modules != "undefined" && + counters.total_modules > 0 + ) { + var $modulesCounter = $("
    "); + $modulesCounter + .addClass("tree-node-counter") + .addClass("total") + .html(counters.total_modules); + + _processNodeCounterTitle( + $modulesCounter, + type, + "total_modules" + ); + + $counters.append(" : ").append($modulesCounter); + } else { + var $modulesCounter = $("
    "); + $modulesCounter + .addClass("tree-node-counter") + .addClass("total") + .html("0"); + + _processNodeCounterTitle( + $modulesCounter, + type, + "total_modules" + ); + + $counters.append(" : ").append($modulesCounter); + } + + // Close the parentheses + $counters.append(")"); + + hasCounters = true; } - if ( - typeof counters.critical != "undefined" && - counters.critical > 0 - ) { - var $criticalCounter = $("
    "); - $criticalCounter + } else { + var $counters = $("
    "); + $counters.addClass("tree-node-counters"); + + if (typeof counters.total != "undefined" && counters.total >= 0) { + var $totalCounter = $("
    "); + $totalCounter .addClass("tree-node-counter") - .addClass("critical") - .addClass("red") - .html(counters.critical); + .addClass("total") + .html(counters.total); - _processNodeCounterTitle($criticalCounter, type, "critical"); + _processNodeCounterTitle($totalCounter, type, "total"); - $counters.append(" : ").append($criticalCounter); - } - if ( - typeof counters.warning != "undefined" && - counters.warning > 0 - ) { - var $warningCounter = $("
    "); - $warningCounter - .addClass("tree-node-counter") - .addClass("warning") - .addClass("yellow") - .html(counters.warning); + // Open the parentheses + $counters.append(" ("); - _processNodeCounterTitle($warningCounter, type, "warning"); + $counters.append($totalCounter); - $counters.append(" : ").append($warningCounter); - } - if ( - typeof counters.unknown != "undefined" && - counters.unknown > 0 - ) { - var $unknownCounter = $("
    "); - $unknownCounter - .addClass("tree-node-counter") - .addClass("unknown") - .addClass("grey") - .html(counters.unknown); + if ( + typeof counters.alerts != "undefined" && + counters.alerts > 0 + ) { + var $firedCounter = $("
    "); + $firedCounter + .addClass("tree-node-counter") + .addClass("alerts") + .addClass("orange") + .html(counters.alerts); - _processNodeCounterTitle($unknownCounter, type, "unknown"); + _processNodeCounterTitle($firedCounter, type, "alerts"); - $counters.append(" : ").append($unknownCounter); - } - if ( - typeof counters.not_init != "undefined" && - counters.not_init > 0 - ) { - var $notInitCounter = $("
    "); - $notInitCounter - .addClass("tree-node-counter") - .addClass("not_init") - .addClass("blue") - .html(counters.not_init); + $counters.append(" : ").append($firedCounter); + } + if ( + typeof counters.critical != "undefined" && + counters.critical > 0 + ) { + var $criticalCounter = $("
    "); + $criticalCounter + .addClass("tree-node-counter") + .addClass("critical") + .addClass("red") + .html(counters.critical); - _processNodeCounterTitle($notInitCounter, type, "not_init"); + _processNodeCounterTitle($criticalCounter, type, "critical"); - $counters.append(" : ").append($notInitCounter); - } - if (typeof counters.ok != "undefined" && counters.ok > 0) { - var $okCounter = $("
    "); - $okCounter - .addClass("tree-node-counter") - .addClass("ok") - .addClass("green") - .html(counters.ok); + $counters.append(" : ").append($criticalCounter); + } + if ( + typeof counters.warning != "undefined" && + counters.warning > 0 + ) { + var $warningCounter = $("
    "); + $warningCounter + .addClass("tree-node-counter") + .addClass("warning") + .addClass("yellow") + .html(counters.warning); - _processNodeCounterTitle($okCounter, type, "ok"); + _processNodeCounterTitle($warningCounter, type, "warning"); - $counters.append(" : ").append($okCounter); + $counters.append(" : ").append($warningCounter); + } + if ( + typeof counters.unknown != "undefined" && + counters.unknown > 0 + ) { + var $unknownCounter = $("
    "); + $unknownCounter + .addClass("tree-node-counter") + .addClass("unknown") + .addClass("grey") + .html(counters.unknown); + + _processNodeCounterTitle($unknownCounter, type, "unknown"); + + $counters.append(" : ").append($unknownCounter); + } + if ( + typeof counters.not_init != "undefined" && + counters.not_init > 0 + ) { + var $notInitCounter = $("
    "); + $notInitCounter + .addClass("tree-node-counter") + .addClass("not_init") + .addClass("blue") + .html(counters.not_init); + + _processNodeCounterTitle($notInitCounter, type, "not_init"); + + $counters.append(" : ").append($notInitCounter); + } + if (typeof counters.ok != "undefined" && counters.ok > 0) { + var $okCounter = $("
    "); + $okCounter + .addClass("tree-node-counter") + .addClass("ok") + .addClass("green") + .html(counters.ok); + + _processNodeCounterTitle($okCounter, type, "ok"); + + $counters.append(" : ").append($okCounter); + } } // Close the parentheses @@ -436,7 +570,120 @@ var TreeController = { $content.append($alertImage); } - $content.append(element.alias); + + // Events by agent + if (element.showEventsBtn == 1) { + if (typeof element.eventAgent != "undefined") { + $content.append( + '' + ); + var $eventImage = $( + ' ' + ); + $eventImage.addClass("agent-alerts-fired"); + $eventImage + .click(function(e) { + e.preventDefault(); + + document + .getElementById( + "hiddenAgentsEventsForm-" + element.eventAgent + ) + .submit(); + }) + .css("cursor", "pointer"); + + $content.append($eventImage); + } + } + + $content.append(" " + element.alias); + break; + case "services": + if ( + typeof element.statusImageHTML != "undefined" && + element.statusImageHTML.length > 0 + ) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + + var $serviceDetailImage = $( + ' ' + ); + + if (typeof element.serviceDetail != "undefined") { + $serviceDetailImage + .click(function(e) { + e.preventDefault(); + + window.location.href = element.serviceDetail; + }) + .css("cursor", "pointer"); + + $content.append($serviceDetailImage); + } + + $content.append(" " + element.name); + + break; + case "modules": + if ( + typeof element.statusImageHTML != "undefined" && + element.statusImageHTML.length > 0 + ) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + + // Events by module + if (element.showEventsBtn == 1) { + if (typeof element.eventModule != "undefined") { + $content.append( + '' + ); + var $moduleImage = $( + ' ' + ); + $moduleImage + .click(function(e) { + e.preventDefault(); + + document + .getElementById( + "hiddenModulesEventsForm-" + element.eventModule + ) + .submit(); + }) + .css("cursor", "pointer"); + + $content.append($moduleImage); + } + } + + $content.append(" " + element.name); break; case "module": // Status image @@ -617,6 +864,19 @@ var TreeController = { } $content.append(element.name); break; + case "services": + // Status image + if ( + typeof element.statusImageHTML != "undefined" && + element.statusImageHTML.length > 0 + ) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + $content.append(element.name); + break; default: $content.append(element.name); break; @@ -820,14 +1080,16 @@ var TreeController = { } controller.recipient.empty(); - controller.recipient.html( - "
    " + - controller.foundMessage + - ": " + - controller.tree.length + - "
    " + - "
    " - ); + if (controller.tree.length !== undefined) { + controller.recipient.html( + "
    " + + controller.foundMessage + + ": " + + controller.tree.length + + "
    " + + "
    " + ); + } var $children = _processGroup(this.recipient, this.tree, true); $children.show(); diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css new file mode 100644 index 0000000000..36711a8474 --- /dev/null +++ b/pandora_console/include/styles/discovery.css @@ -0,0 +1,113 @@ +/* + * Discovery css global + */ + +li.discovery { + display: inline-block; + float: left; + width: 250px; + height: 120px; + margin: 15px; + padding-bottom: 50px; +} + +li.discovery > a { + text-decoration: none; + color: #333; +} +li.discovery > a:hover { + color: #000; +} + +li.discovery img { + height: 90px; +} + +li.discovery > a label { + cursor: pointer; +} + +div.data_container { + width: 100%; + height: 100%; + text-align: center; + padding-top: 30px; + padding-bottom: 30px; +} + +div.data_container:hover { + box-shadow: 2px 2px 10px #ddd; +} + +/* + * TODO: This may be at hostdevices.css + */ +.texto { + height: auto; + text-align: center; +} +h1.wizard { + padding: 0; + margin: 0; + margin-top: -1.25em; +} +h1.wizard a { + margin-left: -20px; +} +h1.wizard a:hover { + color: #fff; +} +#text_wizard { + font-weight: bolder; + text-decoration: none; + font-size: 24px; +} +div.arrow_box { + display: inline-block; + position: relative; + background: #ccc; + color: #888; + padding: 1.3em; + margin-left: 20px; + margin-bottom: 10px; + padding-left: 3em; +} + +.arrow_box:before { + top: 50%; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + z-index: 1; +} +.arrow_box.selected { + background: #424242; + color: #ccc; +} + +.arrow_box:after { + left: 0%; + border-left-color: white; + border-width: 20px; + margin-top: -20px; +} + +div.arrow_box:before { + left: 100%; + border-left-color: #ccc; + border-width: 20px; + margin-top: -20px; +} +.arrow_box.selected:before { + border-left-color: #424242; +} + +.arrow_box.selected:hover { + color: #fff; +} +.arrow_box:hover { + color: #000; +} diff --git a/pandora_console/include/styles/hostdevices.css b/pandora_console/include/styles/hostdevices.css new file mode 100644 index 0000000000..461327705e --- /dev/null +++ b/pandora_console/include/styles/hostdevices.css @@ -0,0 +1,3 @@ +/* + * TODO: This may be at hostdevices.css + */ diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index a30978b3a8..001e9a7c32 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -167,6 +167,9 @@ li:hover ul { } /* Godmode images */ +#icon_god-discovery { + background: url(../../images/gm_discovery.menu.png) no-repeat 50% 50%; +} #icon_god-resources { background: url(../../images/gm_resources.menu.png) no-repeat 50% 50%; } diff --git a/pandora_console/include/styles/message_edit.css b/pandora_console/include/styles/message_edit.css new file mode 100644 index 0000000000..f4b2294580 --- /dev/null +++ b/pandora_console/include/styles/message_edit.css @@ -0,0 +1,49 @@ +/* Chat containers */ +.container { + border: 2px solid #dedede; + background-color: #f1f1f1; + border-radius: 5px; + padding: 10px; + margin: 10px 0; +} + +/* Darker chat container */ +.darker { + border-color: #ccc; + background-color: #ddd; +} + +/* Clear floats */ +.container::after { + content: ""; + clear: both; + display: table; +} + +/* Style images */ +.container img { + float: left; + max-width: 60px; + width: 100%; + margin-right: 20px; + border-radius: 50%; +} + +/* Style the right image */ +.container img.right { + float: right; + margin-left: 20px; + margin-right: 0; +} + +/* Style time text */ +.time-right { + float: right; + color: #aaa; +} + +/* Style time text */ +.time-left { + float: left; + color: #999; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 70a9c4920e..a194b45a35 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1,24 +1,30 @@ -/* -Author: The Pandora FMS team -Name: Default theme -Description: The default Pandora FMS theme layout - -// Pandora FMS - http://pandorafms.com -// ========================================================== -// Copyright (c) 2004-2019 Artica Soluciones Tecnológicas S.L - -// 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; 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. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org 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. + * ============================================================================ + */ /* Tree view styles */ /*@import url(tree.css); @@ -911,6 +917,13 @@ input.group_item_min[disabled] { background: #fefefe url(../../images/group_green.disabled.png) no-repeat center !important; } +input.color_cloud_min { + background: #fefefe url(../../images/color_cloud_item.png) no-repeat center !important; +} +input.color_cloud_min[disabled] { + background: #fefefe url(../../images/color_cloud_item.disabled.png) no-repeat + center !important; +} div#cont { position: fixed; @@ -1490,14 +1503,12 @@ table.databox { } .databox > thead > tr > th, -.databox > tbody > tr > th { +.databox > tbody > tr > th, +.databox > thead > tr > th a { padding: 9px 7px; font-weight: normal; color: #fff; } -.databox > td { - #border-bottom: 1px solid #e2e2e2; -} .databox > th * { color: #fff; @@ -2053,82 +2064,58 @@ div#logo_text3 { /* TABLAS */ /* Cells divs to set individual styles with the table objects */ -div.cellBold { - width: 100%; - height: 100%; +td.cellBold { font-weight: bold; } -div.cellRight { - width: 100%; - height: 100%; +td.cellRight { text-align: right; } -div.cellCenter { - width: 100%; - height: 100%; +td.cellCenter { text-align: center; } -div.cellWhite { - width: 100%; - height: 100%; +td.cellWhite { background: #fff; color: #111; } -div.cellNormal { - width: 100%; - height: 100%; +td.cellNormal { background: #6eb432; color: #fff; } -div.cellCritical { - width: 100%; - height: 100%; +td.cellCritical { background: #f85858; color: #fff; } -div.cellWarning { - width: 100%; - height: 100%; +td.cellWarning { background: #ffea59; color: #111; } -div.cellUnknown { - width: 100%; - height: 100%; +td.cellUnknown { background: #aaaaaa; color: #ffffff; } -div.cellNotInit { - width: 100%; - height: 100%; +td.cellNotInit { background: #3ba0ff; color: #ffffff; } -div.cellAlert { - width: 100%; - height: 100%; +td.cellAlert { background: #ff8800; color: #111; } -div.cellBorder1 { - width: 100%; - height: 100%; +td.cellBorder1 { border: 1px solid #666; } -div.cellBig { - width: 100%; - height: 100%; +td.cellBig { font-size: 18px; } @@ -4268,293 +4255,168 @@ div#dialog_messages table th:last-child { text-align: right; } -/* --- JQUERY-UI --- */ -.ui-button-text-only .ui-button-text { - font-family: "nunito", sans-serif; - font-size: 9pt; - color: #82b92e; -} -.ui-datepicker .ui-datepicker-title *, -.ui-datepicker th * { - color: white; -} -.ui-datepicker .ui-datepicker-title select, -.ui-datepicker .ui-datepicker-title option { - color: #111 !important; -} -.ui-dialog .ui-dialog-titlebar { - display: inherit; - text-align: center; - padding: 0.4em 1em; - height: 30px; - position: relative; - background-color: #82b92e !important; -} -.ui-dialog .ui-dialog-title { - font-family: "Nunito", sans-serif; - margin: 0.1em 0 !important; - white-space: nowrap !important; - width: 100% !important; - overflow: hidden !important; - text-overflow: ellipsis !important; - font-size: 11pt; - position: relative; - top: 5px; - float: none !important; -} -.ui-dialog .ui-dialog-titlebar-close { - position: absolute !important; - right: 1em !important; - width: 21px !important; - margin: 0px 0 0 0 !important; - padding: 1px !important; - height: 20px !important; - bottom: 30% !important; - top: 20% !important; -} -.ui-dialog .ui-dialog-content { - position: relative !important; - border: 0; - padding: 0.5em 1em !important; - background: none !important; - overflow: auto !important; - margin-bottom: 1em; -} -.ui-dialog .ui-dialog-buttonpane { - text-align: left; - border-width: 1px 0 0 0; - background-image: none; - margin-top: 0.5em; - padding: 0.3em 1em 0.5em 0.4em; -} -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: right; -} -.ui-dialog .ui-dialog-buttonpane button { - margin: 0.5em 1em 0.5em 0 !important; - cursor: pointer !important; - background: white !important; - background-color: white !important; - border: 1px solid #82b92e !important; - min-height: 35px !important; - width: 90px !important; -} -.ui-widget-content { - background: #ffffff url(include/styles/images/ui-bg_flat_75_ffffff_40x100.png) - 50% 50% repeat-x; -} -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default { - margin-top: 3px; - border: 1px solid #d3d3d3 !important; - border-bottom: 0 !important; - background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% - repeat-x !important; - font-weight: normal !important; - color: #555555 !important; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 0 !important; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 0 !important; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 0 !important; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 0 !important; -} -#ui-datepicker-div { - border-color: #b1b1b1; - background: #ffffff; -} -.ui-widget-header { - background: #b1b1b1 !important; - color: #ffffff !important; -} -.ui-datepicker-calendar th { - background-color: #3f3f3f; -} -.ui-dialog .ui-widget-header { - background-color: #82b92e; -} -.ui_tpicker_hour, -.ui_tpicker_minute, -.ui_tpicker_second, -.ui-slider-handle { - border: 1px solid #aaaaaa !important; -} -.ui-timepicker-div dd { - margin: 0px 15px 0px 15px; -} -.ui-timepicker-div .ui-datepicker-title { - color: white; -} -.ui-datepicker-buttonpane button { - border-color: #b1b1b1 !important; -} -.ui-datepicker-buttonpane .ui-datepicker-current { - margin-left: 0.2em !important; -} -.ui-dialog .ui-widget-content { - border: 0px !important; -} -.ui-dialog { - box-shadow: 5px 5px 19px #4e4e4e; - border: 0px !important; - padding: 0 !important; -} -.ui-dialog-titlebar { - border: 0px !important; -} -.ui-dialog-titlebar .ui-icon-closethick, -.ui-dialog-titlebar .ui-state-default, -.ui-dialog-titlebar .ui-state-hover, -.ui-dialog-titlebar button { - background: transparent; - border: 0px; -} +/* + * --------------------------------------------------------------------- + * - Notifications + * --------------------------------------------------------------------- + */ -.ui-dialog-title { - color: #ffffff; - font-size: 9pt; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Verdana, Arial, sans-serif !important; -} - -a.ui-button:active, -.ui-button:active, -.ui-button.ui-state-active:hover, -.ui-state-focus .ui-widget-content, -.ui-state-focus .ui-widget-header, -.ui-state-focus .ui-button:hover, -.ui-button:focus { - background: transparent !important; - border: none !important; -} - -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover { - border: 1px solid #999999 !important; - border-bottom: 0 !important; - background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% - repeat-x !important; -} - -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active { - border: 1px solid #aaaaaa !important; - border-bottom: 0 !important; - background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% - repeat-x !important; - font-weight: normal !important; - color: #212121 !important; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #212121 !important; -} - -ul.ui-front { - z-index: 1000000 !important; - padding-right: 0px !important; -} - -ul.ui-front li { - padding: 3px !important; -} - -ul.ui-front li:hover { - background-color: #e1e3e1 !important; -} - -ul.ui-front li a.ui-menu-item-wrapper { - background: transparent !important; - border: none !important; -} - -ul.ui-front li a.ui-menu-item-wrapper span { - padding-left: 5px !important; -} - -ul.ui-front li a.ui-menu-item-wrapper:hover { - text-decoration: none !important; -} -/* --- END - JQUERY-UI --- */ - -.toogle_switch { - position: relative; - display: inline-block; - width: 47px; - height: 24px; -} - -.toogle_switch input { - opacity: 0; - width: 0; - height: 0; -} - -.slider { - position: absolute; +.notification-ball { + border: white solid 2px; + border-radius: 50px; + width: 18px; + height: 18px; + display: flex; + justify-content: center; + align-items: center; cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: #ccc; - -webkit-transition: 0.7s; - transition: 0.7s; - border-radius: 34px; } -.slider:before { - position: absolute; - content: ""; - height: 16px; - width: 16px; - left: 4px; - bottom: 4px; - background-color: white; - -webkit-transition: 0.7s; - transition: 0.7s; - border-radius: 50%; -} - -input:checked + .slider { +.notification-ball-no-messages { background-color: #82b92e; + cursor: pointer; +} +.notification-ball-new-messages { + background-color: #fc4444; } -input:focus + .slider { - box-shadow: 0 0 1px #82b92e; +#notification-wrapper { + background: white; + border: #a5a5a5 solid 1px; + z-index: 900000; + position: absolute; + width: 400px; + margin-top: -5px; + border-radius: 5px; +} +#notification-wrapper::before { + content: ""; + display: block; + position: absolute; + width: 0px; + height: 0; + border-color: transparent; + border-width: 12px; + border-style: solid; + bottom: 100%; + left: 78%; + left: calc(78% - 2px); + margin-left: -12px; + border-bottom-color: white; +} +#notification-wrapper-inner { + max-height: 400px; + overflow: auto; +} +#notification-wrapper-shadow { + height: 100%; + width: 100%; + background: #111; + position: fixed; + z-index: 9009; + top: 0; + opacity: 0.3; +} +.notification-item { + background: whitesmoke; + height: 100px; + margin: 7px; + border: #e4e4e4 solid 1px; + display: flex; + flex-flow: row nowrap; + align-items: center; + padding: 5px; +} +.notification-item:hover { + border: #ccc solid 1px; +} +.notification-item > * { + padding-left: 15px; + pointer-events: none; } -input:checked + .slider:before { - -webkit-transform: translateX(26px); - -ms-transform: translateX(26px); - transform: translateX(26px); - background-color: rgb(197, 235, 192); +.notification-item:hover { + text-decoration: none; +} + +.notification-info { + width: 87%; + display: flex; + flex-flow: column nowrap; + overflow: hidden; + max-height: 83px; + line-height: 1.4em; +} +.notification-item img { + max-width: 100%; + max-height: 100%; +} +.notification-title { + margin: 0; +} +.notification-subtitle { + margin: 0; + color: #373737; +} + +.global-config-notification-title { + display: flex; + flex-direction: row; + align-items: center; +} + +.global-config-notification-title h2 { + margin-left: 10px; +} + +.global-config-notification-checkboxes :first-child { + font-weight: bold; +} + +.global-config-notification-selectors { + display: flex; + flex-direction: row; + margin-bottom: 10px; +} + +.global-config-notification-selectors h4 { + margin: 0; +} + +.global-config-notification-single-selector, +.global_config_notifications_dialog_add select { + display: flex; + width: 100%; + padding: 0 10px; +} + +.global-config-notification-single-selector :first-child, +.global-config-notification-single-selector :first-child select { + width: 99%; +} + +.global-config-notification-single-selector :last-child, +.global_config_notifications_dialog_add_wrapper { + flex-direction: column; + display: flex; + justify-content: flex-end; +} + +.global_config_notifications_dialog_add { + display: flex; + flex-direction: row; + margin: 8px; +} + +.global_config_notifications_two_ways_form_arrows { + display: flex; + flex-flow: column; + justify-content: center; + margin: 0 5px; +} + +.global_config_notifications_two_ways_form_arrows img { + margin: 15px 0; } /* jQuery dialog */ @@ -4562,3 +4424,146 @@ input:checked + .slider:before { display: none; } /* jQuery dialog */ + +/* --- SWITCH --- */ +.p-switch { + position: relative; + display: inline-block; + width: 30px; + height: 17px; +} + +.p-switch input { + opacity: 0; + width: 0; + height: 0; +} + +.p-slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: 0.4s; + transition: 0.4s; + border-radius: 34px; +} + +.p-slider:before { + position: absolute; + content: ""; + height: 13px; + width: 13px; + left: 2px; + bottom: 2px; + background-color: white; + -webkit-transition: 0.4s; + transition: 0.4s; + border-radius: 50%; +} + +input:checked + .p-slider { + background-color: #82b92e; +} + +input:focus + .p-slider { + box-shadow: 0 0 1px #82b92e; +} + +input:checked + .p-slider:before { + -webkit-transform: translateX(13px); + -ms-transform: translateX(13px); + transform: translateX(13px); +} + +/* --- END SWITCH --- */ + +/* --- TOAST --- */ +#notifications-toasts-wrapper { + position: fixed; + right: 20px; + top: 70px; + width: 270px; + height: 100%; + z-index: 6; + pointer-events: none; +} + +.snackbar { + max-width: 270px; + background-color: #333; + color: #fff; + text-align: center; + /* border-radius: 2px; */ + padding: 16px; + margin: 10px; + border-radius: 4px; + visibility: hidden; + pointer-events: all; +} + +.snackbar.show { + visibility: visible; + -webkit-animation: fadein 0.5s, fadeout 0.5s 7.5s; + animation: fadein 0.5s, fadeout 0.5s 7.5s; +} + +.snackbar p, +.snackbar h3 { + text-align: left; + margin: 0; + pointer-events: none; +} +.snackbar h3 { + color: white; + margin-bottom: 10px; +} + +@-webkit-keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + to { + bottom: 30px; + opacity: 1; + } +} + +@keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + to { + bottom: 30px; + opacity: 1; + } +} + +@-webkit-keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + to { + bottom: 0; + opacity: 0; + } +} + +@keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + to { + bottom: 0; + opacity: 0; + } +} + +/* --- END TOAST --- */ diff --git a/pandora_console/include/styles/pandoraPDF.css b/pandora_console/include/styles/pandoraPDF.css new file mode 100644 index 0000000000..37d527c30b --- /dev/null +++ b/pandora_console/include/styles/pandoraPDF.css @@ -0,0 +1,78 @@ +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org 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. + * ============================================================================ + */ +table.header_table { + width: 100%; +} + +table.header_table thead tr th, +table.header_table tbody tr td { + padding: 10px; +} + +thead.header_tr tr { + background: #e6e6e6; +} + +thead.header_tr tr th { + font-weight: normal; + text-align: right; +} + +thead.header_tr tr th.th_first { + font-weight: bold; + text-align: left; +} + +thead.header_tr tr th.th_description { + background-color: #f5f5f5; + color: #1c1c1c; + text-align: justify; +} + +table.table_beauty { + border-collapse: collapse; + width: 100%; +} + +table.table_beauty tbody tr td { + padding: 5px; + border: 0.1pt solid #acacac; +} + +table.databox { + margin-bottom: 20px; +} + +th.title_table_pdf { + background-color: #acacac; + padding: 15px; +} + +table.table_agent_module tr td { + padding: 5px; +} diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css new file mode 100644 index 0000000000..869ea85f2c --- /dev/null +++ b/pandora_console/include/styles/wizard.css @@ -0,0 +1,25 @@ +/* + * Discovery > Wizard css global style + */ + +ul.wizard { +} + +ul.wizard li { + padding: 10px; +} + +ul.wizard li > label:not(.p-switch) { + width: 250px; + vertical-align: top; + display: inline-block; +} + +ul.wizard li > textarea { + width: 250px; + display: inline-block; +} + +.hidden { + display: none; +} diff --git a/pandora_console/index.php b/pandora_console/index.php index ad4b93465a..321b5956dc 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1363,4 +1363,3 @@ require 'include/php_to_js_values.php'; if (__PAN_XHPROF__ === 1) { pandora_xhprof_display_result('node_index'); } - diff --git a/pandora_console/install.php b/pandora_console/install.php index 5608de3f79..996fff9dcc 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -128,8 +128,8 @@
    Checking software dependencies'; echo ''; $res = 0; - $res += check_variable(phpversion(), '5.2', 'PHP version >= 5.2', 1); + $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); $res += check_extension('gd', 'PHP GD extension'); $res += check_extension('ldap', 'PHP LDAP extension'); $res += check_extension('snmp', 'PHP SNMP extension'); @@ -564,7 +564,6 @@ function install_step2() font-size: 8.5pt;margin-top: 2px; font-weight: bolder;'>DB Engines"; echo ''; - check_extension('mysql', 'PHP MySQL extension'); check_extension('mysqli', 'PHP MySQL(mysqli) extension'); echo '
    '; echo '
    '; diff --git a/pandora_console/mobile/operation/alerts.php b/pandora_console/mobile/operation/alerts.php index b95ba9492d..8991f0d8b3 100644 --- a/pandora_console/mobile/operation/alerts.php +++ b/pandora_console/mobile/operation/alerts.php @@ -313,7 +313,7 @@ class Alerts $row = []; if (isset($this->columns['agent']) && $this->columns['agent']) { - $row[__('Agent')] = sprintf($disabled_style, io_safe_output($alert['agent_name'])); + $row[__('Agent')] = sprintf($disabled_style, io_safe_output($alert['agent_alias'])); } $row[__('Module')] = sprintf( diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index ada6cd6ec6..0dd536ac7f 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -37,12 +37,37 @@ enterprise_include_once('include/functions_metaconsole.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); if (! defined('METACONSOLE')) { - // Header - ui_print_page_header( - __('Monitor detail'), - 'images/brick.png', - false - ); + $section = (string) get_parameter('section', 'view'); + + $buttons['fields'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'', + 'operation' => true, + ]; + + $buttons['view'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/list.png', true, ['title' => __('View')]).'', + 'operation' => true, + ]; + + switch ($section) { + case 'fields': + $buttons['fields']['active'] = true; + $subpage = ' - '.__('Custom fields'); + break; + + default: + $buttons['view']['active'] = true; + break; + } + + ui_print_page_header(__('Monitor detail').$subpage, '', false, '', true, $buttons); + + if ($section == 'fields') { + include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php'; + exit(); + } } else { ui_meta_print_header(__('Monitor view')); } @@ -1045,48 +1070,77 @@ if (!empty($result)) { $table->size = []; $table->align = []; - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->head[0] = ''.__('P.').''; + $show_fields = explode(',', $config['status_monitor_fields']); + + + if (in_array('policy', $show_fields)) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + $table->head[0] = ''.__('P.').''; + } } - $table->head[1] = __('Agent'); - $table->head[1] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectAgentNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectAgentNameDown, 'alt' => 'down']).''; - - $table->head[2] = __('Data Type'); - $table->head[2] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectTypeUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectTypeDown, 'alt' => 'down']).''; - - $table->align[2] = 'left'; - - $table->head[3] = __('Module name'); - $table->head[3] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown, 'alt' => 'down']).''; - - $table->head[4] = __('Server type'); - $table->head[4] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown, 'alt' => 'down']).''; - - $table->head[5] = __('Interval'); - $table->head[5] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown, 'alt' => 'down']).''; - $table->align[5] = 'left'; - - $table->head[6] = __('Status'); - $table->head[6] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectStatusDown, 'alt' => 'down']).''; - - $table->align[6] = 'left'; - - $table->head[7] = __('Graph'); - $table->align[7] = 'left'; - - $table->head[8] = __('Warn'); - $table->align[8] = 'left'; - - $table->head[9] = __('Data'); - $table->align[9] = 'left'; - if (is_metaconsole()) { - $table->head[9] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectStatusDown, 'alt' => 'down']).''; + if (in_array('agent', $show_fields) || is_metaconsole()) { + $table->head[1] = __('Agent'); + $table->head[1] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectAgentNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectAgentNameDown, 'alt' => 'down']).''; } - $table->head[10] = __('Timestamp'); - $table->head[10] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectTimestampUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectTimestampDown, 'alt' => 'down']).''; - $table->align[10] = 'left'; + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $table->head[2] = __('Data Type'); + $table->head[2] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectTypeUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectTypeDown, 'alt' => 'down']).''; + + $table->align[2] = 'left'; + } + + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $table->head[3] = __('Module name'); + $table->head[3] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown, 'alt' => 'down']).''; + } + + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $table->head[4] = __('Server type'); + $table->head[4] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown, 'alt' => 'down']).''; + } + + if (in_array('interval', $show_fields) || is_metaconsole()) { + $table->head[5] = __('Interval'); + $table->head[5] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown, 'alt' => 'down']).''; + $table->align[5] = 'left'; + } + + if (in_array('status', $show_fields) || is_metaconsole()) { + $table->head[6] = __('Status'); + $table->head[6] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectStatusDown, 'alt' => 'down']).''; + + $table->align[6] = 'left'; + } + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $table->head[7] = __('Graph'); + $table->align[7] = 'left'; + } + + if (in_array('warn', $show_fields) || is_metaconsole()) { + $table->head[8] = __('Warn'); + $table->align[8] = 'left'; + } + + if (in_array('data', $show_fields) || is_metaconsole()) { + $table->head[9] = __('Data'); + $table->align[9] = 'left'; + if (is_metaconsole()) { + $table->head[9] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectStatusDown, 'alt' => 'down']).''; + } + } + + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + $table->head[10] = __('Timestamp'); + $table->head[10] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectTimestampUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectTimestampDown, 'alt' => 'down']).''; + $table->align[10] = 'left'; + } + + if (in_array('to_critical', $show_fields)) { + $table->head[11] = __('Last status change'); + } $id_type_web_content_string = db_get_value( 'id_tipo', @@ -1110,459 +1164,487 @@ if (!empty($result)) { ] ); - // Fixed the goliat sends the strings from web - // without HTML entities + // Fixed the goliat sends the strings from web + // without HTML entities if ($is_web_content_string) { $row['datos'] = io_safe_input($row['datos']); } - // Fixed the data from Selenium Plugin + // Fixed the data from Selenium Plugin if ($row['datos'] != strip_tags($row['datos'])) { $row['datos'] = io_safe_input($row['datos']); } - $data = []; - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if (is_metaconsole()) { - $node = metaconsole_get_connection_by_id($row['server_id']); - if (metaconsole_load_external_db($node) !== NOERR) { - // Restore the default connection. - metaconsole_restore_db(); - $errors++; - break; - } - } + $data = []; - $policyInfo = policies_info_module_policy($row['id_agente_modulo']); - - if ($policyInfo === false) { - $data[0] = ''; - } else { - $linked = policies_is_module_linked($row['id_agente_modulo']); - - $adopt = false; - if (policies_is_module_adopt($row['id_agente_modulo'])) { - $adopt = true; - } - - if ($linked) { - if ($adopt) { - $img = 'images/policies_brick.png'; - $title = __('(Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/policies.png'; - $title = $policyInfo['name_policy']; + if (in_array('policy', $show_fields) || is_metaconsole()) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + if (is_metaconsole()) { + $node = metaconsole_get_connection_by_id($row['server_id']); + if (metaconsole_load_external_db($node) !== NOERR) { + // Restore the default connection. + metaconsole_restore_db(); + $errors++; + break; } + } + + $policyInfo = policies_info_module_policy($row['id_agente_modulo']); + + if ($policyInfo === false) { + $data[0] = ''; } else { - if ($adopt) { - $img = 'images/policies_not_brick.png'; - $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; + $linked = policies_is_module_linked($row['id_agente_modulo']); + + $adopt = false; + if (policies_is_module_adopt($row['id_agente_modulo'])) { + $adopt = true; + } + + if ($linked) { + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ').$policyInfo['name_policy']; + } else { + $img = 'images/policies.png'; + $title = $policyInfo['name_policy']; + } } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ').$policyInfo['name_policy']; + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; + } else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ').$policyInfo['name_policy']; + } + } + + if (is_metaconsole()) { + $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; + } else { + $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; } } if (is_metaconsole()) { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } else { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; + metaconsole_restore_db(); } } - - if (is_metaconsole()) { - metaconsole_restore_db(); - } } - $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; + if (in_array('agent', $show_fields) || is_metaconsole()) { + $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; - // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view - if (defined('METACONSOLE')) { - $agent_link = ''; - $agent_alias = ui_print_truncate_text( - $agent_alias, - 'agent_small', - false, - true, - false, - '[…]', - 'font-size:7.5pt;' - ); - if (can_user_access_node()) { + // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view + if (defined('METACONSOLE')) { + $agent_link = ''; + $agent_alias = ui_print_truncate_text( + $agent_alias, + 'agent_small', + false, + true, + false, + '[…]', + 'font-size:7.5pt;' + ); + if (can_user_access_node()) { $data[1] = $agent_link.''.$agent_alias.''; + } else { + $data[1] = $agent_alias; + } } else { - $data[1] = $agent_alias; - } - } else { $data[1] = ''; $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); $data[1] .= ''; + } } + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true); + $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); + if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { + $show_edit_icon = true; + if (defined('METACONSOLE')) { + if (!can_user_access_node()) { + $show_edit_icon = false; + } - $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true); - $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { - $show_edit_icon = true; - if (defined('METACONSOLE')) { - if (!can_user_access_node()) { - $show_edit_icon = false; + $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); + } else { + $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; } - $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); - } else { - $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; + if ($show_edit_icon) { + $data[2] .= ''.html_print_image( + 'images/config.png', + true, + [ + 'alt' => '0', + 'border' => '', + 'title' => __('Edit'), + ] + ).''; + } + } + } + + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $data[3] = ui_print_truncate_text($row['module_name'], 'agent_small', false, true, true); + if ($row['extended_info'] != '') { + $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); } - if ($show_edit_icon) { - $data[2] .= ''.html_print_image( - 'images/config.png', + if ($row['tags'] != '') { + $data[3] .= html_print_image( + '/images/tag_red.png', true, [ - 'alt' => '0', - 'border' => '', - 'title' => __('Edit'), + 'title' => $row['tags'], + 'style' => 'width: 20px; margin-left: 3px;', ] - ).''; - } - } - - $data[3] = ui_print_truncate_text($row['module_name'], 'agent_small', false, true, true); - if ($row['extended_info'] != '') { - $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); - } - - if ($row['tags'] != '') { - $data[3] .= html_print_image( - '/images/tag_red.png', - true, - [ - 'title' => $row['tags'], - 'style' => 'width: 20px; margin-left: 3px;', - ] - ); - } - - $data[4] = servers_show_type($row['id_modulo']); - - $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); - - if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 - || $row['module_type'] > 23) && $row['module_type'] != 100) - ) { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NOT INIT'), - true - ); - } else if ($row['estado'] == 0) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.$row['datos'], - true ); } - } else if ($row['estado'] == 1) { - if (is_numeric($row['datos'])) { + } + + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $data[4] = servers_show_type($row['id_modulo']); + } + + + if (in_array('interval', $show_fields) || is_metaconsole()) { + $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); + } + + if (in_array('status', $show_fields) || is_metaconsole()) { + if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 + || $row['module_type'] > 23) && $row['module_type'] != 100) + ) { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NOT INIT'), + true + ); + } else if ($row['estado'] == 0) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_OK, + __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_OK, + __('NORMAL').': '.$row['datos'], + true + ); + } + } else if ($row['estado'] == 1) { + if (is_numeric($row['datos'])) { $data[6] = ui_print_status_image( STATUS_MODULE_CRITICAL, __('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.$row['datos'], - true - ); - } - } else if ($row['estado'] == 2) { - if (is_numeric($row['datos'])) { + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('CRITICAL').': '.$row['datos'], + true + ); + } + } else if ($row['estado'] == 2) { + if (is_numeric($row['datos'])) { $data[6] = ui_print_status_image( STATUS_MODULE_WARNING, __('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_WARNING, + __('WARNING').': '.$row['datos'], + true + ); + } } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.$row['datos'], - true - ); - } - } else { - $last_status = modules_get_agentmodule_last_status( - $row['id_agente_modulo'] - ); - switch ($last_status) { - case 0: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { + $last_status = modules_get_agentmodule_last_status( + $row['id_agente_modulo'] + ); + switch ($last_status) { + case 0: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { $data[6] = ui_print_status_image( STATUS_MODULE_UNKNOWN, __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.$row['datos'], true ); - } - break; + } + break; - case 1: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.$row['datos'], - true - ); - } - break; + case 1: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.$row['datos'], + true + ); + } + break; - case 2: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.$row['datos'], - true - ); - } - break; - } - } - - $data[7] = ''; - - $acl_graphs = false; - - // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions - if (!is_metaconsole()) { - $acl_graphs = check_acl($config['id_user'], $row['id_group'], 'RR'); - } else { - $acl_graphs = true; - } - - if ($row['history_data'] == 1 && $acl_graphs) { - $graph_type = return_graphtype($row['module_type']); - - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); - $win_handle = 'day_'.$handle; - - $graph_params = [ - 'type' => $graph_type, - 'period' => SECONDS_1DAY, - 'id' => $row['id_agente_modulo'], - 'label' => base64_encode($row['module_name']), - 'refresh' => SECONDS_10MINUTES, - ]; - - if (is_metaconsole() && isset($row['server_id'])) { - // Set the server id - $graph_params['server'] = $row['server_id']; - } - - $graph_params_str = http_build_query($graph_params); - - $link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')'; - - $data[7] = get_module_realtime_link_graph($row); - - if (!is_snapshot_data($row['datos'])) { - $data[7] .= ''.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).''; - } - - $data[7] .= ''.html_print_image( - 'images/binary.png', - true, - [ - 'border' => '0', - 'alt' => '', - ] - ).''; - - $data[7] .= ''.$row['module_name'].''; - } - - $data[8] = ui_print_module_warn_value( - $row['max_warning'], - $row['min_warning'], - $row['str_warning'], - $row['max_critical'], - $row['min_critical'], - $row['str_critical'] - ); - - if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { - if ($config['render_proc']) { - switch ($row['module_type']) { case 2: - case 6: - case 9: - case 18: - case 21: - case 31: - if ($row['datos'] >= 1) { - $salida = $config['render_proc_ok']; + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); } else { - $salida = $config['render_proc_fail']; - } - break; - - default: - switch ($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - $salida = human_milliseconds_to_string($row['datos']); - } else { - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - } - break; - - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.$row['datos'], + true + ); } break; } + } + } + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $data[7] = ''; + + $acl_graphs = false; + + // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions + if (!is_metaconsole()) { + $acl_graphs = check_acl($config['id_user'], $row['id_group'], 'RR'); } else { - switch ($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - $salida = human_milliseconds_to_string($row['datos']); - } else { - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - } - break; + $acl_graphs = true; + } - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; + if ($row['history_data'] == 1 && $acl_graphs) { + $graph_type = return_graphtype($row['module_type']); + + $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); + $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); + $win_handle = 'day_'.$handle; + + $graph_params = [ + 'type' => $graph_type, + 'period' => SECONDS_1DAY, + 'id' => $row['id_agente_modulo'], + 'label' => base64_encode($row['module_name']), + 'refresh' => SECONDS_10MINUTES, + ]; + + if (is_metaconsole() && isset($row['server_id'])) { + // Set the server id + $graph_params['server'] = $row['server_id']; } - } - // Show units ONLY in numeric data types - if (isset($row['unit'])) { - $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida .= ' '.''.io_safe_output($row['unit']).''; - if (strlen($salida) > $config['agent_size_text_small']) { - $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); - // clean tag - $text_aux = explode(''.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).''; } - } - } else { - // Fixed the goliat sends the strings from web - // without HTML entities - if ($is_web_content_string) { - $module_value = $row['datos']; - } else { - $module_value = io_safe_output($row['datos']); - } - $is_snapshot = is_snapshot_data($module_value); - $is_large_image = is_text_to_black_string($module_value); - - if (($config['command_snapshot']) && ($is_snapshot || $is_large_image)) { - $link = ui_get_snapshot_link( + $data[7] .= ''.html_print_image( + 'images/binary.png', + true, [ - 'id_module' => $row['id_agente_modulo'], - 'interval' => $row['current_interval'], - 'module_name' => $row['module_name'], - 'id_node' => $row['server_id'], + 'border' => '0', + 'alt' => '', ] - ); - $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - if ($module_value == $sub_string) { - if ($module_value == 0 && !$sub_string) { - $salida = 0; - } else { - $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida = $row['datos']; - } + ).''; + + $data[7] .= ''.$row['module_name'].''; + } + } + + if (in_array('warn', $show_fields) || is_metaconsole()) { + $data[8] = ui_print_module_warn_value( + $row['max_warning'], + $row['min_warning'], + $row['str_warning'], + $row['max_critical'], + $row['min_critical'], + $row['str_critical'] + ); + + if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { + if ($config['render_proc']) { + switch ($row['module_type']) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ($row['datos'] >= 1) { + $salida = $config['render_proc_ok']; + } else { + $salida = $config['render_proc_fail']; + } + break; + + default: + switch ($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { + $salida = human_milliseconds_to_string($row['datos']); + } else { + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + } + break; + + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + } + break; } } else { - // Fixed the goliat sends the strings from web - // without HTML entities - if ($is_web_content_string) { - $sub_string = substr($row['datos'], 0, 12); + switch ($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { + $salida = human_milliseconds_to_string($row['datos']); + } else { + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + } + break; + + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + } + } + + // Show units ONLY in numeric data types + if (isset($row['unit'])) { + $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); + if ($data_macro) { + $salida = $data_macro; } else { - // Fixed the data from Selenium Plugin - if ($module_value != strip_tags($module_value)) { - $module_value = io_safe_input($module_value); + $salida .= ' '.''.io_safe_output($row['unit']).''; + if (strlen($salida) > $config['agent_size_text_small']) { + $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); + // clean tag + $text_aux = explode(' $row['id_agente_modulo'], + 'interval' => $row['current_interval'], + 'module_name' => $row['module_name'], + 'id_node' => $row['server_id'], + ] + ); + $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; + } else { + $sub_string = substr(io_safe_output($row['datos']), 0, 12); + if ($module_value == $sub_string) { + if ($module_value == 0 && !$sub_string) { + $salida = 0; + } else { + $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); + if ($data_macro) { + $salida = $data_macro; + } else { + $salida = $row['datos']; + } + } + } else { + // Fixed the goliat sends the strings from web + // without HTML entities + if ($is_web_content_string) { $sub_string = substr($row['datos'], 0, 12); } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); + // Fixed the data from Selenium Plugin + if ($module_value != strip_tags($module_value)) { + $module_value = io_safe_input($module_value); + $sub_string = substr($row['datos'], 0, 12); + } else { + $sub_string = substr(io_safe_output($row['datos']), 0, 12); + } } - } - if ($module_value == $sub_string) { - $salida = $module_value; - } else { - $salida = '".$module_value.''.'".''.$sub_string.' '."".html_print_image('images/rosette.png', true).''; + if ($module_value == $sub_string) { + $salida = $module_value; + } else { + $salida = '".$module_value.''.'".''.$sub_string.' '."".html_print_image('images/rosette.png', true).''; + } } } } } + if (in_array('data', $show_fields) || is_metaconsole()) { $data[9] = $salida; - - if ($row['module_interval'] > 0) { - $interval = $row['module_interval']; - } else { - $interval = $row['agent_interval']; } - if ($row['estado'] == 3) { - $option = [ - 'html_attr' => 'class="redb"', - 'style' => 'font-size:7pt;', - ]; - } else { - $option = ['style' => 'font-size:7pt;']; + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + if ($row['module_interval'] > 0) { + $interval = $row['module_interval']; + } else { + $interval = $row['agent_interval']; + } + + if ($row['estado'] == 3) { + $option = [ + 'html_attr' => 'class="redb"', + 'style' => 'font-size:7pt;', + ]; + } else { + $option = ['style' => 'font-size:7pt;']; + } + + $data[10] = ui_print_timestamp($row['utimestamp'], true, $option); } - $data[10] = ui_print_timestamp($row['utimestamp'], true, $option); + if (in_array('to_critical', $show_fields)) { + $change_status_timestamp = db_get_sql('SELECT utimestamp FROM tevento WHERE id_agentmodule='.$row['id_agente_modulo'].' ORDER BY utimestamp DESC'); + $data[11] = ui_print_timestamp($change_status_timestamp, true, $option); + } array_push($table->data, $data); } diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index e3171f61f4..5578b9182f 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1,17 +1,32 @@ $v) { @@ -139,7 +164,7 @@ if (is_ajax()) { $id_agents = get_parameter('id_agents'); $selection = get_parameter('selection'); - // No filter by module group + // No filter by module group. $modules = select_modules_for_agent_group(0, $id_agents, $selection, false, true); echo json_encode($modules); return; @@ -177,11 +202,14 @@ if (is_ajax()) { $nameModules = get_parameter('module_name'); $selection_mode = get_parameter('selection_mode', 'common') == 'all'; $status_modulo = (int) get_parameter('status_module', -1); - + $tags_selected = (array) get_parameter('tags', []); $names = select_agents_for_module_group( $nameModules, $selection_mode, - ['status' => $status_modulo], + [ + 'status' => $status_modulo, + 'tags' => $tags_selected, + ], 'AW' ); @@ -311,28 +339,28 @@ if (is_ajax()) { } if (!empty($module_name)) { - $filter .= " AND t1.nombre COLLATE utf8_general_ci LIKE '%$module_name%'"; + $filter .= " AND t1.nombre COLLATE utf8_general_ci LIKE '%".$module_name."%'"; } - // Status selector + // Status selector. if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) { - // Normal + // Normal. $sql_conditions .= ' estado = 0 AND utimestamp > 0 ) OR (t1.id_tipo_modulo IN(21,22,23,100)) '; } else if ($status_modulo == AGENT_MODULE_STATUS_CRITICAL_BAD) { - // Critical + // Critical. $sql_conditions .= ' estado = 1 AND utimestamp > 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_WARNING) { - // Warning + // Warning. $sql_conditions .= ' estado = 2 AND utimestamp > 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_NOT_NORMAL) { - // Not normal + // Not normal. $sql_conditions .= ' estado <> 0)'; } else if ($status_modulo == AGENT_MODULE_STATUS_UNKNOWN) { - // Unknown + // Unknown. $sql_conditions .= ' estado = 3 AND utimestamp <> 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_NOT_INIT) { - // Not init + // Not init. $sql_conditions .= ' utimestamp = 0 ) AND t1.id_tipo_modulo NOT IN (21,22,23,100)'; } @@ -412,7 +440,7 @@ if (is_ajax()) { foreach ($array_reduced as $server_name => $id_agents) { // Metaconsole db connection - // $server_name can be the server id (ugly hack, I know) + // $server_name can be the server id (ugly hack, I know). if (is_numeric($server_name)) { $connection = metaconsole_get_connection_by_id($server_name); } else { @@ -423,7 +451,7 @@ if (is_ajax()) { continue; } - // Get agent's modules + // Get agent's modules. $sql = sprintf( 'SELECT t1.id_agente, t1.id_agente_modulo, t1.nombre FROM tagente_modulo t1 %s @@ -451,7 +479,7 @@ if (is_ajax()) { $modules_aux = []; foreach ($modules as $key => $module) { - // Don't change this order, is used in the serialization + // Don't change this order, is used in the serialization. $module_data = [ 'id_module' => $module['id_agente_modulo'], 'id_agent' => $module['id_agente'], @@ -466,7 +494,7 @@ if (is_ajax()) { $modules = $modules_aux; - // Build the next array using the common values + // Build the next array using the common values. if (!empty($last_modules_set)) { $modules = array_intersect_key($modules, $last_modules_set); @@ -480,7 +508,7 @@ if (is_ajax()) { $last_modules_set = $modules; - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } @@ -490,7 +518,6 @@ if (is_ajax()) { $module_data_processed = array_map( function ($item) { - // data: -> id_module | id_agent | server_name; return implode('|', $item); }, $module_data @@ -600,16 +627,16 @@ if (is_ajax()) { if ($get_agent_modules_json) { $id_agent = (int) get_parameter('id_agent'); - // Use -1 as not received + // Use -1 as not received. $disabled = (int) get_parameter('disabled', -1); $delete_pending = (int) get_parameter('delete_pending', -1); - // Use 0 as not received + // Use 0 as not received. $id_tipo_modulo = (int) get_parameter('id_tipo_modulo', 0); $status_modulo = (int) get_parameter('status_module', -1); $tags = (array) get_parameter('tags', []); - // Filter + // Filter. $filter = []; if ($disabled !== -1) { $filter['disabled'] = $disabled; @@ -627,30 +654,34 @@ if (is_ajax()) { $filter = false; } - $get_only_string_modules = get_parameter('get_only_string_modules', false); + $get_only_string_modules = get_parameter( + 'get_only_string_modules', + false + ); + if ($get_only_string_modules) { $filter['tagente_modulo.id_tipo_modulo IN'] = '(17,23,3,10,33)'; } - // Status selector + // Status selector. if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) { - // Normal - $sql_conditions .= ' estado = 0 AND utimestamp > 0 ) + // Normal. + $sql_conditions .= ' estado = 0 AND utimestamp > 0 ) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100)) '; } else if ($status_modulo == AGENT_MODULE_STATUS_CRITICAL_BAD) { - // Critical + // Critical. $sql_conditions .= ' estado = 1 AND utimestamp > 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_WARNING) { - // Warning + // Warning. $sql_conditions .= ' estado = 2 AND utimestamp > 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_NOT_NORMAL) { - // Not normal + // Not normal. $sql_conditions .= ' estado <> 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_UNKNOWN) { - // Unknown + // Unknown. $sql_conditions .= ' estado = 3 AND utimestamp <> 0 )'; } else if ($status_modulo == AGENT_MODULE_STATUS_NOT_INIT) { - // Not init + // Not init. $sql_conditions .= ' utimestamp = 0 ) AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)'; } @@ -663,7 +694,7 @@ if (is_ajax()) { $get_id_and_name = (bool) get_parameter('get_id_and_name'); $get_distinct_name = (bool) get_parameter('get_distinct_name'); - // Fields + // Fields. $fields = '*'; if ($get_id_and_name) { $fields = [ @@ -680,7 +711,8 @@ if (is_ajax()) { $agentName = (string) get_parameter('agent_name', null); $server_name = (string) get_parameter('server_name', null); $server_id = (int) get_parameter('server_id', 0); - // This will force to get local modules although metaconsole is active, by default get all modules from all nodes + // This will force to get local modules although metaconsole is active, + // by default get all modules from all nodes. $force_local_modules = (int) get_parameter('force_local_modules', 0); if ($agentName != null) { @@ -703,7 +735,7 @@ if (is_ajax()) { } if (metaconsole_load_external_db($connection) == NOERR) { - // Get all agents if no agent was given + // Get all agents if no agent was given. if ($id_agent == 0) { $id_agent = array_keys( agents_get_group_agents( @@ -717,11 +749,11 @@ if (is_ajax()) { $agent_modules = agents_get_modules($id_agent, $fields, $filter, $indexed, true, $force_tags); } - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } } else { - // Get all agents if no agent was given + // Get all agents if no agent was given. if ($id_agent == 0) { $id_agent = array_keys( agents_get_group_agents( @@ -765,7 +797,7 @@ if (is_ajax()) { $id_agent = (int) get_parameter('id_agent'); $metaconsole = (bool) get_parameter('metaconsole', false); $id_server = (int) get_parameter('id_server', 0); - // Metaconsole + // Metaconsole. $server = null; if ($metaconsole) { $filter = []; @@ -802,7 +834,7 @@ if (is_ajax()) { echo ''.__('Last remote contact').': '.human_time_comparation($agent['ultimo_contacto_remoto']).'
    '; if (!$metaconsole) { - // Fix : Only show agents with module with tags of user profile + // Fix : Only show agents with module with tags of user profile. $_user_tags = tags_get_user_tags($config['id_user'], 'RR'); $_sql_post = ''; @@ -839,10 +871,10 @@ if (is_ajax()) { if ($bad_modules === false) { $size_bad_modules = 0; } else { - $size_bad_modules = sizeof($bad_modules); + $size_bad_modules = count($bad_modules); } - // Modules down + // Modules down. if ($size_bad_modules > 0) { echo ''.__('Monitors down').': '.$size_bad_modules.' / '.$total_modules; echo '
      '; @@ -855,7 +887,7 @@ if (is_ajax()) { echo '
    '; } - // Alerts (if present) + // Alerts (if present). $sql = sprintf( 'SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente @@ -937,8 +969,8 @@ if (is_ajax()) { if ($module['id_tipo_modulo'] == 18) { echo ''.__('Address').': '; - // Get the IP/IPs from the module description - // Always the IP is the last part of the description (after the last space) + // Get the IP/IPs from the module description Always the IP + // is the last part of the description (after the last space). $ips = explode(' ', $module['descripcion']); $ips = $ips[(count($ips) - 1)]; @@ -948,7 +980,7 @@ if (is_ajax()) { } else { echo '
      '; foreach ($ips as $ip) { - echo "
    • $ip
    • "; + echo '
    • '.$ip.'
    • '; } echo '
    '; @@ -1033,7 +1065,7 @@ $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); $agent = db_get_row('tagente', 'id_agente', $id_agente); -// get group for this id_agente +// Get group for this id_agente. $id_grupo = $agent['id_grupo']; $is_extra = enterprise_hook('policies_is_agent_extra_policy', [$id_agente]); @@ -1053,7 +1085,7 @@ if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && ! check_ return; } -// Check for Network FLAG change request +// Check for Network FLAG change request. $flag = get_parameter('flag', ''); if ($flag !== '') { if ($flag == 1 && check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { @@ -1067,7 +1099,7 @@ if ($flag !== '') { } } -// Check for Network FLAG change request +// Check for Network FLAG change request. $flag_agent = get_parameter('flag_agent', ''); if ($flag_agent !== '') { if ($flag_agent == 1 && check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { @@ -1082,10 +1114,10 @@ if ($agent['icon_path']) { } -// -------------Code for the tabs in the header of agent page----------- +// Code for the tabs in the header of agent page. $tab = get_parameter('tab', 'main'); -// Manage tab +// Manage tab. $managetab = []; if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || $is_extra) { @@ -1101,7 +1133,7 @@ if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || $is_extra) } -// Main tab +// Main tab. $maintab['text'] = ''.html_print_image('images/agent_mc.png', true, ['title' => __('Main')]).''; if ($tab == 'main') { @@ -1112,7 +1144,7 @@ if ($tab == 'main') { -// Alert tab +// Alert tab. $alerttab['text'] = ''.html_print_image('images/op_alerts.png', true, ['title' => __('Alerts')]).''; if ($tab == 'alert') { @@ -1121,27 +1153,27 @@ if ($tab == 'alert') { $alerttab['active'] = false; } -// Inventory +// Inventory. $inventorytab = enterprise_hook('inventory_tab'); if ($inventorytab == -1) { $inventorytab = ''; } -// Collection +// Collection. $collectiontab = enterprise_hook('collection_tab'); if ($collectiontab == -1) { $collectiontab = ''; } -// Policy +// Policy. $policyTab = enterprise_hook('policy_tab'); if ($policyTab == -1) { $policyTab = ''; } -// WUX Console +// WUX Console. $modules_wux = enterprise_hook('get_wux_modules', [$id_agente]); if ($modules_wux) { $wux_console_tab = enterprise_hook('wux_console_tab'); @@ -1158,7 +1190,7 @@ if ($url_route_analyzer) { } } -// GIS tab +// GIS tab. $gistab = []; if ($config['activate_gis']) { $gistab['text'] = ''.html_print_image('images/op_gis.png', true, [ 'title' => __('GIS data')]).''; @@ -1171,7 +1203,7 @@ if ($config['activate_gis']) { } -// Incident tab +// Incident tab. $total_incidents = agents_get_count_incidents($id_agente); if ($total_incidents > 0) { $incidenttab['text'] = ''.html_print_image('images/book_edit.png', true, ['title' => __('Incidents')]).''; @@ -1184,7 +1216,7 @@ if ($total_incidents > 0) { } -// Url address tab +// Url address tab. if ($agent['url_address'] != '') { $urladdresstab['text'] = ''.html_print_image('images/link.png', true, ['title' => __('Url address')]).''; } @@ -1196,7 +1228,7 @@ if ($tab == 'url_address') { } -// Custom fields tab +// Custom fields tab. $custom_fields['text'] = ''.html_print_image('images/custom_field.png', true, ['title' => __('Custom fields')]).''; if ($tab == 'custom_fields') { $custom_fields['active'] = true; @@ -1205,7 +1237,7 @@ if ($tab == 'custom_fields') { } -// Graphs tab +// Graphs tab. $graphs['text'] = ''.html_print_image('images/chart.png', true, ['title' => __('Graphs')]).''; if ($tab == 'graphs') { $graphs['active'] = true; @@ -1214,7 +1246,7 @@ if ($tab == 'graphs') { } -// Log viewer tab +// Log viewer tab. if (enterprise_installed() && $config['log_collector']) { $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; $agent_has_logs = (bool) db_get_value('id_agent', 'tagent_module_log', 'id_agent', $id_agente); @@ -1226,7 +1258,7 @@ if (enterprise_installed() && $config['log_collector']) { } } -// eHorus tab +// EHorus tab. if ($config['ehorus_enabled'] && !empty($config['ehorus_custom_field']) && (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || is_user_admin($config['id_user'])) ) { @@ -1235,7 +1267,7 @@ if ($config['ehorus_enabled'] && !empty($config['ehorus_custom_field']) $tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente; $ehorus_tab['text'] = ''.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).''; - // Hidden subtab layer + // Hidden subtab layer. $ehorus_tab['sub_menu'] = '
    '; } } @@ -1012,7 +1016,7 @@ if ($group_rep == 2) { var total_checked = $(".chk_val:checked").length; // Limit number of events to apply custom responses to for performance reasons - if (total_checked > 10) { + if (total_checked > ) { $('#max_custom_event_resp_msg').show(); return; } @@ -1022,18 +1026,22 @@ if ($group_rep == 2) { $('#response_loading_dialog').show(function() { $(".chk_val").each(function() { - if ($(this).is(":checked")) { - //var server_id = $('#hidden-server_id_'+). event_id = $(this).val(); server_id = $('#hidden-server_id_'+event_id).val(); - - response['target'] = get_response_target(event_id, response_id, server_id); - + response['target'] = get_response_target( + event_id, + response_id, + server_id + ); if (total_checked-1 === counter) end=1; - - show_massive_response_dialog(event_id, response_id, response, counter, end); - + show_massive_response_dialog( + event_id, + response_id, + response, + counter, + end + ); counter++; } }); @@ -1087,4 +1095,3 @@ if ($group_rep == 2) { echo ''; } - diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 45a436a127..bf81ae5110 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -105,6 +105,7 @@ if (!empty($sub2)) { } enterprise_hook('cluster_menu'); +enterprise_hook('aws_menu'); if (!empty($sub)) { $menu_operation['estado']['text'] = __('Monitoring'); @@ -375,6 +376,11 @@ $sub['operation/users/user_edit']['text'] = __('Edit my user'); $sub['operation/users/user_edit']['id'] = 'Edit my user'; $sub['operation/users/user_edit']['refr'] = 0; +// Users +$sub['operation/users/user_edit_notifications']['text'] = __('Configure user notifications'); +$sub['operation/users/user_edit_notifications']['id'] = 'Configure user notifications'; +$sub['operation/users/user_edit_notifications']['refr'] = 0; + // ANY user can chat with other user and dogs. // Users $sub['operation/users/webchat']['text'] = __('WebChat'); diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index a1f2c430e7..f116e6609d 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -1,24 +1,39 @@ false, - 'text' => ''.html_print_image('images/email_inbox.png', true, ['title' => __('Received messages')]).'', + 'text' => ''.html_print_image( + 'images/email_inbox.png', + true, + ['title' => __('Received messages')] + ).'', ]; $buttons['sent_messages'] = [ 'active' => false, - 'text' => ''.html_print_image('images/email_outbox.png', true, ['title' => __('Sent messages')]).'', + 'text' => ''.html_print_image( + 'images/email_outbox.png', + true, + ['title' => __('Sent messages')] + ).'', ]; $buttons['create_message'] = [ 'active' => true, - 'text' => ''.html_print_image('images/new_message.png', true, ['title' => __('Create message')]).'', + 'text' => ''.html_print_image( + 'images/new_message.png', + true, + ['title' => __('Create message')] + ).'', ]; -// Header -ui_print_page_header(__('Messages'), 'images/email_mc.png', false, '', false, $buttons); +// Header. +ui_print_page_header( + __('Messages'), + 'images/email_mc.png', + false, + '', + false, + $buttons +); -// read a message +// Read a message. if ($read_message) { $message_id = (int) get_parameter('id_message'); if ($show_sent) { @@ -56,10 +90,10 @@ if ($read_message) { messages_process_read($message_id); } - if ($message == false) { + if ($message === false) { echo '
    '.__('This message does not exist in the system').'
    '; return; - // Move out of this page and go processing other pages + // Move out of this page and go processing other pages. } $user_name = get_user_fullname($message['id_usuario_origen']); @@ -72,19 +106,70 @@ if ($read_message) { $dst_name = $message['id_usuario_destino']; } - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox filters'; - $table->data = []; + if (isset($user_name) !== true || empty($user_name) === true) { + echo '

    Notification

    '; + } else { + echo '

    Conversation with '.$user_name.'

    '; + } - $table->data[0][0] = __('Sender'); - $table->data[0][1] = $user_name.' '.__('at').' '.ui_print_timestamp($message['timestamp'], true, ['prominent' => 'timestamp']); + echo '

    Subject: '.$message['subject'].'

    '; - $table->data[1][0] = __('Destination'); - $table->data[1][1] = $dst_name; + $conversation = []; + $target_str = $message['mensaje']; + + while (preg_match_all( + '/(.*)On(.*)wrote:(.*)/', + $target_str, + $decoded, + PREG_PATTERN_ORDER + ) !== false && empty($target_str) !== true) { + if (empty($decoded[2]) !== true) { + array_push( + $conversation, + [ + 'message' => array_pop($decoded)[0], + 'date' => array_pop($decoded)[0], + ] + ); + } else { + array_push( + $conversation, + ['message' => $target_str] + ); + } + + $target_str = $decoded[1][0]; + } + + ui_require_css_file('message_edit'); + foreach ($conversation as $row) { + $date = $row['date']; + + if ($date === null) { + $date = date( + $config['date_format'], + $message['timestamp'] + ).' '.$user_name; + } + + $order = [ + "\r\n", + "\n", + "\r", + ]; + $replace = '
    '; + $parsed_message = str_replace( + $order, + $replace, + trim(io_safe_output($row['message'])) + ); + + echo '
    '; + echo '

    '.$parsed_message.'

    '; + echo ''.$date.''; + echo '
    '; + } - $table->data[2][0] = __('Subject'); - $table->data[2][1] = html_print_input_text_extended('subject', $message['subject'], 'text-subject', '', 50, 70, true, false, '', 'readonly'); $order = [ "\r\n", @@ -94,21 +179,21 @@ if ($read_message) { $replace = '
    '; $parsed_message = str_replace($order, $replace, $message['mensaje']); - $table->data[3][0] = __('Message'); - $table->data[3][1] = html_print_textarea('message', 15, 255, $message['mensaje'], 'readonly', true); - - // Prevent RE: RE: RE: + // Prevent RE: RE: RE:. if (strstr($message['subject'], 'RE:')) { $new_subj = $message['subject']; } else { $new_subj = 'RE: '.$message['subject']; } - // Start the message much like an e-mail reply - $new_msg = "\n\n\nOn ".date($config['date_format'], $message['timestamp']).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje']; + // Start the message much like an e-mail reply. + $new_msg = "\n\n\nOn ".date( + $config['date_format'], + $message['timestamp'] + ).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje']; + echo '
    '; - html_print_table($table); echo '
    '; echo '
    '; @@ -119,17 +204,33 @@ if ($read_message) { echo '
    '; echo "
    "; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'form="delete_message" class="sub delete"'); + html_print_submit_button( + __('Delete conversation'), + 'delete_btn', + false, + 'form="delete_message" class="sub delete"' + ); echo ' '; - html_print_submit_button(__('Reply'), 'reply', false, 'form="reply_message" class="sub next"'); + html_print_submit_button( + __('Reply'), + 'reply', + false, + 'form="reply_message" class="sub next"' + ); echo '
    '; return; } -// Create message (destination user) +// Create message (destination user). if (($new_msg) && (!empty($dst_user)) && (!$reply)) { - $return = messages_create_message($config['id_user'], $dst_user, $subject, $message); + $return = messages_create_message( + $config['id_user'], + [$dst_user], + [], + $subject, + $message + ); $user_name = get_user_fullname($dst_user); if (!$user_name) { @@ -143,9 +244,15 @@ if (($new_msg) && (!empty($dst_user)) && (!$reply)) { ); } -// Create message (destination group) +// Create message (destination group). if (($new_msg) && ($dst_group != '') && (!$reply)) { - $return = messages_create_group($config['id_user'], $dst_group, $subject, $message); + $return = messages_create_message( + $config['id_user'], + [], + [$dst_group], + $subject, + $message + ); ui_print_result_message( $return, @@ -154,8 +261,8 @@ if (($new_msg) && ($dst_group != '') && (!$reply)) { ); } -// message creation form -// user info +// Message creation form. +// User info. $own_info = get_user_info($config['id_user']); $table = new stdClass(); @@ -174,12 +281,28 @@ if (!empty($own_info['fullname'])) { $table->data[1][0] = __('Destination'); -$is_admin = (bool) db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); +$is_admin = (bool) db_get_value( + 'is_admin', + 'tusuario', + 'id_user', + $config['id_user'] +); if ($is_admin) { - $users_full = db_get_all_rows_filter('tusuario', [], ['id_user', 'fullname']); + $users_full = db_get_all_rows_filter( + 'tusuario', + [], + [ + 'id_user', + 'fullname', + ] + ); } else { - $users_full = groups_get_users(array_keys(users_get_groups()), false, false); + $users_full = groups_get_users( + array_keys(users_get_groups()), + false, + false + ); } $users = []; @@ -187,17 +310,16 @@ foreach ($users_full as $user_id => $user_info) { $users[$user_info['id_user']] = $user_info['fullname']; } -// Check if the user to reply is in the list, if not add reply user +// Check if the user to reply is in the list, if not add reply user. if ($reply) { if (!array_key_exists($dst_user, $users)) { - // Add the user to reply + // Add the user to reply. $user_reply = db_get_row('tusuario', 'id_user', $dst_user); $users[$user_reply['id_user']] = $user_reply['fullname']; } } - if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { $return_all_groups = true; } else { @@ -205,21 +327,61 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { } $groups = users_get_groups($config['id_user'], 'AR'); -// Get a list of all groups -$table->data[1][1] = html_print_select($users, 'dst_user', $dst_user, '', __('Select user'), false, true, false, '', false); +// Get a list of all groups. +$table->data[1][1] = html_print_select( + $users, + 'dst_user', + $dst_user, + '', + __('Select user'), + false, + true, + false, + '', + false +); $table->data[1][1] .= '  '.__('OR').'  '; -$table->data[1][1] .= html_print_select_groups($config['id_user'], 'AR', $return_all_groups, 'dst_group', $dst_group, '', __('Select group'), '', true); +$table->data[1][1] .= html_print_select_groups( + $config['id_user'], + 'AR', + $return_all_groups, + 'dst_group', + $dst_group, + '', + __('Select group'), + '', + true +); $table->data[2][0] = __('Subject'); -$table->data[2][1] = html_print_input_text('subject', $subject, '', 50, 70, true); +$table->data[2][1] = html_print_input_text( + 'subject', + $subject, + '', + 50, + 70, + true +); $table->data[3][0] = __('Message'); -$table->data[3][1] = html_print_textarea('message', 15, 255, $message, '', true); +$table->data[3][1] = html_print_textarea( + 'message', + 15, + 255, + $message, + '', + true +); echo '
    '; html_print_table($table); echo '
    '; - html_print_submit_button(__('Send message'), 'send_mes', false, 'class="sub wand"'); -echo ''; -echo '
    '; + html_print_submit_button( + __('Send message'), + 'send_mes', + false, + 'class="sub wand"' + ); + echo ''; + echo ''; diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index a9108d9fc0..9427159432 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -1,16 +1,32 @@ false, - 'text' => ''.html_print_image('images/new_message.png', true, ['title' => __('Create message')]).'', + 'text' => ''.html_print_image( + 'images/new_message.png', + true, + ['title' => __('Create message')] + ).'', ]; if (!is_ajax()) { - ui_print_page_header(__('Messages'), 'images/email_mc.png', false, '', false, $buttons); + ui_print_page_header( + __('Messages'), + 'images/email_mc.png', + false, + '', + false, + $buttons + ); } if ($mark_unread) { @@ -52,7 +79,7 @@ if ($mark_unread) { if ($delete_msg) { $id = (int) get_parameter('id'); $result = messages_delete_message($id); - // Delete message function will actually check the credentials + // Delete message function will actually check the credentials. ui_print_result_message( $result, __('Successfully deleted'), @@ -61,13 +88,10 @@ if ($delete_msg) { } if ($multiple_delete) { - $ids = (array) get_parameter('delete_multiple', []); + $ids = (array) get_parameter('delete_multiple_messages', []); foreach ($ids as $id) { - $result = db_process_sql_delete( - 'tmensajes', - ['id_mensaje' => $id] - ); + $result = messages_delete_message($id); if ($result === false) { break; @@ -82,21 +106,23 @@ if ($multiple_delete) { } if ($show_sent) { - // sent view + // Sent view. $num_messages = messages_get_count_sent($config['id_user']); if ($num_messages > 0 && !is_ajax()) { - echo '

    '.__('You have').' '.$num_messages.' '.' '.__('sent message(s)').'.

    '; + echo '

    '.__('You have').' '.$num_messages.' '.__('sent message(s)').'.

    '; } $messages = messages_get_overview_sent('', 'DESC'); } else { - // messages received - $num_messages = messages_get_count($config['id_user']); + // Messages received. + $num_messages = messages_get_count($config['id_user'], true, true); if ($num_messages > 0 && !is_ajax()) { - echo '

    '.__('You have').' '.$num_messages.' '.' '.__('unread message(s)').'.

    '; + $unread_messages = messages_get_count($config['id_user'], false, true); + echo '

    '.__('You have').' '.$unread_messages.' '.__('unread message(s)').'.

    '; + $messages = messages_get_overview(); + } else { + $messages = messages_get_overview('status', 'ASC'); } - - $messages = messages_get_overview(); } if (empty($messages)) { @@ -139,10 +165,12 @@ if (empty($messages)) { $table->head[3] = __('Timestamp'); $table->head[4] = __('Delete').html_print_checkbox('all_delete_messages', 0, false, true, false); - foreach ($messages as $message_id => $message) { + + foreach ($messages as $message) { + $message_id = $message['id_mensaje']; $data = []; $data[0] = ''; - if ($message['status'] == 1) { + if ($message['read'] == 1) { if ($show_sent) { $data[0] .= ''; $data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Click to read')]); @@ -202,10 +230,10 @@ if (empty($messages)) { if ($show_sent) { $data[4] = ''.html_print_image('images/cross.png', true, ['title' => __('Delete')]).''.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); + onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).''.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); } else { $data[4] = ''.html_print_image('images/cross.png', true, ['title' => __('Delete')]).''.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); + onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).''.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); } array_push($table->data, $data); diff --git a/pandora_console/operation/servers/recon_view.php b/pandora_console/operation/servers/recon_view.php index d91b838e8b..84a057d69c 100644 --- a/pandora_console/operation/servers/recon_view.php +++ b/pandora_console/operation/servers/recon_view.php @@ -30,7 +30,7 @@ $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3'); if ($servers === false) { $servers = []; ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false); - ui_print_error_message(__('Recon Server is disabled')); + ui_print_error_message(__('Discovery Server is disabled')); return; } else { $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index fde9586325..b2344c13ad 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -294,6 +294,8 @@ enterprise_hook('close_meta_frame'); $(".loading_tree").show(); + + var parameters = {}; parameters['page'] = "include/ajax/tree.ajax"; parameters['getChildren'] = 1; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 1552f2f57c..3e3338ff96 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -1,64 +1,36 @@ '.__('User ID').''; $data[0] .= $jump.''.$id.''; $data[1] = ''.__('Full (display) name').''; -$data[1] .= $jump.''.html_print_input_text_extended('fullname', $user_info['fullname'], 'fullname', '', 20, 100, $view_mode, '', 'class="input"', true).''; +$data[1] .= $jump.''; +$data[1] .= html_print_input_text_extended( + 'fullname', + $user_info['fullname'], + 'fullname', + '', + 20, + 100, + $view_mode, + '', + 'class="input"', + true +).''; + // Show "Picture" (in future versions, why not, allow users to upload it's own avatar here. if (is_user_admin($id)) { $data[2] = html_print_image('images/people_1.png', true); @@ -368,7 +360,7 @@ if (!$meta) { - // User only can change skins if has more than one group + // User only can change skins if has more than one group. $data[1] = ''; if (function_exists('skins_print_select')) { if (count($usr_groups) > 1) { @@ -388,18 +380,21 @@ $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; -// Double auth +// Double auth. $double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']); $data = []; -$data[0] = ''.__('Double authentication').''; -$data[0] .= $jump; -$data[0] .= ''.html_print_checkbox('double_auth', 1, $double_auth_enabled, true).''; +if ($config['double_auth_enabled']) { + $data[0] = ''.__('Double authentication').''; + $data[0] .= $jump; + $data[0] .= ''.html_print_checkbox('double_auth', 1, $double_auth_enabled, true).''; +} + if ($double_auth_enabled) { $data[0] .= $jump; $data[0] .= html_print_button(__('Show information'), 'show_info', false, 'javascript:show_double_auth_info();', '', true); } -// Dialog +// Dialog. $data[0] .= '
    '; if (check_acl($config['id_user'], 0, 'ER')) { @@ -407,14 +402,13 @@ if (check_acl($config['id_user'], 0, 'ER')) { $data[1] .= $jump.''.html_print_select_from_sql( 'SELECT id_filter, id_name FROM tevent_filter', 'event_filter', - $user_info['id_filter'], + $user_info['default_event_filter'], '', __('None'), null, true ).''; -}//end if -else if (license_free()) { +} else if (license_free()) { $data[1] = __('Newsletter Subscribed').':'; if ($user_info['middlename']) { $data[1] .= $jump.''.__('Already subscribed to %s newsletter', get_product_name()).''; @@ -465,7 +459,8 @@ if (!isset($autorefresh_list)) { $autorefresh_list[0] = __('None'); } else { $aux = []; - for ($i = 0; $i < count($autorefresh_list); $i++) { + $count_autorefresh_list = count($autorefresh_list); + for ($i = 0; $i < $count_autorefresh_list; $i++) { $aux[$autorefresh_list[$i]] = $autorefresh_list_out[$autorefresh_list[$i]]; unset($autorefresh_list_out[$autorefresh_list[$i]]); $autorefresh_list[$i] = $aux; @@ -478,7 +473,8 @@ if (!isset($autorefresh_list)) { $autorefresh_list[0] = __('None'); } else { $aux = []; - for ($i = 0; $i < count($autorefresh_list); $i++) { + $count_autorefresh_list = count($autorefresh_list); + for ($i = 0; $i < $count_autorefresh_list; $i++) { $aux[$autorefresh_list[$i]] = $autorefresh_list_out[$autorefresh_list[$i]]; unset($autorefresh_list_out[$autorefresh_list[$i]]); $autorefresh_list[$i] = $aux; @@ -488,10 +484,39 @@ if (!isset($autorefresh_list)) { } } -$data[0] = _('Autorefresh').ui_print_help_tip(__('This will activate autorefresh in selected pages'), true); -$select_out = html_print_select($autorefresh_list_out, 'autorefresh_list_out[]', '', '', '', '', true, true, true, '', false, 'width:200px'); +$data[0] = _('Autorefresh').ui_print_help_tip( + __('This will activate autorefresh in selected pages'), + true +); +$select_out = html_print_select( + $autorefresh_list_out, + 'autorefresh_list_out[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:200px' +); $arrows = ' '; -$select_in = html_print_select($autorefresh_list, 'autorefresh_list[]', '', '', '', '', true, true, true, '', false, 'width:200px'); +$select_in = html_print_select( + $autorefresh_list, + 'autorefresh_list[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:200px' +); $table_ichanges = ' @@ -502,19 +527,50 @@ $table_ichanges = '
    '.$select_out.' - '.html_print_image('images/darrowright.png', true, ['id' => 'right_autorefreshlist', 'alt' => __('Push selected pages into autorefresh list'), 'title' => __('Push selected pages into autorefresh list')]).' + '.html_print_image( + 'images/darrowright.png', + true, + [ + 'id' => 'right_autorefreshlist', + 'alt' => __('Push selected pages into autorefresh list'), + 'title' => __('Push selected pages into autorefresh list'), + ] +).'

    - '.html_print_image('images/darrowleft.png', true, ['id' => 'left_autorefreshlist', 'alt' => __('Pop selected pages out of autorefresh list'), 'title' => __('Pop selected pages out of autorefresh list')]).' + '.html_print_image( + 'images/darrowleft.png', + true, + [ + 'id' => 'left_autorefreshlist', + 'alt' => __('Pop selected pages out of autorefresh list'), + 'title' => __('Pop selected pages out of autorefresh list'), + ] +).'
    '.$select_in.'
    '; $data[0] .= $table_ichanges; -// time autorefresh +// Time autorefresh. $times = get_refresh_time_array(); -$data[1] = ''.__('Time autorefresh').ui_print_help_tip(__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), true).''; -$data[1] .= $jump.''.html_print_select($times, 'time_autorefresh', $user_info['time_autorefresh'], '', '', '', true, false, false).''; +$data[1] = ''.__('Time autorefresh'); +$data[1] .= ui_print_help_tip( + __('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), + true +).''; +$data[1] .= $jump.''; +$data[1] .= html_print_select( + $times, + 'time_autorefresh', + $user_info['time_autorefresh'], + '', + '', + '', + true, + false, + false +).''; $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;vertical-align: top'; @@ -528,14 +584,23 @@ $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; $data = []; -$data[0] = '
    '.html_print_textarea('comments', 2, 60, $user_info['comments'], ($view_mode ? 'readonly="readonly"' : ''), true).'
    '; +$data[0] = '
    '; +$data[0] .= html_print_textarea( + 'comments', + 2, + 60, + $user_info['comments'], + (($view_mode) ? 'readonly="readonly"' : ''), + true +); +$data[0] .= '
    '; $data[0] .= html_print_input_hidden('quick_language_change', 1, true); $table->colspan[count($table->data)][0] = 3; $table->rowclass[] = ''; $table->rowstyle[] = ''; $table->data[] = $data; -echo '
    '; +echo ''; html_print_table($table); @@ -594,9 +659,15 @@ if ($result === false) { foreach ($result as $profile) { $data[0] = ''.profile_get_name($profile['id_perfil']).''; if ($config['show_group_name']) { - $data[1] = ui_print_group_icon($profile['id_grupo'], true).''.' '.''; + $data[1] = ui_print_group_icon( + $profile['id_grupo'], + true + ).' '; } else { - $data[1] = ui_print_group_icon($profile['id_grupo'], true).''.' '.ui_print_truncate_text(groups_get_name($profile['id_grupo'], true), GENERIC_SIZE_TEXT).''; + $data[1] = ui_print_group_icon( + $profile['id_grupo'], + true + ).' '.ui_print_truncate_text(groups_get_name($profile['id_grupo'], true), GENERIC_SIZE_TEXT).''; } $tags_ids = explode(',', $profile['tags']); diff --git a/pandora_console/operation/users/user_edit_header.php b/pandora_console/operation/users/user_edit_header.php new file mode 100644 index 0000000000..4b329eee77 --- /dev/null +++ b/pandora_console/operation/users/user_edit_header.php @@ -0,0 +1,87 @@ + [ + 'active' => $_GET['sec2'] === 'operation/users/user_edit', + 'text' => "".html_print_image( + 'images/user_green.png', + true, + ['title' => __('User management')] + ).'', + ], + 'notifications' => [ + 'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications', + 'text' => "".html_print_image( + 'images/alerts_template.png', + true, + ['title' => __('User notifications')] + ).'', + ], + ]; + + ui_print_page_header( + __('User detail editor'), + 'images/op_workspace.png', + false, + '', + false, + $buttons + ); +} diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php new file mode 100644 index 0000000000..6ffbf87976 --- /dev/null +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -0,0 +1,122 @@ + notifications_set_user_label_status( + $source, + $user, + $label, + $value + ), + ] + ); + return; +} + +// User notification table. It is just a wrapper. +$table_content = new StdClass(); +$table_content->data = []; +$table_content->width = '100%'; +$table_content->id = 'user-notifications-wrapper'; +$table_content->class = 'databox filters'; +$table_content->size[0] = '33%'; +$table_content->size[1] = '33%'; +$table_content->size[2] = '33%'; + +// Print the header. +$table_content->data[] = [ + '', + __('Enable'), + __('Also receive an email'), +]; + +$sources = notifications_get_all_sources(); +foreach ($sources as $source) { + $table_content->data[] = [ + $source['description'], + notifications_print_user_switch($source, $id, 'enabled'), + notifications_print_user_switch($source, $id, 'also_mail'), + ]; +} + +html_print_table($table_content); + +// Print id user to handle it on js. +html_print_input_hidden('id_user', $id); + +?> + diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index bf7a69fadf..5ffa0a60fd 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.731 -%define release 190215 +%define release 190226 # User and Group under which Apache is running %define httpd_name httpd @@ -26,7 +26,7 @@ BuildRoot: %{_tmppath}/%{name} BuildArch: noarch AutoReq: 0 Requires: %{httpd_name} >= 2.0.0 -Requires: mod_php >= 5.2.0 +Requires: mod_php >= 7.0 Requires: php-gd, php-ldap, php-snmp, php-session, php-gettext Requires: php-mysqlnd, php-mbstring, php-zip, php-zlib, php-curl Requires: xorg-x11-fonts-75dpi, xorg-x11-fonts-misc, php-pecl-zip diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 55f8b82785..1cc5f88b10 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.731 -%define release 190215 +%define release 190226 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 @@ -29,7 +29,7 @@ BuildArch: noarch AutoReq: 0 Requires: apache2 Requires: apache2-mod_php7 -Requires: php >= 4.3.0 +Requires: php >= 7.0 Requires: php-gd, php-snmp, php-json, php-gettext Requires: php-mysqlnd, php-ldap, php-mbstring, php Requires: graphviz, xorg-x11-fonts-core, graphviz-gd diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7f8197540b..ae780a5470 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -655,6 +655,19 @@ CREATE TABLE IF NOT EXISTS `tevento` ( -- Criticity: 3 - Warning (yellow) (status 2) -- Criticity: 4 - Critical (red) (status 1) +-- --------------------------------------------------------------------- +-- Table `tevent_extended` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tevent_extended` ( + `id` serial PRIMARY KEY, + `id_evento` bigint(20) unsigned NOT NULL, + `external_id` bigint(20) unsigned, + `utimestamp` bigint(20) NOT NULL default '0', + `description` text, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- --------------------------------------------------------------------- -- Table `tgrupo` -- --------------------------------------------------------------------- @@ -719,20 +732,6 @@ CREATE TABLE IF NOT EXISTS `tlink` ( PRIMARY KEY (`id_link`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- --- Table `tmensajes` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tmensajes` ( - `id_mensaje` int(10) unsigned NOT NULL auto_increment, - `id_usuario_origen` varchar(60) NOT NULL default '', - `id_usuario_destino` varchar(60) NOT NULL default '', - `mensaje` text NOT NULL, - `timestamp` bigint (20) unsigned NOT NULL default '0', - `subject` varchar(255) NOT NULL default '', - `estado` int(4) unsigned NOT NULL default '0', - PRIMARY KEY (`id_mensaje`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- ---------------------------------------------------------------------- -- Table `tmodule_group` -- ---------------------------------------------------------------------- @@ -783,6 +782,9 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `snmp_privacy_method` varchar(25) NOT NULL default '', `snmp_privacy_pass` varchar(255) NOT NULL default '', `snmp_security_level` varchar(25) NOT NULL default '', + `wmi_enabled` tinyint(1) unsigned DEFAULT '0', + `auth_strings` text, + `autoconfiguration_enabled` tinyint(1) unsigned default '0', PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1177,6 +1179,113 @@ CREATE TABLE IF NOT EXISTS `treset_pass_history` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ----------------------------------------------------- +-- Table `tnotification_source` +-- ----------------------------------------------------- +CREATE TABLE `tnotification_source` ( + `id` serial, + `description` VARCHAR(255) DEFAULT NULL, + `icon` text, + `max_postpone_time` int(11) DEFAULT NULL, + `enabled` int(1) DEFAULT NULL, + `user_editable` int(1) DEFAULT NULL, + `also_mail` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `tmensajes` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmensajes` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario_origen` VARCHAR(60) NOT NULL DEFAULT '', + `mensaje` TEXT NOT NULL, + `timestamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', + `subject` VARCHAR(255) NOT NULL DEFAULT '', + `estado` INT(4) UNSIGNED NOT NULL DEFAULT '0', + `url` TEXT, + `response_mode` VARCHAR(200) DEFAULT NULL, + `citicity` INT(10) UNSIGNED DEFAULT '0', + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `subtype` VARCHAR(255) DEFAULT '', + PRIMARY KEY (`id_mensaje`), + UNIQUE KEY `id_mensaje` (`id_mensaje`), + KEY `tsource_fk` (`id_source`), + CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_user` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT(20), + `utimestamp_erased` BIGINT(20), + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_group` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_group` mediumint(4) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ---------------------------------------------------------------------- -- Table `tnews` -- ---------------------------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 5dc2b27ec4..f5da1f12fa 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -23,7 +23,8 @@ INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (9,'SMS','sendsms _field1_ _field2_','Send SMS using the standard SMS device, using smstools. Uses field2 as text message, field1 as destination phone (include international prefix!)',0,'[\"Destination number\",\"Message\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (10,'Validate Event','Internal type','This alert validate the events matched with a module given the agent name (_field1_) and module name (_field2_)',1,'[\"Agent name\",\"Module name\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (11,'Integria IMS Ticket','Internal type','This alert create a ticket into your Integria IMS.',1,'[\"Integria IMS API path\",\"Integria IMS API pass\",\"Integria IMS user\",\"Integria IMS user pass\",\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Email copy\",\"Ticket owner\",\"Ticket description\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very Serious\",\"\",\"\",\"\"]'); - +INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (12,'Remote agent control','/usr/share/pandora_server/util/udp_client.pl _address_ 41122 "_field1_"','This command is used to send commands to the agents with the UDP server enabled. The UDP server is used to order agents (Windows and UNIX) to "refresh" the agent execution: that means, to force the agent to execute and send data',0,'[\"Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); +INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (13,'Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); -- -- Dumping data for table `tconfig` -- @@ -85,6 +86,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('netflow_nfdump', '/usr/bin/nfdump'), ('netflow_max_resolution', '50'), ('event_fields', 'evento,id_agente,estado,timestamp'), +('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'), ('list_ACL_IPs_for_API', '127.0.0.1'), ('enable_pass_policy', 0), ('pass_size', 4), @@ -1104,10 +1106,7 @@ INSERT INTO `tgis_map_layer` VALUES (1,'Group All',1,0,1,0); -- example alert template -INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (12,'Remote agent control','/usr/share/pandora_server/util/udp_client.pl _address_ 41122 "_field1_"','This command is used to send commands to the agents with the UDP server enabled. The UDP server is used to order agents (Windows and UNIX) to "refresh" the agent execution: that means, to force the agent to execute and send data',0,'[\"Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); - -- alert actions (default) - INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (1,'Mail to Admin',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','',0,0,'','','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','text/html','','','','','',''); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES @@ -1132,9 +1131,11 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (2, 'Monitoring&#x INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (3, 'Monitoring Report Alerts', 'select t1.alias as agent_name, t2.nombre as module_name, (select talert_templates.name from talert_templates where talert_templates.id = t3.id_alert_template) as template, (select group_concat(t02.name) from talert_template_module_actions as t01 inner join talert_actions as t02 on t01.id_alert_action = t02.id where t01.id_alert_template_module = t3.id group by t01.id_alert_template_module) as actions from tagente as t1 inner join tagente_modulo as t2 on t1.id_agente = t2.id_agente inner join talert_template_modules as t3 on t2.id_agente_modulo = t3.id_agent_module order by agent_name, module_name;'); INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group view', 'select t1.nombre, (select count(t3.id_agente) from tagente as t3 where t1.id_grupo = t3.id_grupo) as agents, (SELECT COUNT(t4.id_agente) FROM tagente as t4 WHERE t4.id_grupo = t1.id_grupo AND t4.disabled = 0 AND t4.ultimo_contacto < NOW() - (intervalo / (1/2))) as agent_unknown, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100) AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval / (1/2))) as monitor_unknow, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0) as monitor_no_init, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))) as monitor_ok, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0) as monitor_critical, (SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = t1.id_grupo AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0) as monitor_alert_fired from tgrupo as t1 where 0 < (select count(t2.id_agente) from tagente as t2 where t1.id_grupo = t2.id_grupo)'); +-- trecon scripts INSERT INTO `trecon_script` VALUES (2,'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es> Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4> * custom_field1 = Network i.e.: 192.168.100.0/24 * custom_field2 = Username * custom_field3 = Password * custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5. These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'); - INSERT INTO `trecon_script` VALUES (5,'WMI Recon Script','This script is used to automatically gather host information via WMI. Available parameters: * Network = network to scan (e.g. 192.168.100.0/24). * WMI auth = comma separated list of WMI authentication tokens in the format username%password (e.g. Administrador%pass). See the documentation for more information.','/usr/share/pandora_server/util/recon_scripts/wmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"WMI auth\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"true\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'); @@ -1267,3 +1268,48 @@ INSERT INTO `tcontainer` SET `name` = 'Default graph container'; INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', '^.*?\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+', +'host,status', 1); + +INSERT INTO tlog_graph_models VALUES (3, 'Apache time per requester and html code', +'(.*?)\ -.*1.1"\ (\d+)\ (\d+)', +'origin,respose,_time_', 1); + +INSERT INTO tlog_graph_models VALUES (4, 'Count output', +'.*', +'Coincidences', 0); + +INSERT INTO tlog_graph_models VALUES (5, 'Events replicated to metaconsole', +'.* (.*?) .* (\d+) events replicated to metaconsole', +'server,_events_', 0); + +INSERT INTO tlog_graph_models VALUES (6, 'Pages with warnings', +'PHP Warning:.*in (.*?) on', +'page', 0); + +INSERT INTO tlog_graph_models VALUES (7, 'Users login', +'Starting Session \d+\ of user (.*)', +'user', 0); + +-- +-- Dumping data for table `tnotification_source` +-- +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); + +-- +-- Dumping data for table `tnotification_source_user` +-- +INSERT INTO `tnotification_source_user`(`id_source`,`id_user`,`enabled`,`also_mail`) VALUES + ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin",1,0); + +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; + + \ No newline at end of file diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index dd4750c64c..52e071fda9 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.731-190215 +Version: 7.0NG.731-190226 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 d8a1c349af..937c46f882 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.731-190215" +pandora_version="7.0NG.731-190226" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index a5e8be893d..53265cb0a0 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -33,7 +33,7 @@ use PandoraFMS::Core; use PandoraFMS::DataServer; use PandoraFMS::NetworkServer; use PandoraFMS::SNMPServer; -use PandoraFMS::ReconServer; +use PandoraFMS::DiscoveryServer; use PandoraFMS::WMIServer; use PandoraFMS::PluginServer; use PandoraFMS::PredictionServer; @@ -123,7 +123,7 @@ sub pandora_startup () { pandora_reset_server (\%Config, $DBH); push (@Servers, new PandoraFMS::DataServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::NetworkServer (\%Config, $DBH)); - push (@Servers, new PandoraFMS::ReconServer (\%Config, $DBH)); + push (@Servers, new PandoraFMS::DiscoveryServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::SNMPServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH)); diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index f51e0d80f8..1b1ed03412 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.731"; -my $pandora_build = "190215"; +my $pandora_build = "190226"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -226,7 +226,7 @@ sub pandora_load_config { $pa_config->{"dataserver"} = 1; # default $pa_config->{"networkserver"} = 1; # default $pa_config->{"snmpconsole"} = 1; # default - $pa_config->{"reconserver"} = 1; # default + $pa_config->{"discoveryserver"} = 1; # default $pa_config->{"wmiserver"} = 1; # default $pa_config->{"pluginserver"} = 1; # default $pa_config->{"predictionserver"} = 1; # default @@ -254,6 +254,7 @@ sub pandora_load_config { $pa_config->{"plugin_threads"} = 2; # Introduced on 2.0 $pa_config->{"plugin_exec"} = '/usr/bin/timeout'; # 3.0 $pa_config->{"recon_threads"} = 2; # Introduced on 2.0 + $pa_config->{"discovery_threads"} = 2; # Introduced on 732 $pa_config->{"prediction_threads"} = 1; # Introduced on 2.0 $pa_config->{"plugin_timeout"} = 5; # Introduced on 2.0 $pa_config->{"wmi_threads"} = 2; # Introduced on 2.0 @@ -659,8 +660,8 @@ sub pandora_load_config { elsif ($parametro =~ m/^predictionserver\s+([0-9]*)/i){ $pa_config->{'predictionserver'}= clean_blank($1); } - elsif ($parametro =~ m/^reconserver\s+([0-9]*)/i) { - $pa_config->{'reconserver'}= clean_blank($1); + elsif ($parametro =~ m/^discoveryserver\s+([0-9]*)/i) { + $pa_config->{'discoveryserver'}= clean_blank($1); } elsif ($parametro =~ m/^reconserver\s+([0-9]*)/i) { $pa_config->{'reconserver'}= clean_blank($1); @@ -809,6 +810,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^autocreate_group\s+([0-9*]*)/i) { $pa_config->{'autocreate_group'}= clean_blank($1); } + elsif ($parametro =~ m/^discovery_threads\s+([0-9]*)/i) { + $pa_config->{'discovery_threads'}= clean_blank($1); + } elsif ($parametro =~ m/^recon_threads\s+([0-9]*)/i) { $pa_config->{'recon_threads'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3bfd1e1a7d..4155b2d432 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -179,6 +179,7 @@ our @EXPORT = qw( pandora_evaluate_alert pandora_evaluate_snmp_alerts pandora_event + pandora_extended_event pandora_execute_alert pandora_execute_action pandora_exec_forced_alerts @@ -236,6 +237,7 @@ our @EXPORT = qw( pandora_self_monitoring pandora_process_policy_queue subst_alert_macros + subst_column_macros locate_agent get_agent get_agent_from_alias @@ -249,6 +251,7 @@ our @EXPORT = qw( pandora_delete_graph_source pandora_delete_custom_graph pandora_edit_custom_graph + notification_set_targets ); # Some global variables @@ -1459,6 +1462,35 @@ sub pandora_execute_action ($$$$$$$$$;$) { pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_email, $ticket_owner, $ticket_description); + + # Generate notification + } elsif ($clean_name eq "Generate Notification") { + + # Translate macros + $field3 = subst_alert_macros($field3, \%macros, $pa_config, $dbh, $agent, $module); + $field4 = subst_alert_macros($field4, \%macros, $pa_config, $dbh, $agent, $module); + + # If no targets ignore notification + if (defined($field1) && defined($field2) && ($field1 ne "" || $field2 ne "")) { + my @user_list = map {clean_blank($_)} split /,/, $field1; + my @group_list = map {clean_blank($_)} split /,/, $field2; + + my $notification = {}; + $notification->{'subject'} = safe_input($field3); + $notification->{'mensaje'} = safe_input($field4); + $notification->{'id_source'} = get_db_value($dbh, 'SELECT id FROM tnotification_source WHERE description = ?', safe_input('System status')); + + # Create message + my $notification_id = db_process_insert($dbh,'id_mensaje','tmensajes',$notification); + if (!$notification_id) { + logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3); + } else { + notification_set_targets($pa_config, $dbh, $notification_id, \@user_list, \@group_list); + } + } else { + logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "' Empty targets. Ignored.", 3); + } + # Unknown } else { logger($pa_config, "Unknown action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3); @@ -3240,11 +3272,11 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { # Create the event logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); - db_do ($dbh, 'INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) + my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status); - + # Do not write to the event file - return if ($pa_config->{'event_file'} eq ''); + return $event_id if ($pa_config->{'event_file'} eq ''); # Add a header when the event file is created my $header = undef; @@ -3255,7 +3287,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { # Open the event file for writing if (! open (EVENT_FILE, '>>' . $pa_config->{'event_file'})) { logger($pa_config, "Error opening event file " . $pa_config->{'event_file'} . ": $!", 10); - return; + return $event_id; } # Resolve ids @@ -3278,6 +3310,29 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { print EVENT_FILE "$agent_name,".safe_output($group_name)."," . safe_output ($evento) . ",$timestamp,$event_status,$utimestamp,$event_type,".safe_output($module_name).",".safe_output($alert_name).",$severity,".safe_output($comment).",".safe_output($module_tags).",$source,$id_extra,$user_name,".safe_output($critical_instructions).",".safe_output($warning_instructions).",".safe_output($unknown_instructions).",$ack_utimestamp\n"; close (EVENT_FILE); + + return $event_id; +} + +########################################################################## +=head2 C<< pandora_extended_event (I<$pa_config>, I<$dbh>, I<$event_id>, I<$description>) >> + +Creates an extended event linked to an existing main event id. + +=cut +########################################################################## +sub pandora_extended_event($$$$) { + my ($pa_config, $dbh, $event_id, $description) = @_; + + return unless defined($event_id) && "$event_id" ne "" && $event_id > 0; + + return db_do( + $dbh, + 'INSERT INTO tevent_extended (id_evento, utimestamp, description) VALUES (?,?,?)', + $event_id, + time(), + safe_input($description) + ); } ########################################################################## @@ -3418,7 +3473,16 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { $alert->{'oid'} = decode_entities($alert->{'oid'}); my $oid = $alert->{'oid'}; if ($oid ne '') { - next if (index ($trap_oid, $oid) == -1 && index ($trap_oid_text, $oid) == -1); + my $term = substr($oid, -1); + # Strict match. + if ($term eq '$') { + chop($oid); + next if ($trap_oid ne $oid && $trap_oid_text ne $oid); + } + # Partial match. + else { + next if (index ($trap_oid, $oid) == -1 && index ($trap_oid_text, $oid) == -1); + } $alert_data .= "OID: $oid "; } @@ -3454,6 +3518,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { # Specific SNMP Trap alert macros for regexp selectors in trap info my %macros; + $macros{'_trap_id_'} = $trap_id; $macros{'_snmp_oid_'} = $trap_oid; $macros{'_snmp_value_'} = $trap_value; @@ -3707,11 +3772,6 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { } } - -########################################################################## -# Utility functions, not to be exported. -########################################################################## - ########################################################################## # Search string for macros and substitutes them with their values. ########################################################################## @@ -3746,6 +3806,19 @@ sub subst_alert_macros ($$;$$$$) { return $string; } +########################################################################## +# Substitute macros if the string begins with an underscore. +########################################################################## +sub subst_column_macros ($$;$$$$) { + my ($string, $macros, $pa_config, $dbh, $agent, $module) = @_; + + # Do not attempt to substitute macros unless the string + # begins with an underscore. + return $string unless substr($string, 0, 1) eq '_'; + + return subst_alert_macros($string, $macros, $pa_config, $dbh, $agent, $module); +} + ########################################################################## # Load macros that access the database on demand. ########################################################################## @@ -3774,9 +3847,16 @@ sub on_demand_macro($$$$$$) { } elsif ($macro eq '_name_tag_') { return (defined ($module)) ? pandora_get_module_tags ($pa_config, $dbh, $module->{'id_agente_modulo'}) : ''; } elsif ($macro =~ /_agentcustomfield_(\d+)_/) { - return '' unless defined ($agent); + my $agent_id = undef; + if (defined($module)) { + $agent_id = $module->{'id_agente'}; + } elsif (defined($agent)) { + $agent_id = $agent->{'id_agente'}; + } else { + return ''; + } my $field_number = $1; - my $field_value = get_db_value($dbh, 'SELECT description FROM tagent_custom_data WHERE id_field=? AND id_agent=?', $field_number, $agent->{'id_agente'}); + my $field_value = get_db_value($dbh, 'SELECT description FROM tagent_custom_data WHERE id_field=? AND id_agent=?', $field_number, $agent_id); return (defined($field_value)) ? $field_value : ''; } elsif ($macro eq '_prevdata_') { return '' unless defined ($module); @@ -3840,6 +3920,10 @@ sub on_demand_macro($$$$$$) { } } +########################################################################## +# Utility functions, not to be exported. +########################################################################## + ########################################################################## # Process module data. ########################################################################## @@ -4514,7 +4598,7 @@ sub pandora_server_statistics ($$) { $server->{"lag"} = 0; $server->{"module_lag"} = 0; # Recon server - } elsif ($server->{"server_type"} == RECONSERVER) { + } elsif ($server->{"server_type"} == DISCOVERYSERVER) { # Total jobs running on this recon server $server->{"modules"} = get_db_value ($dbh, "SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ?", $server->{"id_server"}); @@ -5746,6 +5830,62 @@ sub pandora_safe_mode_modules_update { } } +########################################################################## + +=head2 C<< message_set_targets (I<$dbh>, I<$pa_config>, I<$notification_id>, I<$users>, I<$groups>) >> +Set targets for given messaje (users and groups in hash ref) +=cut + +########################################################################## +sub notification_set_targets { + my ($pa_config, $dbh, $notification_id, $users, $groups) = @_; + my $ret = undef; + + if (!defined($pa_config)) { + return undef; + } + + if (!defined($notification_id)) { + return undef; + } + + if (ref($users) eq "ARRAY") { + my $values = {}; + foreach my $user (@{$users}) { + if (defined($user) && $user eq "") { + next; + } + + $values->{'id_mensaje'} = $notification_id; + $values->{'id_user'} = $user; + } + + $ret = db_process_insert($dbh, '', 'tnotification_user', $values); + if (!$ret) { + return undef; + } + } + + if (ref($groups) eq "ARRAY") { + my $values = {}; + foreach my $group (@{$groups}) { + if ($group != 0 && empty($group)) { + next; + } + + $values->{'id_mensaje'} = $notification_id; + $values->{'id_group'} = $group; + } + + $ret = db_process_insert($dbh, '', 'tnotification_group', $values); + if (!$ret) { + return undef; + } + } + + return 1; +} + # End of function declaration # End of defined Code diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 20bece94e6..a257d5df07 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -20,6 +20,8 @@ package PandoraFMS::DB; use strict; use warnings; use DBI; + +use lib '/usr/lib/perl5'; use PandoraFMS::Tools; #use Data::Dumper; diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm similarity index 87% rename from pandora_server/lib/PandoraFMS/ReconServer.pm rename to pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 277e3a3ec8..bc4e1caa73 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -1,6 +1,6 @@ -package PandoraFMS::ReconServer; +package PandoraFMS::DiscoveryServer; ########################################################################## -# Pandora FMS Recon Server. +# Pandora FMS Discovery Server. # Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org ########################################################################## # Copyright (c) 2005-2009 Artica Soluciones Tecnologicas S.L @@ -28,6 +28,7 @@ use IO::Socket::INET; use POSIX qw(strftime ceil); use JSON qw(decode_json encode_json); use Encode qw(encode_utf8); +use MIME::Base64; # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; @@ -57,16 +58,16 @@ use constant OS_ROUTER => 17; use constant OS_SWITCH => 18; ######################################################################################## -# Recon Server class constructor. +# Discovery Server class constructor. ######################################################################################## sub new ($$$$$$) { my ($class, $config, $dbh) = @_; - return undef unless $config->{'reconserver'} == 1; + return undef unless $config->{'reconserver'} == 1 || $config->{'discoveryserver'} == 1; if (! -e $config->{'nmap'}) { - logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1); - print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1); + logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1); + print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1); return undef; } @@ -78,14 +79,14 @@ sub new ($$$$$$) { # Restart automatic recon tasks. db_do ($dbh, 'UPDATE trecon_task SET utimestamp = 0 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep > 0', - get_server_id ($dbh, $config->{'servername'}, RECONSERVER)); + get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER)); # Reset (but do not restart) manual recon tasks. db_do ($dbh, 'UPDATE trecon_task SET status = -1 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep = 0', - get_server_id ($dbh, $config->{'servername'}, RECONSERVER)); + get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER)); # Call the constructor of the parent class - my $self = $class->SUPER::new($config, RECONSERVER, \&PandoraFMS::ReconServer::data_producer, \&PandoraFMS::ReconServer::data_consumer, $dbh); + my $self = $class->SUPER::new($config, DISCOVERYSERVER, \&PandoraFMS::DiscoveryServer::data_producer, \&PandoraFMS::DiscoveryServer::data_consumer, $dbh); bless $self, $class; return $self; @@ -98,8 +99,14 @@ sub run ($) { my $self = shift; my $pa_config = $self->getConfig (); - print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Recon Server.", 1); - $self->setNumThreads ($pa_config->{'recon_threads'}); + print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Discovery Server.", 1); + my $threads = $pa_config->{'recon_threads'}; + + # Use hightest value + if ($pa_config->{'discovery_threads'} > $pa_config->{'recon_threads'}) { + $threads = $pa_config->{'discovery_threads'}; + } + $self->setNumThreads($threads); $self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem); } @@ -121,9 +128,10 @@ sub data_producer ($) { # Status -1 means "done". my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task - WHERE id_recon_server = ? - AND disabled = 0 - AND utimestamp = 0 OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id); + WHERE id_recon_server = ? + AND disabled = 0 + AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1) + OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id); foreach my $row (@rows) { # Update task status @@ -154,12 +162,15 @@ sub data_consumer ($$) { logger($pa_config, 'Starting recon task for net ' . $task->{'subnet'} . '.', 10); } - # Call nmap - my $nmap_args = '-nsP -PE --max-retries '.$pa_config->{'icmp_checks'}.' --host-timeout '.$pa_config->{'networktimeout'}.'s -T'.$pa_config->{'recon_timing_template'}; - my $np = new PandoraFMS::NmapParser; eval { my @subnets = split(/,/, safe_output($task->{'subnet'})); my @communities = split(/,/, safe_output($task->{'snmp_community'})); + my @auth_strings = (); + if(defined($task->{'auth_strings'})) { + @auth_strings = split(/,/, safe_output($task->{'auth_strings'})); + } + + my $main_event = pandora_event($pa_config, "[Discovery] Execution summary",$task->{'id_group'}, 0, 0, 0, 0, 'system', 0, $dbh); my $recon = new PandoraFMS::Recon::Base( communities => \@communities, @@ -186,6 +197,10 @@ sub data_consumer ($$) { subnets => \@subnets, task_id => $task->{'id_rt'}, vlan_cache_enabled => $task->{'vlan_enabled'}, + wmi_enabled => $task->{'wmi_enabled'}, + auth_strings_array => \@auth_strings, + autoconfiguration_enabled => $task->{'autoconfiguration_enabled'}, + main_event_id => $main_event, %{$pa_config} ); @@ -225,7 +240,13 @@ sub exec_recon_script ($$$) { # \r and \n should be escaped for decode_json(). $macros =~ s/\n/\\n/g; $macros =~ s/\r/\\r/g; - my $decoded_macros = decode_json (encode_utf8($macros)); + my $decoded_macros; + + if ($macros) { + eval { + $decoded_macros = decode_json(encode_utf8($macros)); + }; + } my $macros_parameters = ''; @@ -244,15 +265,28 @@ sub exec_recon_script ($$$) { $macros_parameters = $macros_parameters . ' "' . $m->{"value"} . '"'; } } + + my $ent_script = 0; + my $args = enterprise_hook('discovery_custom_recon_scripts',[$pa_config, $dbh, $task, $script]); + if (!$args) { + $args = "$task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters"; + } else { + $ent_script = 1; + } if (-x $command) { - `$command $task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters`; + my $exec_output = `$command $args`; + logger($pa_config, "Execution output: \n". $exec_output, 10); } else { - logger ($pa_config, "Cannot execute recon task command $command."); + logger($pa_config, "Cannot execute recon task command $command.", 10); } # Only update the timestamp in case something went wrong. The script should set the status. db_do ($dbh, 'UPDATE trecon_task SET utimestamp = ? WHERE id_rt = ?', time (), $task->{'id_rt'}); + + if ($ent_script == 1) { + enterprise_hook('discovery_clean_custom_recon',[$pa_config, $dbh, $task, $script]); + } logger($pa_config, 'Done executing recon script ' . safe_output($script->{'name'}), 10); return 0; @@ -441,7 +475,23 @@ sub PandoraFMS::Recon::Base::create_agent($$) { $location->{'longitude'}, $location->{'latitude'} ); return undef unless defined ($agent_id) and ($agent_id > 0); - pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); + + # Autoconfigure agent + if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) { + my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id); + # Update agent configuration once, after create agent. + enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, 1]); + } + + if (defined($self->{'main_event_id'})) { + my $addresses_str = join(',', safe_output($self->get_addresses($device))); + pandora_extended_event( + $self->{'pa_config'}, $self->{'dbh'}, $self->{'main_event_id'}, + "[Discovery] New " . safe_output($self->get_device_type($device)) . " found " . $host_name . " (" . $addresses_str . ") Agent $agent_id." + ); + + } + $agent_learning = 1; # Create network profile modules for the agent @@ -748,6 +798,35 @@ sub PandoraFMS::Recon::Base::set_parent($$$) { db_do($self->{'dbh'}, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $agent_parent->{'id_agente'}, $agent->{'id_agente'}); } +########################################################################## +# Create a WMI module for the given agent. +########################################################################## +sub PandoraFMS::Recon::Base::wmi_module { + my ($self, $agent_id, $target, $wmi_query, $wmi_auth, $column, + $module_name, $module_description, $module_type, $unit) = @_; + + # Check whether the module already exists. + my $module_id = get_agent_module_id($self->{'dbh'}, $module_name, $agent_id); + return if ($module_id > 0); + + my ($user, $pass) = ($wmi_auth ne '') ? split('%', $wmi_auth) : (undef, undef); + my %module = ( + 'descripcion' => safe_input($module_description), + 'id_agente' => $agent_id, + 'id_modulo' => 6, + 'id_tipo_modulo' => get_module_id($self->{'dbh'}, $module_type), + 'ip_target' => $target, + 'nombre' => safe_input($module_name), + 'plugin_pass' => defined($pass) ? $pass : '', + 'plugin_user' => defined($user) ? $user : '', + 'snmp_oid' => $wmi_query, + 'tcp_port' => $column, + 'unit' => defined($unit) ? $unit : '' + ); + + pandora_create_module_from_hash($self->{'pa_config'}, \%module, $self->{'dbh'}); +} + ########################################################################## # Update recon task status. ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index cea3733764..72ff78d975 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -344,14 +344,20 @@ sub pandora_snmp_get_command ($$$$$$$$$$$) { sub pandora_query_snmp ($$$$) { my ($pa_config, $module, $ip_target, $dbh) = @_; + # Initialize macros. + my %macros = ( + '_agentcustomfield_\d+_' => undef, + ); + + my $snmp_version = $module->{"tcp_send"}; # (1, 2, 2c or 3) my $snmp3_privacy_method = $module->{"custom_string_1"}; # DES/AES - my $snmp3_privacy_pass = safe_output(pandora_output_password($pa_config, $module->{"custom_string_2"})); + my $snmp3_privacy_pass = safe_output(pandora_output_password($pa_config, subst_column_macros($module->{"custom_string_2"}, \%macros, $pa_config, $dbh, undef, $module))); my $snmp3_security_level = $module->{"custom_string_3"}; # noAuthNoPriv|authNoPriv|authPriv - my $snmp3_auth_user = safe_output($module->{"plugin_user"}); - my $snmp3_auth_pass = safe_output(pandora_output_password($pa_config, $module->{"plugin_pass"})); + my $snmp3_auth_user = safe_output(subst_column_macros($module->{"plugin_user"}, \%macros, $pa_config, $dbh, undef, $module)); + my $snmp3_auth_pass = safe_output(pandora_output_password($pa_config, subst_column_macros($module->{"plugin_pass"}, \%macros, $pa_config, $dbh, undef, $module))); my $snmp3_auth_method = $module->{"plugin_parameter"}; #MD5/SHA1 - my $snmp_community = $module->{"snmp_community"}; + my $snmp_community = safe_output(subst_column_macros($module->{"snmp_community"}, \%macros, $pa_config, $dbh, undef, $module)); my $snmp_target = $ip_target; my $snmp_oid = $module->{"snmp_oid"}; my $snmp_port = $module->{"tcp_port"}; diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index e5dfc75307..41cb56f39b 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -32,7 +32,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.731"; -my $pandora_build = "190215"; +my $pandora_build = "190226"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); @@ -163,6 +163,8 @@ sub csv_to_obj { @hr_headers = map { $_ =~ s/\"//g; trim($_); } @hr_headers; foreach my $line (@lines) { + next if empty($line); + my $i = 0; my %hr = map { $_ =~ s/\"//g; $hr_headers[$i++] => trim($_) } split /,/, $line; diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index a214d6ba4b..ec3eb0d853 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -123,6 +123,12 @@ sub new { # Globally enable/disable SNMP scans. snmp_enabled => 1, + # Globally enable/disable WMI scans. + wmi_enabled => 0, + auth_strings_array => [], + wmi_timeout => 3, + timeout_cmd => '', + # Switch to switch connections. Used to properly connect hosts # that are connected to a switch wich is in turn connected to another switch, # since the hosts will show up in the latter's switch AFT too. @@ -160,6 +166,7 @@ sub new { snmp_timeout => 2, snmp_version => 1, subnets => [], + autoconfiguration_enabled => 0, @_, }; @@ -217,6 +224,19 @@ sub new { } } + # Prepare auth array. + # WMI could be launched with '-N' - no pass - argument. + if ($self->{'wmi_enabled'} == 1){ + if (defined($self->{'auth_strings_str'})) { + @{$self->{'auth_strings_array'}} = split(',', $self->{'auth_strings_str'}); + } + + # Timeout available only in linux environments. + if ($^O =~ /lin/i && defined($self->{'plugin_exec'}) && defined($self->{'wmi_timeout'})) { + $self->{'timeout_cmd'} = $self->{'plugin_exec'}.' '.$self->{'wmi_timeout'}.' '; + } + } + # Remove all snmp related values if disabled if (!$self->{'snmp_enabled'}) { $self->{'communities'} = []; @@ -1312,6 +1332,9 @@ sub scan_subnet($) { $progress += $step; $self->snmp_discovery($host); + + # Add wmi scan if enabled. + $self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1); } } # ping scan. @@ -1330,6 +1353,9 @@ sub scan_subnet($) { next if ($self->ping($host) == 0); $self->snmp_discovery($host); + + # Add wmi scan if enabled. + $self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1); } } } @@ -1475,6 +1501,9 @@ sub snmp_get_command { my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe "; if ($self->{'snmp_version'} eq "3") { + if ($self->{'community'}) { # Context + $command .= " -N $self->{'community'} "; + } $command .= " -l$self->{'snmp_security_level'} "; if ($self->{'snmp_security_level'} ne "noAuthNoPriv") { $command .= " -u$self->{'snmp_auth_user'} -a$self->{'snmp_auth_method'} -A$self->{'snmp_auth_pass'} "; @@ -1579,6 +1608,168 @@ sub traceroute_connectivity($$) { } } +########################################################################## +# Returns the credentials with which the host responds to WMI queries or +# undef if it does not respond to WMI. +########################################################################## +sub responds_to_wmi { + my ($self, $target) = @_; + + foreach my $auth (@{$self->{'auth_strings_array'}}) { + my @output; + if ($auth ne '') { + @output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -U $auth //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`; + } else { + @output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -N //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`; + } + + foreach my $line (@output) { + chomp($line); + return $auth if ($line =~ m/^CLASS: Win32_ComputerSystem$/); + } + } + + return undef; +} + +########################################################################## +# Add wmi modules to the given host. +########################################################################## +sub wmi_scan { + my ($self, $target) = @_; + + $self->call('message', "[".$target."] Checking WMI.", 5); + + my $auth = $self->responds_to_wmi($target); + return unless defined($auth); + + $self->call('message', "[".$target."] WMI available.", 10); + # Create the agent if it does not exist. + my $agent_id = $self->call('create_agent', $target); + next unless defined($agent_id); + + # CPU. + my @cpus = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceId FROM Win32_Processor', 0); + foreach my $cpu (@cpus) { + $self->call( + 'wmi_module', + ( + $agent_id, + $target, + "SELECT LoadPercentage FROM Win32_Processor WHERE DeviceId='$cpu'", + $auth, + 1, + "CPU Load $cpu", + "Load for $cpu (%)", + 'generic_data' + ) + ); + } + + # Memory. + my $mem = $self->wmi_get_value($target, $auth, 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem', 0); + if (defined($mem)) { + $self->call('wmi_module', + ( + $agent_id, + $target, + "SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem", + $auth, + 0, + 'FreeMemory', + 'Free memory', + 'generic_data', + 'KB' + ) + ); + } + + # Disk. + my @units = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceID FROM Win32_LogicalDisk', 0); + foreach my $unit (@units) { + $self->call( + 'wmi_module', + ( + $agent_id, + $target, + "SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID='$unit'", + $auth, + 1, + "FreeDisk $unit", + 'Available disk space in kilobytes', + 'generic_data', + 'KB' + ) + ); + } +} + +########################################################################## +# Extra: WMI imported methods. DO NOT EXPORT TO AVOID DOUBLE DEF. +########################################################################## + +########################################################################## +# Performs a wmi get requests and returns the response as an array. +########################################################################## +sub wmi_get { + my ($self, $target, $auth, $query) = @_; + + my @output; + if (defined($auth) && $auth ne '') { + @output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -U $auth //$target "$query" 2>&1`; + }else { + @output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -N //$target "$query" 2>&1`; + } + + # Something went wrong. + return () if ($? != 0); + + return @output; +} + +########################################################################## +# Performs a WMI request and returns the requested column of the first row. +# Returns undef on error. +########################################################################## +sub wmi_get_value { + my ($self, $target, $auth, $query, $column) = @_; + my @result; + + my @output = $self->wmi_get($target, $auth, $query); + return undef unless defined($output[2]); + + my $line = $output[2]; + chomp($line); + my @columns = split(/\|/, $line); + return undef unless defined($columns[$column]); + + return $columns[$column]; +} + +########################################################################## +# Performs a WMI request and returns row values for the requested column +# in an array. +########################################################################## +sub wmi_get_value_array { + my ($self, $target, $auth, $query, $column) = @_; + my @result; + + my @output = $self->wmi_get($target, $auth, $query); + foreach (my $i = 2; defined($output[$i]); $i++) { + my $line = $output[$i]; + chomp($line); + my @columns = split(/\|/, $line); + next unless defined($columns[$column]); + push(@result, $columns[$column]); + } + + return @result; +} + +########################################################################## +# END: WMI imported methods. +########################################################################## + 1; __END__ diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 1146e8ce92..aababebd69 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -51,7 +51,7 @@ our @EXPORT = qw( DATASERVER NETWORKSERVER SNMPCONSOLE - RECONSERVER + DISCOVERYSERVER PLUGINSERVER PREDICTIONSERVER WMISERVER @@ -134,7 +134,7 @@ our @EXPORT = qw( use constant DATASERVER => 0; use constant NETWORKSERVER => 1; use constant SNMPCONSOLE => 2; -use constant RECONSERVER => 3; +use constant DISCOVERYSERVER => 3; use constant PLUGINSERVER => 4; use constant PREDICTIONSERVER => 5; use constant WMISERVER => 6; diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index b667de6a91..3606166508 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -142,13 +142,21 @@ sub data_consumer ($$) { my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente_modulo = ?', $module_id); return unless defined $module; + # Initialize macros. + my %macros = ( + '_agentcustomfield_\d+_' => undef, + ); + # Build command to execute my $wmi_command = ''; if (defined ($module->{'plugin_pass'}) && $module->{'plugin_pass'} ne "") { - $wmi_command = $pa_config->{'wmi_client'} . ' -U "' . safe_output($module->{'plugin_user'}) . '"%"' . pandora_output_password($pa_config, $module->{'plugin_pass'}) . '"'; + my $user = safe_output(subst_column_macros($module->{'plugin_user'}, \%macros, $pa_config, $dbh, undef, $module)); + my $pass = safe_output(pandora_output_password($pa_config, subst_column_macros($module->{'plugin_pass'}, \%macros, $pa_config, $dbh, undef, $module))); + $wmi_command = $pa_config->{'wmi_client'} . ' -U "' . $user . '"%"' . $pass . '"'; } elsif (defined ($module->{'plugin_user'}) && $module->{'plugin_user'} ne "") { - $wmi_command = $pa_config->{'wmi_client'} . ' -U "' . safe_output($module->{'plugin_user'}) . '"'; + my $user = safe_output(subst_column_macros($module->{'plugin_user'}, \%macros, $pa_config, $dbh, undef, $module)); + $wmi_command = $pa_config->{'wmi_client'} . ' -U "' . $user . '"'; } else { $wmi_command = $pa_config->{'wmi_client'} . ' -N'; diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index e0834c0d3a..076f19497a 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190215 +%define release 190226 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 29a5c3e307..e3adf2711e 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190215 +%define release 190226 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 1b9483c5fe..55915d85a0 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190215" +PI_BUILD="190226" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 97816668a5..c8eb037f7a 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.731 PS190215"; +my $version = "7.0NG.731 PS190226"; # Pandora server configuration my %conf; @@ -432,6 +432,13 @@ sub pandora_purgedb ($$) { # Delete old tgraph_source data db_do ($dbh,"DELETE FROM tgraph_source WHERE id_graph NOT IN (SELECT id_graph FROM tgraph)"); + + # Delete old messages + log_message ('PURGE', "Deleting old messages."); + if ($conf->{'_delete_old_messages'} > 0) { + my $message_limit = time() - 86400 * $conf->{'_delete_old_messages'}; + db_do ($dbh, "DELETE FROM tmensajes WHERE timestamp < ?", $message_limit); + } } ############################################################################### @@ -651,6 +658,7 @@ sub pandora_load_config_pdb ($) { $conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'"); $conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'"); $conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'"); + $conf->{'_delete_old_messages'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_messages'"); $conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'"); $conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'"); $conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'"); diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 2bedc1f01e..bda564a07a 100644 --- 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.731 PS190215"; +my $version = "7.0NG.731 PS190226"; # save program name for logging my $progname = basename($0); @@ -200,7 +200,7 @@ sub help_screen{ print "\nINCIDENTS:\n\n" unless $param ne ''; help_screen_line('--create_incident', " <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents'); print "\nPOLICIES:\n\n" unless $param ne ''; - help_screen_line('--apply_policy', '<id_policy> [<id_agent> <return> <name agent>]', 'Force apply a policy'); + help_screen_line('--apply_policy', '<id_policy> [<id_agent> <name(boolean)> <id_server>]', 'Force apply a policy in an agent'); help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy'); help_screen_line('--remove_agent_from_policy', '<policy_id> <agent_id>', 'Delete an agent to a policy'); @@ -3606,10 +3606,10 @@ sub cli_delete_data($) { ############################################################################## sub cli_apply_policy() { - my ($id_policy, $id_agent, $name, $return) = @ARGV[2..5]; + my ($id_policy, $id_agent, $name, $id_server) = @ARGV[2..5]; # Call the API. - my $result = api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$return"); + my $result = api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$id_server"); print "\n$result\n"; } @@ -3627,7 +3627,7 @@ sub cli_apply_all_policies() { my $added = 0; foreach my $policy (@{$policies}) { - my $ret = enterprise_hook('pandora_add_policy_queue', [$dbh, $conf, $policy->{'id'}, 'apply']); + my $ret = enterprise_hook('pandora_add_policy_queue', [$dbh, $conf, $policy->{'id'}, 'apply', 0, 1]); if($ret != -1) { $added++; print_log "[INFO] Added operation 'apply' to policy '".safe_output($policy->{'name'})."'\n";