diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f9c18d1803..1e659ae284 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.735-190603 +Version: 7.0NG.735-190619 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 df6d0ddafb..d6993d2d19 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.735-190603" +pandora_version="7.0NG.735-190619" 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 2f07c16bdb..5ce17de55c 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.735'; -use constant AGENT_BUILD => '190603'; +use constant AGENT_BUILD => '190619'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -3038,10 +3038,10 @@ while (1) { my @address_list; if( -x "/bin/ip" || -x "/sbin/ip" || -x "/usr/sbin/ip" ) { - @address_list = `ip addr show 2>$DevNull | sed -e '/127.0.0/d' -e '/[0-9]*\\.[0-9]*\\.[0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/\\/.*//'`; + @address_list = `ip addr show 2>$DevNull | sed -e '/127.0.0/d' -e '/\\([0-9][0-9]*\\.\\)\\{3\\}[0-9][0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/\\/.*//'`; } else { - @address_list = `ifconfig -a 2>$DevNull | sed -e '/127.0.0/d' -e '/[0-9]*\\.[0-9]*\\.[0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/.*://'`; + @address_list = `ifconfig -a 2>$DevNull | sed -e '/127.0.0/d' -e '/\\([0-9][0-9]*\\.\\)\\{3\\}[0-9][0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/.*://'`; } for (my $i = 0; $i <= $#address_list; $i++) { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index e25ec45570..0a25523900 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.735 -%define release 190603 +%define release 190619 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 e98f09fe82..672869336d 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.735 -%define release 190603 +%define release 190619 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 964972dcb7..2bb4896d58 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.735" -PI_BUILD="190603" +PI_BUILD="190619" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/grep_log b/pandora_agents/unix/plugins/grep_log index 2e17210a51..76661c5230 100755 --- a/pandora_agents/unix/plugins/grep_log +++ b/pandora_agents/unix/plugins/grep_log @@ -6,17 +6,17 @@ # # grep_log Perl script to search log files for a matching pattern. The last # searched position is saved in an index file so that consecutive -# runs do not return the same results. The log file inode number is +# runs do not return the same results. The log file inode number is # also saved to detect log rotation. # # 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 of the License. -# +# # 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. +# GNU General Public License for more details. # ############################################################################### use strict; @@ -30,7 +30,7 @@ my $Output = 'module'; my $Verbose = 0; # Index file storage directory, with a trailing '/' -my $Idx_dir=($^O =~ /win/i)?'.\\':'/tmp/'; +my $Idx_dir=($^O =~ /win/i)?"$ENV{'TMP'}\\":"/tmp/"; # Log file my $Log_file = ''; @@ -64,7 +64,7 @@ if ( (defined ($ENV{GREP_LOG_TMP})) && (-d $ENV{GREP_LOG_TMP}) ) { } ######################################################################################## -# Erase blank spaces before and after the string +# Erase blank spaces before and after the string ######################################################################################## sub trim($){ my $string = shift; @@ -226,7 +226,7 @@ sub parse_log (;$$) { open(LOGFILE, $Log_file) || error_msg("Error opening file $Log_file: " . $!); - # Go to starting position. + # Go to starting position. seek(LOGFILE, $Idx_pos, 0); # Parse log file @@ -318,7 +318,7 @@ sub print_log ($) { print_summary() if ($summary_flag == 1); return; } - + # Log module if ($Output eq 'log_module') { my $output = "\n"; diff --git a/pandora_agents/win32/bin/util/grep_log.exe b/pandora_agents/win32/bin/util/grep_log.exe index a21e080805..4e4029fb60 100644 Binary files a/pandora_agents/win32/bin/util/grep_log.exe and b/pandora_agents/win32/bin/util/grep_log.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8b06da5ae2..f06d41720b 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190603} +{190619} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 3b7eebf6e5..6f2965b7b8 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.735(Build 190603)") +#define PANDORA_VERSION ("7.0NG.735(Build 190619)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 005a397ef2..d1e6134c6c 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.735(Build 190603))" + VALUE "ProductVersion", "(7.0NG.735(Build 190619))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index f5afe29f9f..28979a99ef 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.735-190603 +Version: 7.0NG.735-190619 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 f2fdf35d7f..a65a5185cd 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.735-190603" +pandora_version="7.0NG.735-190619" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index b5860068d8..97657f5189 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -1,23 +1,24 @@ '.__('Group').''; $filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;'); $filter_recursion_label = ''.__('Recursion').''; $filter_recursion = html_print_checkbox('recursion', 1, 0, true); - // groups module + // Groups module. $filter_module_groups_label = ''.__('Module group').''; $filter_module_groups = html_print_select_from_sql( 'SELECT * FROM tmodule_group ORDER BY name', @@ -146,7 +147,7 @@ function mainAgentsModules() 'width: auto;' ); - // agent + // Agent. $agents = agents_get_group_agents($group_id); if ((empty($agents)) || $agents == -1) { $agents = []; @@ -155,7 +156,7 @@ function mainAgentsModules() $filter_agents_label = ''.__('Agents').''; $filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;'); - // type show + // Type show. $selection = [ 0 => __('Show common modules'), 1 => __('Show all modules'), @@ -163,12 +164,12 @@ function mainAgentsModules() $filter_type_show_label = ''.__('Show common modules').''; $filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;'); - // modules + // Modules. $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); $filter_modules_label = ''.__('Module').''; $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;'); - // update + // Update. $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); $onheader = [ @@ -178,8 +179,11 @@ function mainAgentsModules() 'combo_groups' => $filter_groups, ]; - // Old style table, we need a lot of special formatting,don't use table function - // Prepare old-style table + /* + * Old style table, we need a lot of special formatting,don't use table function. + * Prepare old-style table. + */ + if ($config['pure'] == 0) { // Header. ui_print_page_header( @@ -200,38 +204,51 @@ function mainAgentsModules() $full_modules = urlencode(implode(';', $full_modules_selected)); $full_agents = urlencode(implode(';', $full_agents_id)); - $url = " index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset + $url = 'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset &group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules - &full_agents_id=$full_agents&selection_agent_module=$selection_a_m"; + &full_agents_id=$full_agents&selection_agent_module=$selection_a_m'; } else { - $url = " index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr"; + $url = 'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr'; } - // Floating menu - Start + // Floating menu - Start. echo '
'; echo ''; echo '
'; - // Floating menu - End + // Floating menu - End. ui_require_jquery_file('countdown'); } if ($config['pure'] != 1) { - echo '
'; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo "'; - echo ''; - echo '
'.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.''.$filter_module_groups_label.''.$filter_module_groups.'
'.$filter_agents_label.''.$filter_agents.''.$filter_type_show_label.''.$filter_type_show.''.$filter_modules_label.''.$filter_modules.'
".$filter_update.'
'; - echo '
'; + $show_filters = '
'; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= "'; + $show_filters .= ''; + $show_filters .= '
'.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.''.$filter_module_groups_label.''.$filter_module_groups.'
'.$filter_agents_label.''.$filter_agents.''.$filter_type_show_label.''.$filter_type_show.''.$filter_modules_label.''.$filter_modules.'
".$filter_update.'
'; + $show_filters .= '
'; + ui_toggle($show_filters, __('Filters')); } if ($agents_id[0] != -1) { @@ -291,7 +308,7 @@ function mainAgentsModules() $count = 0; foreach ($agents as $agent) { - // TODO TAGS agents_get_modules + // TODO TAGS agents_get_modules. $module = agents_get_modules( $agent, false, @@ -339,7 +356,7 @@ function mainAgentsModules() } } } else { - // TODO TAGS agents_get_modules + // TODO TAGS agents_get_modules. $all_modules = agents_get_modules( $agents, false, @@ -414,11 +431,11 @@ function mainAgentsModules() if ($hor_offset > 0) { $new_hor_offset = ($hor_offset - $block); - echo ""."".html_print_image( - 'images/arrow_left.png', + echo "".html_print_image( + 'images/arrow_left_green.png', true, ['title' => __('Previous modules')] - ).''.''; + ).''; } $nmodules = 0; @@ -440,11 +457,11 @@ function mainAgentsModules() if (($hor_offset + $block) < $nmodules) { $new_hor_offset = ($hor_offset + $block); - echo ""."".html_print_image( - 'images/arrow.png', + echo "".html_print_image( + 'images/arrow_right_green.png', true, ['title' => __('More modules')] - ).''.''; + ).''; } echo ''; @@ -457,12 +474,12 @@ function mainAgentsModules() $filter_agents['id_grupo'] = $group_id; } - // Prepare pagination - $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&'.'hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; + // Prepare pagination. + $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; ui_pagination($total_pagination, $url); foreach ($agents as $agent) { - // Get stats for this group + // Get stats for this group. $agent_status = agents_get_status($agent['id_agente']); $alias = db_get_row('tagente', 'id_agente', $agent['id_agente']); if (empty($alias['alias'])) { @@ -471,29 +488,29 @@ function mainAgentsModules() switch ($agent_status) { case 4: - // Alert fired status + // Alert fired status. $rowcolor = 'group_view_alrm'; break; case 1: - // Critical status + // Critical status. $rowcolor = 'group_view_crit'; break; case 2: - // Warning status + // Warning status. $rowcolor = 'group_view_warn'; break; case 0: - // Normal status + // Normal status. $rowcolor = 'group_view_ok'; break; case 3: case -1: default: - // Unknown status + // Unknown status. $rowcolor = 'group_view_unk'; break; } @@ -502,7 +519,7 @@ function mainAgentsModules() echo " ".$alias['alias'].''; - // TODO TAGS agents_get_modules + // TODO TAGS agents_get_modules. $agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true); $nmodules = 0; @@ -572,18 +589,23 @@ function mainAgentsModules() echo ''; - echo "
"; + $show_legend = "
"; + $show_legend .= "
+
".__('Orange cell when the module has fired alerts').'
'; + $show_legend .= "
+
".__('Red cell when the module has a critical status').' +
'; + $show_legend .= "
+
".__('Yellow cell when the module has a warning status').'
'; + $show_legend .= "
+
".__('Green cell when the module has a normal status').'
'; + $show_legend .= "
+
".__('Grey cell when the module has an unknown status').'
'; + $show_legend .= "
+
".__("Cell turns blue when the module is in 'not initialize' status").'
'; + $show_legend .= '
'; + ui_toggle($show_legend, __('Legend')); - echo ''; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo '
".__('Legend').'
".__('Orange cell when the module has fired alerts').'
".__('Red cell when the module has a critical status').'
".__('Yellow cell when the module has a warning status').'
".__('Green cell when the module has a normal status').'
".__('Grey cell when the module has an unknown status').'
".__("Cell turns blue when the module is in 'not initialize' status").'
'; - echo '
'; $pure_var = $config['pure']; if ($pure_var) { $pure_var = 1; @@ -627,16 +649,14 @@ $ignored_params['refresh'] = ''; $.each($('.th_class_module_r'), function (i, elem) { id = $(elem).attr('id').replace('th_module_r_', ''); $("#th_module_r_" + id).height(($("#div_module_r_" + id).width() + 10) + 'px'); - - //$("#div_module_r_" + id).css('margin-top', (max_width - $("#div_module_r_" + id).width()) + 'px'); $("#div_module_r_" + id).css('margin-top', (max_width - 20) + 'px'); $("#div_module_r_" + id).show(); }); - var refr =" . $refr . "; - var pure =" . $pure_var . "; - var href ='" . ui_get_url_refresh ($ignored_params) . "'; - + var refr = ''; + var pure = ''; + var href =' '; + if (pure) { var startCountDown = function (duration, cb) { $('div.vc-countdown').countdown('destroy'); @@ -646,7 +666,7 @@ $ignored_params['refresh'] = ''; $('div.vc-countdown').countdown({ until: t, format: 'MS', - layout: '(%M%nn%M:%S%nn%S Until refresh)', + layout: '(%M%nn%M:%S%nn%S ) ', alwaysExpire: true, onExpiry: function () { $('div.vc-countdown').countdown('destroy'); @@ -655,8 +675,11 @@ $ignored_params['refresh'] = ''; } }); } - - startCountDown(refr, false); + + if(refr>0){ + startCountDown(refr, false); + } + var controls = document.getElementById('vc-controls'); autoHideElement(controls, 1000); diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 2d8669f83f..d78ff90fc8 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -215,7 +215,7 @@ function extension_db_check_tables_differences( $diff_tables = array_diff($tables_test, $tables_system); ui_print_result_message( - !empty($diff_tables), + empty($diff_tables), __('Success! %s DB contains all tables', get_product_name()), __( '%s DB could not retrieve all tables. The missing tables are (%s)', diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt deleted file mode 100644 index 82ce1527aa..0000000000 --- a/pandora_console/extras/delete_files/delete_files.txt +++ /dev/null @@ -1,3 +0,0 @@ -/general/login_identification_wizard.php -/general/login_required.php -/godmode/update_manager/update_manager.messages.php \ No newline at end of file diff --git a/pandora_console/extras/mr/29.sql b/pandora_console/extras/mr/29.sql new file mode 100644 index 0000000000..032dd407b1 --- /dev/null +++ b/pandora_console/extras/mr/29.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +DELETE FROM `ttipo_modulo` WHERE `nombre` LIKE 'log4x'; + + +COMMIT; diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index c5420c26bd..f3b11177d1 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -139,8 +139,9 @@ function get_logs_size($file) function get_status_logs($path) { $status_server_log = ''; - $size_server_log = get_logs_size($path); - if ($size_server_log <= 1048576) { + $size_server_log = number_format(get_logs_size($path)); + $size_server_log = (0 + str_replace(',', '', $size_server_log)); + if ($size_server_log <= 10485760) { $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"; 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 4261fdf88b..2c9ff7e7de 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 @@ -1989,6 +1989,33 @@ CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( UNIQUE (`source`, `destination`, `utimestamp`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; +-- --------------------------------------------------------------------- +-- Table `user_task` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tuser_task` ( + `id` int(20) unsigned NOT NULL auto_increment, + `function_name` varchar(80) NOT NULL default '', + `parameters` text NOT NULL default '', + `name` varchar(60) NOT NULL default '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `user_task_scheduled` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` ( + `id` int(20) unsigned NOT NULL auto_increment, + `id_usuario` varchar(60) NOT NULL default '0', + `id_user_task` int(20) unsigned NOT NULL default '0', + `args` TEXT NOT NULL, + `scheduled` enum('no','hourly','daily','weekly','monthly','yearly','custom') default 'no', + `last_run` int(20) unsigned default '0', + `custom_data` int(10) NULL default '0', + `flag_delete` tinyint(1) UNSIGNED NOT NULL default 0, + `id_grupo` int(10) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ----------------------------------------------------- -- Table `tnotification_source` -- ----------------------------------------------------- diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index 5730fea501..b08dc62c4f 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -322,7 +322,7 @@ if ($create_modules) { } else if (preg_match('/ifAdminStatus/', $name_array[1])) { $module_type = 2; } else if (preg_match('/ifOperStatus/', $name_array[1])) { - $module_type = 18; + $module_type = 2; } else { $module_type = 4; } @@ -608,11 +608,11 @@ ui_require_jquery_file('bgiframe'); $(document).ready (function () { var inputActive = true; - + $(document).data('text_for_module', $("#none_text").html()); - + $("#id_snmp").change(snmp_changed_by_multiple_snmp); - + $("#snmp_version").change(function () { if (this.value == "3") { $("#snmp3_options").css("display", ""); @@ -621,7 +621,7 @@ $(document).ready (function () { $("#snmp3_options").css("display", "none"); } }); - + $("#walk_form").submit(function() { $("#submit-snmp_walk").disable (); $("#oid_loading").show (); @@ -632,15 +632,15 @@ $(document).ready (function () { function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { var idSNMP = Array(); - + jQuery.each ($("#id_snmp option:selected"), function (i, val) { idSNMP.push($(val).val()); }); $('#module').attr ('disabled', 1); $('#module').empty (); $('#module').append ($('').html ("Loading...").attr ("value", 0)); - - jQuery.post ('ajax.php', + + jQuery.post ('ajax.php', {"page" : "godmode/agentes/agent_manager", "get_modules_json_for_multiple_snmp": 1, "id_snmp[]": idSNMP, @@ -655,7 +655,7 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { $('#module').fadeIn ('normal'); c++; }); - + if (c == 0) { if (typeof($(document).data('text_for_module')) != 'undefined') { $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true)); @@ -666,11 +666,11 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { } else { var anyText = $("#any_text").html(); //Trick for catch the translate text. - + if (anyText == null) { anyText = 'Any'; } - + $('#module').append ($('').html (anyText).attr ("value", 0).prop('selected', true)); } } @@ -684,4 +684,3 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { /* ]]> */ - diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 902d074f21..0e08a3728f 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -118,7 +118,7 @@ if ($enable_agent) { enterprise_include_once('include/functions_agents.php'); $values = ['disabled' => 0]; enterprise_hook('agent_update_from_cache', [$enable_agent, $values, $server_name]); - + config_agents_update_config_token($enable_agent, 'standby', 0); db_pandora_audit('Agent management', 'Enable '.$alias); } else { db_pandora_audit('Agent management', 'Fail to enable '.$alias); @@ -140,6 +140,7 @@ if ($disable_agent) { enterprise_include_once('include/functions_agents.php'); $values = ['disabled' => 1]; enterprise_hook('agent_update_from_cache', [$disable_agent, $values, $server_name]); + config_agents_update_config_token($disable_agent, 'standby', 1); db_pandora_audit('Agent management', 'Disable '.$alias); } else { diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index 6ad7311179..09501c358b 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -83,8 +83,8 @@ $data[3] = html_print_input_password( true, $disabledBecauseInPolicy, false, - '', - $classdisabledBecauseInPolicy + $classdisabledBecauseInPolicy, + 'new-password' ); push_table_simple($data, 'user_pass'); diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 0e632380ce..8277463e18 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -357,8 +357,8 @@ function addConnectionMap() { for (var index in connectionMaps) { if (isInt(index)) { if (connectionMaps[index] == idConnectionMap) { - alert(" "' + connectionMapName + '" "); - + alert(" " + connectionMapName + " "); + return; } } diff --git a/pandora_console/godmode/massive/massive_edit_plugins.php b/pandora_console/godmode/massive/massive_edit_plugins.php index 48688ded8d..7513c99eb9 100644 --- a/pandora_console/godmode/massive/massive_edit_plugins.php +++ b/pandora_console/godmode/massive/massive_edit_plugins.php @@ -725,7 +725,6 @@ echo ''; } }); - $modulesSelect.change(); } var processGet = function (params, callback) { diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 93806138cb..a5e59e46ce 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -221,7 +221,7 @@ switch ($action) { $server_name = $item['server_name']; // Metaconsole db connection. - if ($meta && $server_name != '') { + if ($meta && !empty($server_name)) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { continue; @@ -547,8 +547,43 @@ switch ($action) { break; case 'event_report_agent': - case 'event_report_group': + $description = $item['description']; + $period = $item['period']; + $group = $item['id_group']; $recursion = $item['recursion']; + $idAgent = $item['id_agent']; + $idAgentModule = $item['id_agent_module']; + + + $show_summary_group = $style['show_summary_group']; + $filter_event_severity = json_decode($style['filter_event_severity'], true); + $filter_event_status = json_decode($style['filter_event_status'], true); + $filter_event_type = json_decode($style['filter_event_type'], true); + + $event_graph_by_user_validator = $style['event_graph_by_user_validator']; + $event_graph_by_criticity = $style['event_graph_by_criticity']; + $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; + $include_extended_events = $item['show_extended_events']; + + $filter_search = $style['event_filter_search']; + + break; + + case 'event_report_group': + $description = $item['description']; + $period = $item['period']; + $group = $item['id_group']; + $recursion = $item['recursion']; + + $event_graph_by_agent = $style['event_graph_by_agent']; + $event_graph_by_user_validator = $style['event_graph_by_user_validator']; + $event_graph_by_criticity = $style['event_graph_by_criticity']; + $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; + + $filter_search = $style['event_filter_search']; + + + $include_extended_events = $item['show_extended_events']; break; @@ -2805,7 +2840,7 @@ function print_SLA_list($width, $action, $idItem=null) foreach ($itemsSLA as $item) { $server_name = $item['server_name']; // Metaconsole db connection. - if ($meta && $server_name != '') { + if ($meta && !empty($server_name)) { $connection = metaconsole_get_connection( $server_name ); @@ -3133,7 +3168,7 @@ function print_General_list($width, $action, $idItem=null, $type='general') foreach ($itemsGeneral as $item) { $server_name = $item['server_name']; // Metaconsole db connection. - if ($meta && $server_name != '') { + if ($meta && !empty($server_name)) { $connection = metaconsole_get_connection( $server_name ); @@ -3491,6 +3526,7 @@ $(document).ready (function () { $("#submit-create_item").click(function () { var type = $('#type').val(); + var name = $('#text-name').val(); switch (type){ case 'alert_report_module': case 'alert_report_agent': @@ -3521,6 +3557,13 @@ $(document).ready (function () { default: break; } + + if($('#text-name').val() == ''){ + alert( ); + return false; + } + + }); $("#submit-edit_item").click(function () { diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 44e616977d..b77f8665c7 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -45,6 +45,9 @@ .parent() .addClass('checkselected'); $(".check_delete").prop("checked", true); + $('.check_delete').each(function(){ + $('#hidden-id_report_'+$(this).val()).prop("disabled", false); + }); } else{ $('[id^=checkbox-massive_report_check]') @@ -1345,6 +1348,8 @@ switch ($action) { $values['description'] = get_parameter('description'); $values['type'] = get_parameter('type', null); $values['recursion'] = get_parameter('recursion', null); + $values['show_extended_events'] = get_parameter('include_extended_events', null); + $label = get_parameter('label', ''); // Add macros name. @@ -1900,8 +1905,8 @@ switch ($action) { $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; - $style['event_filter_search'] = $event_filter_search; + if ($label != '') { $style['label'] = $label; } else { @@ -2007,6 +2012,7 @@ switch ($action) { ); $name_it = (string) get_parameter('name'); $values['recursion'] = get_parameter('recursion', null); + $values['show_extended_events'] = get_parameter('include_extended_events', null); $values['name'] = reporting_label_macro( $items_label, $name_it @@ -2418,6 +2424,7 @@ switch ($action) { case 'event_report_agent': case 'event_report_group': case 'event_report_module': + $show_summary_group = get_parameter( 'show_summary_group', 0 @@ -2473,22 +2480,11 @@ switch ($action) { $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; - - - switch ($values['type']) { - case 'event_report_group': - case 'event_report_agent': - $style['event_filter_search'] = $event_filter_search; - if ($label != '') { - $style['label'] = $label; - } else { - $style['label'] = ''; - } - break; - - default: - // Default. - break; + $style['event_filter_search'] = $event_filter_search; + if ($label != '') { + $style['label'] = $label; + } else { + $style['label'] = ''; } break; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index cb72ce58ce..85cbd9be5e 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -254,7 +254,12 @@ function update_button_palette_callback() { var values = {}; values = readFields(); - + if (values["map_linked"] == 0) { + if (values["agent"] == "" || values["agent"] == "none") { + dialog_message("#message_alert_no_agent"); + return false; + } + } // TODO VALIDATE DATA switch (selectedItem) { case "background": @@ -1260,6 +1265,7 @@ function create_button_palette_callback() { dialog_message("#message_alert_max_height"); validate = false; } + break; case "group_item": if (values["height"] == "") { @@ -1323,6 +1329,12 @@ function create_button_palette_callback() { dialog_message("#message_alert_no_image"); validate = false; } + if (values["map_linked"] == 0) { + if (values["agent"] == "" || values["agent"] == "none") { + dialog_message("#message_alert_no_agent"); + validate = false; + } + } break; case "auto_sla_graph": diff --git a/pandora_console/godmode/setup/license.php b/pandora_console/godmode/setup/license.php index f03d32ef0a..06d7d2e7e3 100644 --- a/pandora_console/godmode/setup/license.php +++ b/pandora_console/godmode/setup/license.php @@ -135,7 +135,9 @@ $table->data[9][0] = ''.__('Licensed to').''; $table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true); html_print_table($table); -if (enterprise_installed()) { + +// If DESTDIR is defined the enterprise license is expired. +if (enterprise_installed() || defined('DESTDIR')) { echo '
'; html_print_input_hidden('update_settings', 1); html_print_submit_button(__('Validate'), 'update_button', false, 'class="sub upd"'); diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index f76678ffb6..2398e3b1c5 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -659,18 +659,18 @@ class Wizard if ($input['arguments']['inline'] != 'true') { $output .= '
'; } else { - $output .= '
'; + $output .= '
'; if (!isset($input['extra'])) { $output .= '
'; } if (isset($input['extra'])) { - $output .= '
'; + $output .= '
'; } } if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) { - $output .= '
'; + $output .= '
'; } $output .= '
'; @@ -690,11 +690,11 @@ class Wizard $output .= $this->printInput($input['arguments']); $output .= '
'; } else if ($input['arguments']['inline'] == 'true') { - $output .= '
'; - if (isset($input['extra'])) { - $output .= '
'; + $output .= '
'; + $output .= '
'; } else { + $output .= '
'; $output .= '
'; } diff --git a/pandora_console/images/arrow_left_green.png b/pandora_console/images/arrow_left_green.png new file mode 100644 index 0000000000..b6aadc9639 Binary files /dev/null and b/pandora_console/images/arrow_left_green.png differ diff --git a/pandora_console/images/groups_small_white/application_osx.png b/pandora_console/images/groups_small_white/application_osx.png new file mode 100644 index 0000000000..409d9742d2 Binary files /dev/null and b/pandora_console/images/groups_small_white/application_osx.png differ diff --git a/pandora_console/images/groups_small_white/application_osx_terminal.png b/pandora_console/images/groups_small_white/application_osx_terminal.png new file mode 100644 index 0000000000..3deb76aa34 Binary files /dev/null and b/pandora_console/images/groups_small_white/application_osx_terminal.png differ diff --git a/pandora_console/images/groups_small_white/applications.png b/pandora_console/images/groups_small_white/applications.png new file mode 100644 index 0000000000..362ed8b98d Binary files /dev/null and b/pandora_console/images/groups_small_white/applications.png differ diff --git a/pandora_console/images/groups_small_white/bricks.png b/pandora_console/images/groups_small_white/bricks.png new file mode 100644 index 0000000000..b68255b88b Binary files /dev/null and b/pandora_console/images/groups_small_white/bricks.png differ diff --git a/pandora_console/images/groups_small_white/chart_organisation.png b/pandora_console/images/groups_small_white/chart_organisation.png new file mode 100644 index 0000000000..d80fc4f65f Binary files /dev/null and b/pandora_console/images/groups_small_white/chart_organisation.png differ diff --git a/pandora_console/images/groups_small_white/clock.png b/pandora_console/images/groups_small_white/clock.png new file mode 100644 index 0000000000..dc16f55773 Binary files /dev/null and b/pandora_console/images/groups_small_white/clock.png differ diff --git a/pandora_console/images/groups_small_white/computer.png b/pandora_console/images/groups_small_white/computer.png new file mode 100644 index 0000000000..5eab00e255 Binary files /dev/null and b/pandora_console/images/groups_small_white/computer.png differ diff --git a/pandora_console/images/groups_small_white/database.png b/pandora_console/images/groups_small_white/database.png new file mode 100644 index 0000000000..397f3fa5d3 Binary files /dev/null and b/pandora_console/images/groups_small_white/database.png differ diff --git a/pandora_console/images/groups_small_white/database_gear.png b/pandora_console/images/groups_small_white/database_gear.png new file mode 100644 index 0000000000..72a6b63d0f Binary files /dev/null and b/pandora_console/images/groups_small_white/database_gear.png differ diff --git a/pandora_console/images/groups_small_white/drive_network.png b/pandora_console/images/groups_small_white/drive_network.png new file mode 100644 index 0000000000..4e1cd615c6 Binary files /dev/null and b/pandora_console/images/groups_small_white/drive_network.png differ diff --git a/pandora_console/images/groups_small_white/email.png b/pandora_console/images/groups_small_white/email.png new file mode 100644 index 0000000000..496991da88 Binary files /dev/null and b/pandora_console/images/groups_small_white/email.png differ diff --git a/pandora_console/images/groups_small_white/eye.png b/pandora_console/images/groups_small_white/eye.png new file mode 100644 index 0000000000..f5c8a4e940 Binary files /dev/null and b/pandora_console/images/groups_small_white/eye.png differ diff --git a/pandora_console/images/groups_small_white/firewall.png b/pandora_console/images/groups_small_white/firewall.png new file mode 100644 index 0000000000..261adbcb1e Binary files /dev/null and b/pandora_console/images/groups_small_white/firewall.png differ diff --git a/pandora_console/images/groups_small_white/heart.png b/pandora_console/images/groups_small_white/heart.png new file mode 100644 index 0000000000..6bfec0298a Binary files /dev/null and b/pandora_console/images/groups_small_white/heart.png differ diff --git a/pandora_console/images/groups_small_white/house.png b/pandora_console/images/groups_small_white/house.png new file mode 100644 index 0000000000..72ab42dd35 Binary files /dev/null and b/pandora_console/images/groups_small_white/house.png differ diff --git a/pandora_console/images/groups_small_white/images.png b/pandora_console/images/groups_small_white/images.png new file mode 100644 index 0000000000..195c7e222b Binary files /dev/null and b/pandora_console/images/groups_small_white/images.png differ diff --git a/pandora_console/images/groups_small_white/lightning.png b/pandora_console/images/groups_small_white/lightning.png new file mode 100644 index 0000000000..31a0670a68 Binary files /dev/null and b/pandora_console/images/groups_small_white/lightning.png differ diff --git a/pandora_console/images/groups_small_white/lock.png b/pandora_console/images/groups_small_white/lock.png new file mode 100644 index 0000000000..522ff71bd6 Binary files /dev/null and b/pandora_console/images/groups_small_white/lock.png differ diff --git a/pandora_console/images/groups_small_white/network.png b/pandora_console/images/groups_small_white/network.png new file mode 100644 index 0000000000..1a8573a729 Binary files /dev/null and b/pandora_console/images/groups_small_white/network.png differ diff --git a/pandora_console/images/groups_small_white/plugin.png b/pandora_console/images/groups_small_white/plugin.png new file mode 100644 index 0000000000..051ec05d6b Binary files /dev/null and b/pandora_console/images/groups_small_white/plugin.png differ diff --git a/pandora_console/images/groups_small_white/printer.png b/pandora_console/images/groups_small_white/printer.png new file mode 100644 index 0000000000..4187e87a00 Binary files /dev/null and b/pandora_console/images/groups_small_white/printer.png differ diff --git a/pandora_console/images/groups_small_white/server_database.png b/pandora_console/images/groups_small_white/server_database.png new file mode 100644 index 0000000000..864e3cb7cb Binary files /dev/null and b/pandora_console/images/groups_small_white/server_database.png differ diff --git a/pandora_console/images/groups_small_white/transmit.png b/pandora_console/images/groups_small_white/transmit.png new file mode 100644 index 0000000000..d27f5c377d Binary files /dev/null and b/pandora_console/images/groups_small_white/transmit.png differ diff --git a/pandora_console/images/groups_small_white/without_group.png b/pandora_console/images/groups_small_white/without_group.png new file mode 100644 index 0000000000..30915bd101 Binary files /dev/null and b/pandora_console/images/groups_small_white/without_group.png differ diff --git a/pandora_console/images/groups_small_white/world.png b/pandora_console/images/groups_small_white/world.png new file mode 100644 index 0000000000..dcfd04139b Binary files /dev/null and b/pandora_console/images/groups_small_white/world.png differ diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index 9baacdcdc2..21d3d11085 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -299,6 +299,7 @@ if (check_login()) { 'status' => "
".$image_status.'
', 'id_agent' => $values['id_tagente'], 'id_server' => $values['id_tmetaconsole_setup'], + 'status_value' => $values['status'], ]; } diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 76dc24e145..a99d0c93fe 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -392,11 +392,16 @@ if (check_login()) { switch ($row['module_type']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id); + // System Uptime: + // In case of System Uptime module, shows data in format "Days hours minutes seconds" if and only if + // selected module unit is "_timeticks_" + // Take notice that selected unit may not be postrocess unit if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - if ($post_process > 0) { - $data[] = human_milliseconds_to_string(($row['data'] / $post_process)); + $data_macro = modules_get_unit_macro($row[$attr[0]], $unit); + if ($data_macro) { + $data[] = $data_macro; } else { - $data[] = human_milliseconds_to_string($row['data']); + $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); } } else { $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 1ab383b672..5ef2fed828 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -282,39 +282,42 @@ function process_user_login_remote($login, $pass, $api=false) } } } else if ($config['auth'] === 'ldap') { - if ($config['ldap_save_password']) { - $update_credentials = change_local_user_pass_ldap($login, $pass); + // Check if autocreate remote users is active. + if ($config['autocreate_remote_users'] == 1) { + if ($config['ldap_save_password']) { + $update_credentials = change_local_user_pass_ldap($login, $pass); - if ($update_credentials) { - $config['auth_error'] = __('Your permissions have changed. Please, login again.'); - return false; - } - } else { - delete_user_pass_ldap($login); - } - - $permissions = fill_permissions_ldap($sr); - if (empty($permissions)) { - $config['auth_error'] = __('User not found in database or incorrect password'); - return false; - } else { - // check permissions - $result = check_permission_ad( - $login, - $pass, - false, - $permissions, - defined('METACONSOLE') - ); - - if ($return === 'error_permissions') { - $config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator'); - return false; - } else { - if ($return === 'permissions_changed') { + if ($update_credentials) { $config['auth_error'] = __('Your permissions have changed. Please, login again.'); return false; } + } else { + delete_user_pass_ldap($login); + } + + $permissions = fill_permissions_ldap($sr); + if (empty($permissions)) { + $config['auth_error'] = __('User not found in database or incorrect password'); + return false; + } else { + // check permissions + $result = check_permission_ad( + $login, + $pass, + false, + $permissions, + defined('METACONSOLE') + ); + + if ($return === 'error_permissions') { + $config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator'); + return false; + } else { + if ($return === 'permissions_changed') { + $config['auth_error'] = __('Your permissions have changed. Please, login again.'); + return false; + } + } } } } @@ -1337,8 +1340,9 @@ function fill_permissions_ldap($sr) 'tags' => implode(',', $ldap_adv_perm['tags']), 'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0, ]; - return $permissions; } + + return $permissions; } foreach ($result as $perms) { @@ -1468,7 +1472,10 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $tls = ' -ZZ '; } - if (stripos($ldap_host, 'ldap') !== false) { + if (stripos($ldap_host, 'ldap://') !== false + || stripos($ldap_host, 'ldaps://') !== false + || stripos($ldap_host, 'ldapi://') !== false + ) { $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; } else { $ldap_host = ' -h '.$ldap_host.' -p '.$ldap_port; diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index eaf3c55fea..2316714031 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -72,6 +72,8 @@ class TreeService extends Tree protected function getFirstLevel() { + global $config; + $processed_items = $this->getProcessedServices(); $ids = array_keys($processed_items); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 28807adbf9..26be9a68e7 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190603'; +$build_version = 'PC190619'; $pandora_version = 'v7.0NG.735'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 9809c31b8a..2525462793 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1392,6 +1392,11 @@ function enterprise_installed() { $return = false; + // Load enterprise extensions. + if (defined('DESTDIR')) { + return $return; + } + if (defined('PANDORA_ENTERPRISE')) { if (PANDORA_ENTERPRISE) { $return = true; @@ -1444,7 +1449,7 @@ function enterprise_include($filename) { global $config; - // Load enterprise extensions + // Load enterprise extensions. if (defined('DESTDIR')) { $destdir = DESTDIR; } else { @@ -1481,9 +1486,13 @@ function enterprise_include_once($filename) { global $config; - defined('ENTERPRISE_DIR') || define('ENTERPRISE_DIR', 'enterprise'); - // Load enterprise extensions. + if (defined('DESTDIR')) { + $destdir = DESTDIR; + } else { + $destdir = ''; + } + $filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename); if ($filepath === false) { diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 3c6cdbf595..e683b74f7d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -11519,7 +11519,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][18] != '') { $values['id_extra'] = $other['data'][18]; - $sql_validation = 'SELECT id_evento FROM tevento where estado=0 and id_extra ="'.$other['data'][18].'";'; + $sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";'; $validation = db_get_all_rows_sql($sql_validation); if ($validation) { foreach ($validation as $val) { diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 4ef3800fca..1d346f3b6d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -180,7 +180,7 @@ function config_update_config() $error_update[] = __('Automatic check for updates'); } - if (!config_update_value('cert_path', (bool) get_parameter('cert_path'))) { + if (!config_update_value('cert_path', get_parameter('cert_path'))) { $error_update[] = __('SSL cert path'); } @@ -270,7 +270,7 @@ function config_update_config() $error_update[] = __('Referer security'); } - if (!config_update_value('event_storm_protection', get_parameter('event_storm_protection'))) { + if (!config_update_value('event_storm_protection', get_parameter('event_storm_protection', 0))) { $error_update[] = __('Event storm protection'); } @@ -2167,9 +2167,9 @@ function config_process_config() if (!isset($config['ad_adv_perms'])) { config_update_value('ad_adv_perms', ''); } else { + $temp_ad_adv_perms = []; if (!json_decode(io_safe_output($config['ad_adv_perms']))) { - $temp_ad_adv_perms = []; - if (!isset($config['ad_adv_perms']) && $config['ad_adv_perms'] != '') { + if ($config['ad_adv_perms'] != '') { $perms = explode(';', io_safe_output($config['ad_adv_perms'])); foreach ($perms as $ad_adv_perm) { if (preg_match('/[\[\]]/', $ad_adv_perm)) { @@ -2232,22 +2232,26 @@ function config_process_config() if (!empty($new_ad_adv_perms)) { $temp_ad_adv_perms = json_encode($new_ad_adv_perms); } + } else { + $temp_ad_adv_perms = ''; } - - config_update_value('ad_adv_perms', $temp_ad_adv_perms); + } else { + $temp_ad_adv_perms = $config['ad_adv_perms']; } + + config_update_value('ad_adv_perms', $temp_ad_adv_perms); } if (!isset($config['ldap_adv_perms'])) { config_update_value('ldap_adv_perms', ''); } else { + $temp_ldap_adv_perms = []; if (!json_decode(io_safe_output($config['ldap_adv_perms']))) { - $temp_ldap_adv_perms = []; - if (!isset($config['ad_adv_perms']) && $config['ldap_adv_perms'] != '') { + if ($config['ldap_adv_perms'] != '') { $perms = explode(';', io_safe_output($config['ldap_adv_perms'])); - foreach ($perms as $ad_adv_perm) { - if (preg_match('/[\[\]]/', $ad_adv_perm)) { - $all_data = explode(',', io_safe_output($ad_adv_perm)); + foreach ($perms as $ldap_adv_perm) { + if (preg_match('/[\[\]]/', $ldap_adv_perm)) { + $all_data = explode(',', io_safe_output($ldap_adv_perm)); $profile = $all_data[0]; $group_pnd = $all_data[1]; $groups_ad = str_replace(['[', ']'], '', $all_data[2]); @@ -2277,7 +2281,7 @@ function config_process_config() 'groups_ldap' => $groups_ldap, ]; } else { - $all_data = explode(',', io_safe_output($ad_adv_perm)); + $all_data = explode(',', io_safe_output($ldap_adv_perm)); $profile = $all_data[0]; $group_pnd = $all_data[1]; $groups_ad = $all_data[2]; @@ -2306,10 +2310,14 @@ function config_process_config() if (!empty($new_ldap_adv_perms)) { $temp_ldap_adv_perms = json_encode($new_ldap_adv_perms); } + } else { + $temp_ldap_adv_perms = ''; } - - config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); + } else { + $temp_ldap_adv_perms = $config['ldap_adv_perms']; } + + config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); } if (!isset($config['rpandora_server'])) { diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 9570098766..d1f661e874 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -188,10 +188,16 @@ function get_custom_fields_data($custom_field_name) } $array_result = []; - if (isset($result_meta) && is_array($result_meta)) { + if (isset($result_meta) === true + && is_array($result_meta) === true + ) { foreach ($result_meta as $result) { - foreach ($result as $k => $v) { - $array_result[$v['description']] = $v['description']; + if (isset($result) === true + && is_array($result) === true + ) { + foreach ($result as $k => $v) { + $array_result[$v['description']] = $v['description']; + } } } } @@ -385,9 +391,13 @@ function agent_counters_custom_fields($filters) // Filter custom data. $custom_data_and = ''; - if (!in_array(-1, $filters['id_custom_fields_data'])) { - $custom_data_array = implode("', '", $filters['id_custom_fields_data']); - $custom_data_and = "AND tcd.description IN ('".$custom_data_array."')"; + if (isset($filters['id_custom_fields_data']) === true + && is_array($filters['id_custom_fields_data']) === true + ) { + if (!in_array(-1, $filters['id_custom_fields_data'])) { + $custom_data_array = implode("', '", $filters['id_custom_fields_data']); + $custom_data_and = "AND tcd.description IN ('".$custom_data_array."')"; + } } // Filter custom name. @@ -693,3 +703,123 @@ function print_counters_cfv( $html_result .= ''; return $html_result; } + + +/** + * Function for export a csv file from Custom Fields View + * + * @param array $filters Status counters for agents and modules. + * @param array $id_status Agent status. + * @param array $module_status Module status. + * + * @return array Returns the data that will be saved in the csv file + */ +function export_custom_fields_csv($filters, $id_status, $module_status) +{ + $data = agent_counters_custom_fields($filters); + $indexed_descriptions = $data['indexed_descriptions']; + + // Table temporary for save array in table + // by order and search custom_field data. + $table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields ( + id_server int(10), + id_agent int(10), + name_custom_fields varchar(2048), + critical_count int, + warning_count int, + unknown_count int, + notinit_count int, + normal_count int, + total_count int, + `status` int(2), + KEY `data_index_temp_1` (`id_server`, `id_agent`) + )'; + db_process_sql($table_temporary); + + // Insert values array in table temporary. + $values_insert = []; + foreach ($indexed_descriptions as $key => $value) { + $values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')'; + } + + $values_insert_implode = implode(',', $values_insert); + $query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode; + db_process_sql($query_insert); + + // Search for status module. + $status_agent_search = ''; + if (isset($id_status) === true && is_array($id_status) === true) { + if (in_array(-1, $id_status) === false) { + if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $id_status) === false) { + $status_agent_search = ' AND temp.status IN ('.implode(',', $id_status).')'; + } else { + // Not normal statuses. + $status_agent_search = ' AND temp.status IN (1,2,3,4,5)'; + } + } + } + + // Search for status module. + $status_module_search = ''; + if (isset($module_status) === true && is_array($module_status) === true) { + if (in_array(-1, $module_status) === false) { + if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status) === false) { + if (count($module_status) > 0) { + $status_module_search = ' AND ( '; + foreach ($module_status as $key => $value) { + $status_module_search .= ($key != 0) ? ' OR (' : ' ('; + switch ($value) { + default: + case AGENT_STATUS_NORMAL: + $status_module_search .= ' temp.normal_count > 0) '; + break; + case AGENT_STATUS_CRITICAL: + $status_module_search .= ' temp.critical_count > 0) '; + break; + + case AGENT_STATUS_WARNING: + $status_module_search .= ' temp.warning_count > 0) '; + break; + + case AGENT_STATUS_UNKNOWN: + $status_module_search .= ' temp.unknown_count > 0) '; + break; + + case AGENT_STATUS_NOT_INIT: + $status_module_search .= ' temp.notinit_count > 0) '; + break; + } + } + + $status_module_search .= ' ) '; + } + } else { + // Not normal. + $status_module_search = ' AND ( temp.critical_count > 0 OR temp.warning_count > 0 OR temp.unknown_count > 0 AND temp.notinit_count > 0 )'; + } + } + } + + // Query all fields result. + $query = sprintf( + 'SELECT + temp.name_custom_fields, + tma.alias, + tma.direccion, + tma.server_name, + temp.status + FROM tmetaconsole_agent tma + INNER JOIN temp_custom_fields temp + ON temp.id_agent = tma.id_tagente + AND temp.id_server = tma.id_tmetaconsole_setup + WHERE tma.disabled = 0 + %s + %s + ', + $status_agent_search, + $status_module_search + ); + + $result = db_get_all_rows_sql($query); + return $result; +} diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 7f1118ce3f..5e888072af 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2258,7 +2258,7 @@ function events_get_response_target( global $config; // If server_id > 0, it's a metaconsole query. - $meta = $server_id > 0; + $meta = $server_id > 0 || is_metaconsole(); $event_table = events_get_events_table($meta, $history); $event = db_get_row($event_table, 'id_evento', $event_id); @@ -4551,7 +4551,7 @@ function events_list_events_grouped_agents($sql) $sql = sprintf( 'SELECT * FROM %s LEFT JOIN tagent_secondary_group - ON tagent_secondary_group.id_agent = tevento.id_agente + ON tagent_secondary_group.id_agent = id_agente WHERE %s', $table, $sql diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 86de873965..bc4f83d24d 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -289,7 +289,7 @@ function grafico_modulo_sparse_data( } } - if ($array_data === false || (!$params['graph_combined'] + if ($array_data === false && (!$params['graph_combined'] && !isset($array_data['sum1']['data'][0][1]) && !$params['baseline']) ) { return false; @@ -2235,6 +2235,7 @@ function combined_graph_summatory_average( $data_array_pop[$key_reverse] = array_pop( $data_array_reverse[$key_reverse] ); + $count_data_array_reverse--; } } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 010845caf6..505c395c68 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1233,7 +1233,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', * * @return string HTML code if return parameter is true. */ -function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return=false, $password=false, $function='') +function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return=false, $password=false, $function='', $autocomplete='off') { static $idcounter = 0; @@ -1283,7 +1283,7 @@ function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlen 'autocomplete', ]; - $output = ' $values[$key]['module_name'], 'agent_id' => $values[$key]['agent_id'], 'agent_name' => $values[$key]['agent_name'], + 'module_type' => $values[$key]['module_type'], ]; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index fba9d87a02..eb215340c3 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1383,7 +1383,7 @@ function reporting_event_top_n( foreach ($tops as $key => $row) { // Metaconsole connection. $server_name = $row['server_name']; - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { // ui_print_error_message ("Error connecting to ".$server_name); @@ -1426,7 +1426,7 @@ function reporting_event_top_n( } // Restore dbconnection. - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } } @@ -2330,7 +2330,7 @@ function reporting_exception( do { // Metaconsole connection. $server_name = $exceptions[$i]['server_name']; - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { // ui_print_error_message ("Error connecting to ".$server_name); @@ -2372,7 +2372,7 @@ function reporting_exception( $i++; // Restore dbconnection. - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } } while ($min === false && $i < count($exceptions)); @@ -2385,7 +2385,7 @@ function reporting_exception( foreach ($exceptions as $exc) { // Metaconsole connection. $server_name = $exc['server_name']; - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { // ui_print_error_message ("Error connecting to ".$server_name); @@ -2499,7 +2499,7 @@ function reporting_exception( } // Restore dbconnection - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } } @@ -2693,7 +2693,7 @@ function reporting_group_report($report, $content) { global $config; - $metaconsole_on = ($config['metaconsole'] == 1) && defined('METACONSOLE'); + $metaconsole_on = ($config['metaconsole'] == 1) && is_metaconsole(); $return['type'] = 'group_report'; @@ -6173,7 +6173,7 @@ function reporting_availability($report, $content, $date=false, $time=false) foreach ($items as $item) { // aaMetaconsole connection $server_name = $item['server_name']; - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { // ui_print_error_message ("Error connecting to ".$server_name); @@ -6185,7 +6185,7 @@ function reporting_availability($report, $content, $date=false, $time=false) || modules_is_not_init($item['id_agent_module']) ) { // Restore dbconnection - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } @@ -6242,7 +6242,7 @@ function reporting_availability($report, $content, $date=false, $time=false) $text = $row['data']['agent'].' ('.$text.')'; // Restore dbconnection - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } @@ -6807,7 +6807,7 @@ function reporting_increment($report, $content) $return['data'] = []; - if (defined('METACONSOLE')) { + if (is_metaconsole()) { $sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC'; $sql2 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC'; @@ -6845,7 +6845,7 @@ function reporting_increment($report, $content) $last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC'); } - if (!defined('METACONSOLE')) { + if (!is_metaconsole()) { } if ($old_data === false || $last_data === false) { @@ -6934,7 +6934,7 @@ function reporting_general($report, $content) foreach ($generals as $row) { // Metaconsole connection $server_name = $row['server_name']; - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { // ui_print_error_message ("Error connecting to ".$server_name); @@ -7085,7 +7085,7 @@ function reporting_general($report, $content) $i++; // Restore dbconnection - if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } } diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index d20daecb46..ca2b2d055b 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -261,138 +261,47 @@ function snmp_browser_get_tree( ) { global $config; - if ($target_ip == '') { - return __('Target IP cannot be blank.'); - } + $output = get_snmpwalk( + $target_ip, + $version, + $community, + $snmp3_auth_user, + $snmp3_security_level, + $snmp3_auth_method, + $snmp3_auth_pass, + $snmp3_privacy_method, + $snmp3_privacy_pass, + 0, + $starting_oid, + '', + $server_to_exec, + '', + '' + ); - // Call snmpwalk - if (empty($config['snmpwalk'])) { - switch (PHP_OS) { - case 'FreeBSD': - $snmpwalk_bin = '/usr/local/bin/snmpwalk'; - break; - - case 'NetBSD': - $snmpwalk_bin = '/usr/pkg/bin/snmpwalk'; - break; - - default: - $snmpwalk_bin = 'snmpwalk'; - break; - } - } else { - $snmpwalk_bin = $config['snmpwalk']; - } - - switch (PHP_OS) { - case 'WIN32': - case 'WINNT': - case 'Windows': - $error_redir_dir = 'NUL'; - break; - - default: - $error_redir_dir = '/dev/null'; - break; - } - - if ($server_to_exec != 0) { - $sql = sprintf('SELECT ip_address FROM tserver WHERE id_server = %d', $server_to_exec); - $server_data = db_get_row_sql($sql); - - if (enterprise_installed()) { - enterprise_include_once('include/functions_satellite.php'); - - $oid_tree = ['__LEAVES__' => []]; - if ($version == '3') { - switch ($snmp3_security_level) { - case 'authPriv': - $command = $snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' -x '.escapeshellarg($snmp3_privacy_method).' -X '.escapeshellarg($snmp3_privacy_pass).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir; - break; - - case 'authNoPriv': - $command = $snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir; - break; - - case 'noAuthNoPriv': - $command = $snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -l '.escapeshellarg($snmp3_security_level).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir; - break; - } - } else { - $command = $snmpwalk_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -Cc -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir; - } - - exec('ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$command.'"', $output, $rc); - } else { - $oid_tree = ['__LEAVES__' => []]; - if ($version == '3') { - switch ($snmp3_security_level) { - case 'authPriv': - exec($snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' -x '.escapeshellarg($snmp3_privacy_method).' -X '.escapeshellarg($snmp3_privacy_pass).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - break; - - case 'authNoPriv': - exec($snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - break; - - case 'noAuthNoPriv': - exec($snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -l '.escapeshellarg($snmp3_security_level).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - break; - } - } else { - exec($snmpwalk_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -Cc -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - } - } - } else { - $oid_tree = ['__LEAVES__' => []]; - if ($version == '3') { - switch ($snmp3_security_level) { - case 'authPriv': - exec($snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' -x '.escapeshellarg($snmp3_privacy_method).' -X '.escapeshellarg($snmp3_privacy_pass).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - break; - - case 'authNoPriv': - exec($snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - break; - - case 'noAuthNoPriv': - exec($snmpwalk_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -l '.escapeshellarg($snmp3_security_level).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - break; - } - } else { - exec($snmpwalk_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -Cc -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($starting_oid).' 2> '.$error_redir_dir, $output, $rc); - } - } - - foreach ($output as $line) { - // Separate the OID from the value - $full_oid = explode('=', $line); - if (! isset($full_oid[1])) { - continue; - } - - $oid = trim($full_oid[0]); - $value = trim($full_oid[1]); - - // Parse the OID + // Build the tree. + $oid_tree = ['__LEAVES__' => []]; + foreach ($output as $oid => $value) { + // Parse the OID. + $oid_len = strlen($oid); $group = 0; $sub_oid = ''; $ptr = &$oid_tree['__LEAVES__']; - for ($i = 0; $i < strlen($oid); $i++) { + for ($i = 0; $i < $oid_len; $i++) { // "X.Y.Z" if ($oid[$i] == '"') { $group = ($group ^ 1); } - // Move to the next element of the OID + // Move to the next element of the OID. if ($group == 0 && ($oid[$i] == '.' || ($oid[$i] == ':' && $oid[($i + 1)] == ':'))) { - // Skip the next : + // Skip the next ":". if ($oid[$i] == ':') { $i++; } - // Starting dot + // Starting dot. if ($sub_oid == '') { continue; } @@ -410,7 +319,7 @@ function snmp_browser_get_tree( } } - // The last element will contain the full OID + // The last element will contain the full OID. $ptr[$sub_oid] = [ '__OID__' => $oid, '__VALUE__' => $value, @@ -459,83 +368,27 @@ function snmp_browser_get_oid( return; } + $output = get_snmpwalk( + $target_ip, + $version, + $community, + $snmp3_auth_user, + $snmp3_security_level, + $snmp3_auth_method, + $snmp3_auth_pass, + $snmp3_privacy_method, + $snmp3_privacy_pass, + 0, + $target_oid, + '', + $server_to_exec, + '', + '-On' + ); + $oid_data['oid'] = $target_oid; - if (empty($config['snmpget'])) { - switch (PHP_OS) { - case 'FreeBSD': - $snmpget_bin = '/usr/local/bin/snmpget'; - break; - - case 'NetBSD': - $snmpget_bin = '/usr/pkg/bin/snmpget'; - break; - - default: - $snmpget_bin = 'snmpget'; - break; - } - } else { - $snmpget_bin = $config['snmpget']; - } - - switch (PHP_OS) { - case 'WIN32': - case 'WINNT': - case 'Windows': - $error_redir_dir = 'NUL'; - break; - - default: - $error_redir_dir = '/dev/null'; - break; - } - - if ($server_to_exec != 0) { - $sql = sprintf( - 'SELECT ip_address FROM tserver WHERE id_server = %d', - $server_to_exec - ); - $server_data = db_get_row_sql($sql); - - if ($version == '3') { - $command = $snmpget_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' -x '.escapeshellarg($snmp3_privacy_method).' -X '.escapeshellarg($snmp3_privacy_pass).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir; - } else { - $command = $snmpget_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -On -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir; - } - - exec( - 'ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$command.'"', - $output, - $rc - ); - } else { - if ($version == '3') { - exec( - $snmpget_bin.' -m ALL -v 3 -u '.escapeshellarg($snmp3_auth_user).' -A '.escapeshellarg($snmp3_auth_pass).' -l '.escapeshellarg($snmp3_security_level).' -a '.escapeshellarg($snmp3_auth_method).' -x '.escapeshellarg($snmp3_privacy_method).' -X '.escapeshellarg($snmp3_privacy_pass).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir, - $output, - $rc - ); - } else { - exec( - $snmpget_bin.' -m ALL -M +'.escapeshellarg($config['homedir'].'/attachment/mibs').' -On -c '.escapeshellarg(io_safe_output($community)).' -v '.escapeshellarg($version).' '.escapeshellarg($target_ip).' '.escapeshellarg($target_oid).' 2> '.$error_redir_dir, - $output, - $rc - ); - } - } - - if ($rc != 0) { - return $oid_data; - } - - foreach ($output as $line) { - // Separate the OID from the value. - $full_oid = explode('=', $line); - if (! isset($full_oid[1])) { - break; - } - - $oid = trim($full_oid[0]); + foreach ($output as $oid => $value) { + $oid = trim($oid); $oid_data['numeric_oid'] = $oid; // Translate the OID. @@ -594,16 +447,19 @@ function snmp_browser_get_oid( $oid_data['description'] = $custom_data['description']; } - $full_value = explode(':', trim($full_oid[1])); + $full_value = explode(':', trim($value)); if (! isset($full_value[1])) { - $oid_data['value'] = trim($full_oid[1]); + $oid_data['value'] = trim($value); } else { $oid_data['type'] = trim($full_value[0]); $oid_data['value'] = trim($full_value[1]); } - return $oid_data; + // There should only be one OID. + break; } + + return $oid_data; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 59b76ba00f..c81148b9c9 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4364,7 +4364,7 @@ function ui_print_agent_autocomplete_input($parameters) function '.$javascript_on_blur_function_name.'() { input_value = $("#'.$input_id.'").val(); - if (input_value.length == 0) { + if (input_value.length < 2) { if (('.((int) $print_hidden_input_idagent).') || ('.((int) $use_hidden_input_idagent).')) { $("#'.$hidden_input_idagent_id.'").val(0); @@ -4415,7 +4415,7 @@ function ui_print_agent_autocomplete_input($parameters) url: action="'.$javascript_ajax_page.'", dataType: "json", success: function (data) { - if (data.length == 0) { + if (data.length < 2) { //Set icon $("#'.$input_id.'") .css("background", diff --git a/pandora_console/include/javascript/buttons.html5.min.js b/pandora_console/include/javascript/buttons.html5.min.js new file mode 100644 index 0000000000..deee7fee68 --- /dev/null +++ b/pandora_console/include/javascript/buttons.html5.min.js @@ -0,0 +1,35 @@ +/*! + HTML5 export buttons for Buttons and DataTables. + 2016 SpryMedia Ltd - datatables.net/license + + FileSaver.js (1.3.3) - MIT license + Copyright © 2016 Eli Grey - http://eligrey.com +*/ +(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(g){return f(g,window,document)}):"object"===typeof exports?module.exports=function(g,p,z,t){g||(g=window);p&&p.fn.dataTable||(p=require("datatables.net")(g,p).$);p.fn.dataTable.Buttons||require("datatables.net-buttons")(g,p);return f(p,g,g.document,z,t)}:f(jQuery,window,document)})(function(f,g,p,z,t,w){function A(a){for(var b="";0<=a;)b=String.fromCharCode(a%26+65)+b,a=Math.floor(a/ +26)-1;return b}function E(a,b){y===w&&(y=-1===C.serializeToString(f.parseXML(F["xl/worksheets/sheet1.xml"])).indexOf("xmlns:r"));f.each(b,function(b,c){if(f.isPlainObject(c))b=a.folder(b),E(b,c);else{if(y){var d=c.childNodes[0],e,h=[];for(e=d.attributes.length-1;0<=e;e--){var m=d.attributes[e].nodeName;var k=d.attributes[e].nodeValue;-1!==m.indexOf(":")&&(h.push({name:m,value:k}),d.removeAttribute(m))}e=0;for(m=h.length;e'+c),c=c.replace(/_dt_b_namespace_token_/g,":"),c=c.replace(/xmlns:NS[\d]+="" NS[\d]+:/g,""));c=c.replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g,"<$1 $2>");a.file(b,c)}})}function r(a,b,d){var c=a.createElement(b);d&&(d.attr&&f(c).attr(d.attr),d.children&&f.each(d.children,function(a,b){c.appendChild(b)}),null!==d.text&&d.text!==w&&c.appendChild(a.createTextNode(d.text))); +return c}function L(a,b){var d=a.header[b].length;a.footer&&a.footer[b].length>d&&(d=a.footer[b].length);for(var c=0,f=a.body.length;cd&&(d=e);if(401*a[1]?!0:!1};try{var C=new XMLSerializer,y}catch(a){}var F={"_rels/.rels":'', +"xl/_rels/workbook.xml.rels":'',"[Content_Types].xml":'', +"xl/workbook.xml":'', +"xl/worksheets/sheet1.xml":'',"xl/styles.xml":''}, +K=[{match:/^\-?\d+\.\d%$/,style:60,fmt:function(a){return a/100}},{match:/^\-?\d+\.?\d*%$/,style:56,fmt:function(a){return a/100}},{match:/^\-?\$[\d,]+.?\d*$/,style:57},{match:/^\-?£[\d,]+.?\d*$/,style:58},{match:/^\-?€[\d,]+.?\d*$/,style:59},{match:/^\-?\d+$/,style:65},{match:/^\-?\d+\.\d{2}$/,style:66},{match:/^\([\d,]+\)$/,style:61,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\([\d,]+\.\d{2}\)$/,style:62,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\-?[\d,]+$/,style:63}, +{match:/^\-?[\d,]+\.\d{2}$/,style:64}];v.ext.buttons.copyHtml5={className:"buttons-copy buttons-html5",text:function(a){return a.i18n("buttons.copy","Copy")},action:function(a,b,d,c){this.processing(!0);var g=this;a=I(b,c);var e=b.buttons.exportInfo(c),h=H(c),m=a.str;d=f("
").css({height:1,width:1,overflow:"hidden",position:"fixed",top:0,left:0});e.title&&(m=e.title+h+h+m);e.messageTop&&(m=e.messageTop+h+h+m);e.messageBottom&&(m=m+h+h+e.messageBottom);c.customize&&(m=c.customize(m,c,b));c=f("