diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index cd64659b78..cc0f3850df 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.730-190103 +Version: 7.0NG.730-190115 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 53f9b46a33..861f6db6e6 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.730-190103" +pandora_version="7.0NG.730-190115" 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 78b5d339e3..94995fcac4 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.730'; -use constant AGENT_BUILD => '190103'; +use constant AGENT_BUILD => '190115'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -516,11 +516,18 @@ sub parse_conf_modules($) { log_message ('setup', "Invalid regular expression in intensive condition: $line"); } } - } elsif ($line =~ /^\s*module_crontab\s+(((\*|(\d+(-\d+){0,1}))\s*){5}).*$/) { + } elsif ($line =~ /^\s*module_crontab\s+(.*)$/) { my $cron_text = $1; chomp ($cron_text); + $cron_text =~ s/\s+$//; + # Get module name if is already read. + my $module_name_message = ""; + $module_name_message = " (module $module->{'name'})" if defined($module->{'name'}); if (cron_check_syntax($cron_text)) { $module->{'cron'} = $cron_text; + log_message('debug', "Cron '$module->{'cron'}' configured $module_name_message."); + } else { + log_message('setup', "Incorrect cron syntax '$cron_text'. This module$module_name_message will be executed always."); } } elsif ($line =~ /^\s*module_end\s*$/) { @@ -2397,6 +2404,7 @@ sub check_module_cron { $interval ); + my $is_first = ($module->{'cron_utimestamp'} == 0) ? 1 : 0; $module->{'cron_utimestamp'} = $now + $time_to_next_execution; $module->{'cron_interval'} = $time_to_next_execution; @@ -2405,7 +2413,7 @@ sub check_module_cron { } # On first execution checking if cron is valid is required - return 1 unless ($module->{'cron_utimestamp'} == 0); + return 1 unless ($is_first); # Check if current timestamp is a valid cron date my $next_execution = cron_next_execution_date( diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 63d3ad8b3e..aa2d6205b4 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.730 -%define release 190103 +%define release 190115 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 f60aa04f98..86c141d0cb 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.730 -%define release 190103 +%define release 190115 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 7913f8ecd0..8d554c6ec7 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.730" -PI_BUILD="190103" +PI_BUILD="190115" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b05ce6e00c..afcb597e6d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190103} +{190115} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f704e12589..0d53efcb89 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.730(Build 190103)") +#define PANDORA_VERSION ("7.0NG.730(Build 190115)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 79a84d87b5..c8c4cee86b 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.730(Build 190103))" + VALUE "ProductVersion", "(7.0NG.730(Build 190115))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 3e706a613e..a0cf1e6211 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.730-190103 +Version: 7.0NG.730-190115 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 ef43c7814c..9da4a3959e 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.730-190103" +pandora_version="7.0NG.730-190115" package_pear=0 package_pandora=1 diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index 97ffe031a9..c7d21fff1a 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -14,6 +14,15 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +// Enable profiler for testing +if (!defined("__PAN_XHPROF__")) define ("__PAN_XHPROF__", 0); + +if (__PAN_XHPROF__ === 1) { + if (function_exists('tideways_xhprof_enable')) { + tideways_xhprof_enable(); + } +} + if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) { exit; } @@ -88,4 +97,8 @@ if (file_exists ($page)) { else { echo '
Sorry! I can\'t find the page '.$page.'!'; } + +if (__PAN_XHPROF__ === 1) { + pandora_xhprof_display_result("ajax", "console"); +} ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 0527bea08d..63b27e3303 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -249,29 +249,33 @@ else { $idModuleType = ''; } - $sql = sprintf ('SELECT id_tipo, descripcion + //Removed web analysis and log4x from select + $sql = sprintf ( + 'SELECT id_tipo, descripcion, nombre FROM ttipo_modulo - WHERE categoria IN (%s) + WHERE categoria IN (%s) AND id_tipo NOT IN (24, 25) ORDER BY descripcion', - implode (',', $categories)); - - $table_simple->data[2][1] = html_print_select_from_sql ($sql, 'id_module_type', - $idModuleType, '', '', '', true, false, false, $disabledBecauseInPolicy, false, false, 100); - - // Store the relation between id and name of the types on a hidden field - $sql = sprintf ('SELECT id_tipo, nombre - FROM ttipo_modulo - WHERE categoria IN (%s) - ORDER BY descripcion', - implode (',', $categories)); + implode (',', $categories) + ); $type_names = db_get_all_rows_sql($sql); $type_names_hash = array(); - foreach ($type_names as $tn) { - $type_names_hash[$tn['id_tipo']] = $tn['nombre']; + $type_description_hash = array(); + if (isset($type_names) && is_array($type_names)) { + foreach ($type_names as $tn) { + $type_names_hash[$tn['id_tipo']] = $tn['nombre']; + $type_description_hash[$tn['id_tipo']] = $tn['descripcion']; + } } + $table_simple->data[2][1] = html_print_select ( + $type_description_hash, 'id_module_type', $idModuleType, + $disabledBecauseInPolicy, '', 0, true, + false, true, '', false, false, false, 100 + ); + + // Store the relation between id and name of the types on a hidden field $table_simple->data[2][1] .= html_print_input_hidden('type_names',base64_encode(io_json_mb_encode($type_names_hash)),true); } @@ -439,7 +443,7 @@ $table_advanced->data[2][1] .= html_print_input_hidden ('moduletype', $moduletyp $table_advanced->data[2][3] = __('Post process').' ' . ui_print_help_icon ('postprocess', true); $table_advanced->data[2][4] = html_print_extended_select_for_post_process('post_process', - $post_process, '', '', '0', false, true, false, true, + $post_process, '', '', '0', false, true, false, false, $disabledBecauseInPolicy); $table_advanced->colspan[2][4] = 3; diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index d32ab3ed48..4458918b1a 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -65,6 +65,8 @@ if (! $id_agente) { $params['selectbox_id'] = 'id_agent_module'; $params['javascript_is_function_select'] = true; $params['metaconsole_enabled'] = false; + $params['use_hidden_input_idagent'] = true; + $params['print_hidden_input_idagent'] = true; $table->data['agent'][1] = ui_print_agent_autocomplete_input($params); } @@ -137,20 +139,18 @@ if (check_acl ($config['id_user'], 0, "LM")) { $table->data[3][1] .= ' ' . __('seconds') . ui_print_help_icon ('action_threshold', true); -if (!isset($step) || $step!=5) { +if (!isset($step)) { echo '
'; html_print_table ($table); } echo '
'; -if (!isset($step) || $step!=5) { +if (!isset($step)) { if($id_cluster){ echo ""; } - - html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"'); html_print_input_hidden ('create_alert', 1); echo '
'; @@ -223,7 +223,7 @@ $(document).ready (function () { $("#value", $value).append (""); } else { - $("#value", $value).append (parseInt(data)); + $("#value", $value).append (data); } $loading.hide (); $value.show (); diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 8462d75b7e..74860bb50f 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -285,7 +285,7 @@ else { $filter = false; } $names = agents_get_modules (array_keys ($agents), - 'DISTINCT(tagente_modulo.nombre)', $filter, false); + 'tagente_modulo.nombre', $filter, false); foreach ($names as $name) { $modules[$name['nombre']] = $name['nombre']; } diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index f09d495c0a..35d5bd1abc 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -51,31 +51,27 @@ if ($update) { $agents_ = array(); $force = get_parameter('force_type', false); - + if ($agents_select == false) { $agents_select = array(); } - - foreach ($agents_select as $agent_name) { - $agents_[] = agents_get_agent_id($agent_name); - } + $agents_ = $agents_select; $modules_ = $module_name; - } else if ($selection_mode == 'agents') { $force = get_parameter('force_group', false); - + $agents_ = $agents_id; $modules_ = $modules_select; } - + $success = 0; $count = 0; - + if ($agents_ == false) $agents_ = array(); - + // If the option to select all of one group or module type is checked if ($force) { if ($force == 'type') { diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 229c5ab56f..ed503f0eae 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -119,7 +119,9 @@ if ($schedule_report != '') { $time = date(TIME_FORMAT); $parameters[0] = get_parameter('id_schedule_report'); //$parameters[1] = db_get_value('schedule_email', 'treport', 'id_report', $id_report); - $parameters[1] = get_parameter('schedule_email'); + $parameters[1] = get_parameter('schedule_email_address'); + $parameters[2] = get_parameter('schedule_subject', ''); + $parameters[3] = get_parameter('schedule_email', ''); $parameters['first_execution'] = strtotime ($date.' '.$time); $values = array( diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index afdd2fc759..4138b048f6 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -193,25 +193,49 @@ if ($dialogue_event_response) { $event_id = get_parameter ('event_id'); $response_id = get_parameter ('response_id'); $command = get_parameter ('target'); - + $massive = get_parameter ('massive'); + $end = get_parameter ('end'); + $show_execute_again_btn = get_parameter ('show_execute_again_btn'); + $out_iterator = get_parameter ('out_iterator'); $event_response = db_get_row('tevent_response','id',$response_id); $event = db_get_row('tevento','id_evento',$event_id); $prompt = "
> "; - switch($event_response['type']) { case 'command': - echo "
"; - echo $prompt.sprintf(__('Executing command: %s',$command)); - echo "

"; + - echo ""; - echo "
"; - - echo "
"; + if ($massive) { + echo "
"; + echo $prompt.sprintf("(Event #$event_id) ".__('Executing command: %s',$command)); + echo "

"; + + echo ""; + echo "
"; + + if ($end) { + + echo "
"; + } + } + else { + + echo "
"; + echo $prompt.sprintf(__('Executing command: %s',$command)); + echo "

"; + + echo ""; + echo "
"; + + echo "
"; + } + break; case 'url': $command = str_replace("localhost",$_SERVER['SERVER_NAME'],$command); diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index ffd618fb65..3b73fd7f37 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -269,32 +269,8 @@ function process_user_login_remote ($login, $pass, $api = false) { else { delete_user_pass_ldap ($login); } - - $permissions = array(); - if($config['ldap_advanced_config']){ - $i = 0; - - $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); - foreach ($ldap_adv_perms as $ldap_adv_perm) { - $attributes = $ldap_adv_perm['groups_ldap']; - - foreach ($attributes as $attr) { - $attr = explode('=', $attr, 2); - foreach ($sr[$attr[0]] as $s_attr) { - if(preg_match('/' . $attr[1] . '/', $s_attr)){ - $permissions[$i]["profile"] = $ldap_adv_perm['profile']; - $permissions[$i]["groups"] = $ldap_adv_perm['group']; - $permissions[$i]["tags"] = implode(",",$ldap_adv_perm['tags']); - $i++; - } - } - } - } - } else { - $permissions[0]["profile"] = $config['default_remote_profile']; - $permissions[0]["groups"][] = $config['default_remote_group']; - $permissions[0]["tags"] = $config['default_assign_tags']; - } + + $permissions = fill_permissions_ldap($sr); if(empty($permissions)) { $config["auth_error"] = __("User not found in database or incorrect password"); return false; @@ -388,33 +364,7 @@ function process_user_login_remote ($login, $pass, $api = false) { } } - $permissions = array(); - if($config['ldap_advanced_config']){ - $i = 0; - - $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); - - foreach ($ldap_adv_perms as $ldap_adv_perm) { - $attributes = $ldap_adv_perm['groups_ldap']; - - foreach ($attributes as $attr) { - $attr = explode('=', $attr, 2); - foreach ($sr[$attr[0]] as $s_attr) { - if(preg_match('/' . $attr[1] . '/', $s_attr)){ - $permissions[$i]["profile"] = $ldap_adv_perm['profile']; - $permissions[$i]["groups"] = $ldap_adv_perm['group']; - $permissions[$i]["tags"] = implode(",",$ldap_adv_perm['tags']); - $i++; - } - } - } - } - } else { - $permissions[0]["profile"] = $config['default_remote_profile']; - $permissions[0]["groups"][] = $config['default_remote_group']; - $permissions[0]["tags"] = $config['default_assign_tags']; - } - + $permissions = fill_permissions_ldap($sr); if(empty($permissions)) { $config["auth_error"] = __("User not found in database or incorrect password"); return false; @@ -904,10 +854,11 @@ function create_user_and_permisions_ldap ($id_user, $password, $user_info, $id_profile = $permission["profile"]; $id_groups = $permission["groups"]; $tags = $permission["tags"]; + $no_hierarchy = (bool)$permission["no_hierarchy"] ? 1 : 0; foreach ($id_groups as $id_group) { $profile = profile_create_user_profile( - $id_user, $id_profile, $id_group, false, $tags); + $id_user, $id_profile, $id_group, false, $tags, $no_hierarchy); } if ( defined("METACONSOLE") && $syncronize ) { @@ -934,7 +885,7 @@ function create_user_and_permisions_ldap ($id_user, $password, $user_info, db_process_sql_insert ("tusuario", $values); foreach ($id_groups as $id_group) { $profile = profile_create_user_profile ($id_user, - $id_profile, $id_group, false, $tags); + $id_profile, $id_group, false, $tags, $no_hierarchy); } } @@ -1141,6 +1092,46 @@ function check_permission_ldap ($id_user, $password, $user_info, } } +/** + * Fill permissions array with setup values + * + * @param string sr return value from LDAP connection + * + * @return array with all permission on LDAP authentication + */ +function fill_permissions_ldap ($sr) { + global $config; + + $permissions = array(); + if(!$config['ldap_advanced_config']){ + $permissions[0]["profile"] = $config['default_remote_profile']; + $permissions[0]["groups"][] = $config['default_remote_group']; + $permissions[0]["tags"] = $config['default_assign_tags']; + $permissions[0]["no_hierarchy"] = $config['default_no_hierarchy']; + return $permissions; + } + + // Decode permissions in advanced mode + $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); + foreach ($ldap_adv_perms as $ldap_adv_perm) { + $attributes = $ldap_adv_perm['groups_ldap']; + foreach ($attributes as $attr) { + $attr = explode('=', $attr, 2); + foreach ($sr[$attr[0]] as $s_attr) { + if(preg_match('/' . $attr[1] . '/', $s_attr)){ + $permissions[] = array( + "profile" => $ldap_adv_perm['profile'], + "groups" => $ldap_adv_perm['group'], + "tags" => implode(",",$ldap_adv_perm['tags']), + "no_hierarchy" => (bool)$ldap_adv_perm['no_hierarchy'] ? 1 : 0 + ); + } + } + } + } + return $permissions; +} + /** * Update local user pass from ldap user * diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 5101d1045a..18f1ba08b3 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190103'; +$build_version = 'PC190115'; $pandora_version = 'v7.0NG.730'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 1e43ae46fd..f2056f058e 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3400,5 +3400,39 @@ function validate_csrf_code() { function generate_hash_to_api(){ hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key')); +} + +/** + * Disable the profiller and display de result + * + * @param string Key to identify the profiler run. + * @param string Way to display the result + * "link" (default): Click into word "Performance" to display the profilling info. + * "console": Display with a message in pandora_console.log. + */ +function pandora_xhprof_display_result($key = "", $method = "link") { + // Check if function exists + if (!function_exists('tideways_xhprof_disable')) { + error_log("Cannot find tideways_xhprof_disable function"); + return; } + + $run_id = uniqid(); + $data = tideways_xhprof_disable(); + $source = "pandora_$key"; + file_put_contents( + sys_get_temp_dir() . "/" . $run_id . ".$source.xhprof", + serialize($data) + ); + $new_url = "http://{$_SERVER['HTTP_HOST']}/profiler/index.php?run={$run_id}&source={$source}"; + switch($method) { + case "console": + error_log("'{$new_url}'"); + case "link": + default: + echo "Performance\n"; + break; + + } +} ?> diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 7b4592171b..b1d258e223 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1233,8 +1233,8 @@ function agents_get_modules ($id_agent = null, $details = false, ON tagente.id_agente = tasg.id_agent WHERE tagente_modulo.delete_pending = 0 AND %s - GROUP BY tagente_modulo.id_agente_modulo - ORDER BY tagente_modulo.nombre', + GROUP BY 1 + ORDER BY 1', ($details != 'tagente_modulo.*' && $indexed) ? 'tagente_modulo.id_agente_modulo,' : '', io_safe_output(implode (",", (array) $details)), $sql_tags_join, diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 53479ae7ed..8695ad9b1d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -32,6 +32,7 @@ include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); include_once($config['homedir'] . "/include/functions_db.php"); include_once($config['homedir'] . "/include/functions_event_responses.php"); +include_once($config['homedir'] . "/include/functions_policies.php"); enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_agents.php'); @@ -6448,6 +6449,63 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { array('type' => 'string', 'data' => __('SNMP policy module updated.'))); } +/** + * Remove an agent from a policy. + * @param $id Id of the policy + * @param $id2 Id of the agent policy + * @param $trash1 + * @param $trash2 + * + * Example: + * api.php?op=set&op2=remove_agent_from_policy&apipass=1234&user=admin&pass=pandora&id=11&id2=2 + */ +function api_set_remove_agent_from_policy ($id, $id2, $thrash2, $thrash3) { + global $config; + + if (!check_acl($config['id_user'], 0, "AW")){ + returnError('forbidden', 'string'); + return; + } + + if ($id == '' || !$id) { + returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.')); + return; + } + + if ($id2 == '' || !$id2) { + returnError('error_parameter', __('Error deleting agent from policy. Agent cannot be left blank.')); + return; + } + + $policy = policies_get_policy ($id, false, false); + $agent = db_get_row_filter('tagente', array('id_agente' => $id2)); + $policy_agent = db_get_row_filter('tpolicy_agents', array('id_policy' => $id ,'id_agent' => $id2)); + + if (empty ($policy)){ + returnError('error_policy', __('This policy does not exist.')); + return; + } + if (empty ($agent)){ + returnError('error_agent', __('This agent does not exist.')); + return; + } + if (empty ($policy_agent)){ + returnError('error_policy_agent', __('This agent does not exist in this policy.')); + return; + } + + $return = policies_change_delete_pending_agent($policy_agent['id']); + $data = __('Successfully added to delete pending id agent %d to id policy %d.', $id2, $id); + + if ($return === false) + returnError('error_delete_policy_agent', 'Could not be deleted id agent %d from id policy %d', $id2, $id); + else + returnData('string', array('type' => 'string', 'data' => $data)); + + +} + + /** * Create a new group. And return the id_group of the new group. * @@ -9716,6 +9774,11 @@ function api_set_create_event($id, $trash1, $other, $returnType) { return; } $values['id_grupo'] = $other['data'][1]; + + if (groups_get_name($values['id_grupo']) === false) { + returnError('error_parameter', 'Group ID does not exist'); + return; + } } else { returnError('error_parameter', 'Group ID required.'); @@ -10059,7 +10122,7 @@ function api_get_netflow_get_summary ($discard_1, $discard_2, $params) { } //http://localhost/pandora_console/include/api.php?op=set&op2=validate_event_by_id&id=23&apipass=1234&user=admin&pass=pandora -function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) { +function api_set_validate_event_by_id ($id, $trash1 = null, $trash2 = null, $returnType = 'string') { global $config; $data['type'] = 'string'; $check_id = db_get_value('id_evento', 'tevento', 'id_evento', $id); @@ -10078,7 +10141,7 @@ function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) { 'ack_utimestamp' => $ack_utimestamp, 'estado' => 1 ); - + $result = db_process_sql_update('tevento', $values, array('id_evento' => $id)); if ($result === false) { diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index bd0c78bd76..17f6d9b345 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -312,6 +312,8 @@ function config_update_config () { $error_update[] = __('Autocreate profile group'); if (!config_update_value ('default_assign_tags', implode(",",get_parameter ('default_assign_tags')))) $error_update[] = __('Autocreate profile tags'); + if (!config_update_value ('default_no_hierarchy', (int)get_parameter ('default_no_hierarchy'))) + $error_update[] = __('Automatically assigned no hierarchy'); if (!config_update_value ('autocreate_blacklist', get_parameter ('autocreate_blacklist'))) $error_update[] = __('Autocreate blacklist'); @@ -1452,7 +1454,10 @@ function config_process_config () { if (!isset ($config['default_assign_tags'])) { config_update_value ( 'default_assign_tags', ''); } - + if (!isset ($config['default_no_hierarchy'])) { + config_update_value ('default_no_hierarchy', 0); + } + if (!isset ($config['ldap_server'])) { config_update_value ( 'ldap_server', 'localhost'); } diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index e9b7ca7c1d..55256313b2 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -68,6 +68,7 @@ function groupview_get_modules_counters($groups_ids = false) { ta.id_grupo AS g FROM $table ta WHERE ta.id_grupo IN ($groups_ids) + AND ta.disabled = 0 GROUP BY ta.id_grupo UNION ALL SELECT SUM(ta.normal_count) AS module_normal, diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 16e222ca5c..06257a5457 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -735,8 +735,11 @@ function html_print_extended_select_for_post_process($name, $selected = '', $selected_float = (float)$selected; $found = false; - if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) - $found = true; + if($selected){ + if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) { + $found = true; + } + } if (!$found) { $fields[$selected] = floatval($selected); @@ -1017,7 +1020,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle ++$idcounter; $valid_attrs = array ("accept", "disabled", "maxlength", - "name", "readonly", "size", "value", "accesskey", + "name", "readonly", "placeholder", "size", "value", "accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang", "onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index 01d876697d..292d2892a7 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -79,14 +79,10 @@ function profile_create_user_profile ($id_user, $tags = '', $no_hierarchy = false ) { - global $config; if (empty ($id_profile) || $id_group < 0) - return false; - - // Secondary server is an enterprise function - if (!enterprise_installed() && $no_hierarchy) return false; + return false; // Checks if the user exists $result_user = users_get_user_by_id($id_user); diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 72a222becd..a4be0d445e 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -278,6 +278,11 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = )); $salida = ui_get_snapshot_image($link, $is_snapshot) . '  '; } + + if($salida !== NULL){ + $last_data_str = html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px')); + } + $last_data_str .= $salida; } else { diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 7067e1d560..e69fb155e0 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -362,10 +362,11 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, tickFormatter: xFormatter, }, yaxis: { - color: tick_color, - axisLabelUseCanvas: true, - axisLabelFontSizePixels: font_size, - axisLabelFontFamily: font+'Font', + font: { + size: font_size + 2, + color: 'rgb(84, 84, 84)', + family: font+'Font' + }, ticks: yFormatter, }, legend: { @@ -417,7 +418,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, div_attributes += "min-height: 2.5em;"; } - div_attributes += '" title="'+title+'" class="'+font+'" '+ ' style="overflow: hidden;"'; + div_attributes += '" title="'+title+'" style="overflow: hidden;"'; format.push([i,'
' + label diff --git a/pandora_console/include/help/en/help_plugin_macros.php b/pandora_console/include/help/en/help_plugin_macros.php index 1660c45e13..6d1e508b21 100644 --- a/pandora_console/include/help/en/help_plugin_macros.php +++ b/pandora_console/include/help/en/help_plugin_macros.php @@ -31,10 +31,10 @@ Hidden this macros because they cannot edit in the module form -->
  • _plugin_parameters_ : Plug-in Parameters of the module.
  • -
  • _name_tag_ : Nombre de los tags asociados al módulo.
  • -
  • _email_tag_ : Emails asociados a los tags de módulos.
  • -
  • _phone_tag_ : Teléfonos asociados a los tags de módulos.
  • -
  • _moduletags_ : Teléfonos asociados a los tags de módulos.
  • +
  • _name_tag_ : Names of the tags associated to the module.
  • +
  • _email_tag_ : Emails associated to module tags.
  • +
  • _phone_tag_ : Phone numbers associated to module tags.
  • +
  • _moduletags_ : URLs associated to module tags.
  • _agentcustomfield_n_: Agent custom field number n (eg. _agentcustomfield_9_).
  • diff --git a/pandora_console/include/help/es/help_plugin_macros.php b/pandora_console/include/help/es/help_plugin_macros.php index 701d15f35e..77c97aa4d7 100644 --- a/pandora_console/include/help/es/help_plugin_macros.php +++ b/pandora_console/include/help/es/help_plugin_macros.php @@ -30,9 +30,9 @@ Hidden this macros because they cannot edit in the module form -->

  • _plugin_parameters_ : Parámetros del Plug-in del módulo.
  • -
  • _name_tag_ : Names of the tags associated to the module.
  • -
  • _email_tag_ : Emails associated to the module tags.
  • -
  • _phone_tag_ : Phone numbers associated to the module tags.
  • -
  • _moduletags_ : URLs associated to the module tags.
  • +
  • _name_tag_ : Nombre de los tags asociados al módulo.
  • +
  • _email_tag_ : Emails asociados a los tags de módulos.
  • +
  • _phone_tag_ : Teléfonos asociados a los tags de módulos.
  • +
  • _moduletags_ : URLs asociadas a los tags de módulos.
  • _agentcustomfield_n_: Campo personalizado número n del agente (eg. _agentcustomfield_9_).
  • diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 2b323a55f1..1ca0759801 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -594,12 +594,51 @@ function post_process_select_init_unit(name,selected) { function post_process_select_events_unit(name,selected) { $('.' + name + '_toggler').click(function() { - $('#' + name + '_select option[value=none]').attr("selected",true); - $('#text-' + name + '_text').val(""); + var value = $('#text-' + name + '_text').val(); + + var count = $('#' + name + '_select option') + .filter(function(i, item) { + + if ($(item).val() == value) + return true; + else return false; + }) + .length; + + if (count != 1) { + $('#' + name + '_select') + .append($("