Merge remote-tracking branch 'origin/develop' into ent-3328-7200-correcciones-consola-vmware

Former-commit-id: b09a410d415480efd4bcf6c387347e2e582febeb
This commit is contained in:
fbsanchez 2019-01-15 18:22:27 +01:00
commit a84db4d88f
51 changed files with 693 additions and 232 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.730-190103 Version: 7.0NG.730-190115
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # 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." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.730'; 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 # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; 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"); 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; my $cron_text = $1;
chomp ($cron_text); 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)) { if (cron_check_syntax($cron_text)) {
$module->{'cron'} = $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*$/) { } elsif ($line =~ /^\s*module_end\s*$/) {
@ -2397,6 +2404,7 @@ sub check_module_cron {
$interval $interval
); );
my $is_first = ($module->{'cron_utimestamp'} == 0) ? 1 : 0;
$module->{'cron_utimestamp'} = $now + $time_to_next_execution; $module->{'cron_utimestamp'} = $now + $time_to_next_execution;
$module->{'cron_interval'} = $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 # 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 # Check if current timestamp is a valid cron date
my $next_execution = cron_next_execution_date( my $next_execution = cron_next_execution_date(

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.730 %define version 7.0NG.730
%define release 190103 %define release 190115
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.730 %define version 7.0NG.730
%define release 190103 %define release 190115
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.730" PI_VERSION="7.0NG.730"
PI_BUILD="190103" PI_BUILD="190115"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190103} {190115}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #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_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" 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" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.730-190103 Version: 7.0NG.730-190115
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.730-190103" pandora_version="7.0NG.730-190115"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -14,6 +14,15 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // 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"))) { if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) {
exit; exit;
} }
@ -88,4 +97,8 @@ if (file_exists ($page)) {
else { else {
echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>'; echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>';
} }
if (__PAN_XHPROF__ === 1) {
pandora_xhprof_display_result("ajax", "console");
}
?> ?>

View File

@ -249,29 +249,33 @@ else {
$idModuleType = ''; $idModuleType = '';
} }
$sql = sprintf ('SELECT id_tipo, descripcion //Removed web analysis and log4x from select
$sql = sprintf (
'SELECT id_tipo, descripcion, nombre
FROM ttipo_modulo FROM ttipo_modulo
WHERE categoria IN (%s) WHERE categoria IN (%s) AND id_tipo NOT IN (24, 25)
ORDER BY descripcion', ORDER BY descripcion',
implode (',', $categories)); 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));
$type_names = db_get_all_rows_sql($sql); $type_names = db_get_all_rows_sql($sql);
$type_names_hash = array(); $type_names_hash = array();
foreach ($type_names as $tn) { $type_description_hash = array();
$type_names_hash[$tn['id_tipo']] = $tn['nombre']; 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); $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][3] = __('Post process').' ' . ui_print_help_icon ('postprocess', true);
$table_advanced->data[2][4] = $table_advanced->data[2][4] =
html_print_extended_select_for_post_process('post_process', html_print_extended_select_for_post_process('post_process',
$post_process, '', '', '0', false, true, false, true, $post_process, '', '', '0', false, true, false, false,
$disabledBecauseInPolicy); $disabledBecauseInPolicy);
$table_advanced->colspan[2][4] = 3; $table_advanced->colspan[2][4] = 3;

View File

@ -65,6 +65,8 @@ if (! $id_agente) {
$params['selectbox_id'] = 'id_agent_module'; $params['selectbox_id'] = 'id_agent_module';
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
$params['metaconsole_enabled'] = false; $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); $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); $table->data[3][1] .= ' ' . __('seconds') . ui_print_help_icon ('action_threshold', true);
if (!isset($step) || $step!=5) { if (!isset($step)) {
echo '<form class="add_alert_form" method="post">'; echo '<form class="add_alert_form" method="post">';
html_print_table ($table); html_print_table ($table);
} }
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
if (!isset($step) || $step!=5) { if (!isset($step)) {
if($id_cluster){ if($id_cluster){
echo "<input onclick='window.location.replace(\"index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id=".$id_cluster."\");' type=button style='float:right;margin-left:20px;' name='store' class='sub upd' value='".__('Finish and view cluster')."'>"; echo "<input onclick='window.location.replace(\"index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id=".$id_cluster."\");' type=button style='float:right;margin-left:20px;' name='store' class='sub upd' value='".__('Finish and view cluster')."'>";
} }
html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"'); html_print_submit_button (__('Add alert'), 'add', false, 'class="sub wand"');
html_print_input_hidden ('create_alert', 1); html_print_input_hidden ('create_alert', 1);
echo '</div></form>'; echo '</div></form>';
@ -223,7 +223,7 @@ $(document).ready (function () {
$("#value", $value).append ("<em><?php echo __('Empty') ?></em>"); $("#value", $value).append ("<em><?php echo __('Empty') ?></em>");
} }
else { else {
$("#value", $value).append (parseInt(data)); $("#value", $value).append (data);
} }
$loading.hide (); $loading.hide ();
$value.show (); $value.show ();

View File

@ -285,7 +285,7 @@ else {
$filter = false; $filter = false;
} }
$names = agents_get_modules (array_keys ($agents), $names = agents_get_modules (array_keys ($agents),
'DISTINCT(tagente_modulo.nombre)', $filter, false); 'tagente_modulo.nombre', $filter, false);
foreach ($names as $name) { foreach ($names as $name) {
$modules[$name['nombre']] = $name['nombre']; $modules[$name['nombre']] = $name['nombre'];
} }

View File

@ -51,31 +51,27 @@ if ($update) {
$agents_ = array(); $agents_ = array();
$force = get_parameter('force_type', false); $force = get_parameter('force_type', false);
if ($agents_select == false) { if ($agents_select == false) {
$agents_select = array(); $agents_select = array();
} }
foreach ($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id($agent_name);
}
$agents_ = $agents_select;
$modules_ = $module_name; $modules_ = $module_name;
} }
else if ($selection_mode == 'agents') { else if ($selection_mode == 'agents') {
$force = get_parameter('force_group', false); $force = get_parameter('force_group', false);
$agents_ = $agents_id; $agents_ = $agents_id;
$modules_ = $modules_select; $modules_ = $modules_select;
} }
$success = 0; $success = 0;
$count = 0; $count = 0;
if ($agents_ == false) if ($agents_ == false)
$agents_ = array(); $agents_ = array();
// If the option to select all of one group or module type is checked // If the option to select all of one group or module type is checked
if ($force) { if ($force) {
if ($force == 'type') { if ($force == 'type') {

View File

@ -119,7 +119,9 @@ if ($schedule_report != '') {
$time = date(TIME_FORMAT); $time = date(TIME_FORMAT);
$parameters[0] = get_parameter('id_schedule_report'); $parameters[0] = get_parameter('id_schedule_report');
//$parameters[1] = db_get_value('schedule_email', 'treport', 'id_report', $id_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); $parameters['first_execution'] = strtotime ($date.' '.$time);
$values = array( $values = array(

View File

@ -193,25 +193,49 @@ if ($dialogue_event_response) {
$event_id = get_parameter ('event_id'); $event_id = get_parameter ('event_id');
$response_id = get_parameter ('response_id'); $response_id = get_parameter ('response_id');
$command = get_parameter ('target'); $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_response = db_get_row('tevent_response','id',$response_id);
$event = db_get_row('tevento','id_evento',$event_id); $event = db_get_row('tevento','id_evento',$event_id);
$prompt = "<br>> "; $prompt = "<br>> ";
switch($event_response['type']) { switch($event_response['type']) {
case 'command': case 'command':
echo "<div style='text-align:left'>";
echo $prompt.sprintf(__('Executing command: %s',$command));
echo "</div><br>";
echo "<div id='response_loading_command' style='display:none'>".html_print_image('images/spinner.gif', true)."</div>"; if ($massive) {
echo "<br><div id='response_out' style='text-align:left'></div>"; echo "<div style='text-align:left'>";
echo $prompt.sprintf("(Event #$event_id) ".__('Executing command: %s',$command));
echo "<br><div id='re_exec_command' style='display:none;'>"; echo "</div><br>";
html_print_button(__('Execute again'),'btn_str',false,'perform_response(\''.$command.'\', ' . $response_id . ');', "class='sub next'");
echo "</div>"; echo "<div id='response_loading_command_".$out_iterator."' style='display:none'>".html_print_image('images/spinner.gif', true)."</div>";
echo "<br><div id='response_out_".$out_iterator."' style='text-align:left'></div>";
if ($end) {
echo "<br><div id='re_exec_command_".$out_iterator."' style='display:none;'>";
html_print_button(__('Execute again'),'btn_str',false,'execute_event_response(false);', "class='sub next'");
echo "<span id='execute_again_loading' style='display:none'>".html_print_image('images/spinner.gif', true)."</span>";
echo "</div>";
}
}
else {
echo "<div style='text-align:left'>";
echo $prompt.sprintf(__('Executing command: %s',$command));
echo "</div><br>";
echo "<div id='response_loading_command' style='display:none'>".html_print_image('images/spinner.gif', true)."</div>";
echo "<br><div id='response_out' style='text-align:left'></div>";
echo "<br><div id='re_exec_command' style='display:none;'>";
html_print_button(__('Execute again'),'btn_str',false,'perform_response(\''.$command.'\', ' . $response_id . ');', "class='sub next'");
echo "</div>";
}
break; break;
case 'url': case 'url':
$command = str_replace("localhost",$_SERVER['SERVER_NAME'],$command); $command = str_replace("localhost",$_SERVER['SERVER_NAME'],$command);

View File

@ -269,32 +269,8 @@ function process_user_login_remote ($login, $pass, $api = false) {
else { else {
delete_user_pass_ldap ($login); delete_user_pass_ldap ($login);
} }
$permissions = array(); $permissions = fill_permissions_ldap($sr);
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'];
}
if(empty($permissions)) { if(empty($permissions)) {
$config["auth_error"] = __("User not found in database or incorrect password"); $config["auth_error"] = __("User not found in database or incorrect password");
return false; return false;
@ -388,33 +364,7 @@ function process_user_login_remote ($login, $pass, $api = false) {
} }
} }
$permissions = array(); $permissions = fill_permissions_ldap($sr);
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'];
}
if(empty($permissions)) { if(empty($permissions)) {
$config["auth_error"] = __("User not found in database or incorrect password"); $config["auth_error"] = __("User not found in database or incorrect password");
return false; return false;
@ -904,10 +854,11 @@ function create_user_and_permisions_ldap ($id_user, $password, $user_info,
$id_profile = $permission["profile"]; $id_profile = $permission["profile"];
$id_groups = $permission["groups"]; $id_groups = $permission["groups"];
$tags = $permission["tags"]; $tags = $permission["tags"];
$no_hierarchy = (bool)$permission["no_hierarchy"] ? 1 : 0;
foreach ($id_groups as $id_group) { foreach ($id_groups as $id_group) {
$profile = profile_create_user_profile( $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 ) { 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); db_process_sql_insert ("tusuario", $values);
foreach ($id_groups as $id_group) { foreach ($id_groups as $id_group) {
$profile = profile_create_user_profile ($id_user, $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 * Update local user pass from ldap user
* *

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC190103'; $build_version = 'PC190115';
$pandora_version = 'v7.0NG.730'; $pandora_version = 'v7.0NG.730';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -3400,5 +3400,39 @@ function validate_csrf_code() {
function generate_hash_to_api(){ function generate_hash_to_api(){
hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key')); 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 "<a href='{$new_url}' target='_new'>Performance</a>\n";
break;
}
}
?> ?>

View File

@ -1233,8 +1233,8 @@ function agents_get_modules ($id_agent = null, $details = false,
ON tagente.id_agente = tasg.id_agent ON tagente.id_agente = tasg.id_agent
WHERE tagente_modulo.delete_pending = 0 WHERE tagente_modulo.delete_pending = 0
AND %s AND %s
GROUP BY tagente_modulo.id_agente_modulo GROUP BY 1
ORDER BY tagente_modulo.nombre', ORDER BY 1',
($details != 'tagente_modulo.*' && $indexed) ? 'tagente_modulo.id_agente_modulo,' : '', ($details != 'tagente_modulo.*' && $indexed) ? 'tagente_modulo.id_agente_modulo,' : '',
io_safe_output(implode (",", (array) $details)), io_safe_output(implode (",", (array) $details)),
$sql_tags_join, $sql_tags_join,

View File

@ -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_planned_downtimes.php");
include_once($config['homedir'] . "/include/functions_db.php"); include_once($config['homedir'] . "/include/functions_db.php");
include_once($config['homedir'] . "/include/functions_event_responses.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_local_components.php');
enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.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.'))); 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. * 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; return;
} }
$values['id_grupo'] = $other['data'][1]; $values['id_grupo'] = $other['data'][1];
if (groups_get_name($values['id_grupo']) === false) {
returnError('error_parameter', 'Group ID does not exist');
return;
}
} }
else { else {
returnError('error_parameter', 'Group ID required.'); 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 //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; global $config;
$data['type'] = 'string'; $data['type'] = 'string';
$check_id = db_get_value('id_evento', 'tevento', 'id_evento', $id); $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, 'ack_utimestamp' => $ack_utimestamp,
'estado' => 1 'estado' => 1
); );
$result = db_process_sql_update('tevento', $values, array('id_evento' => $id)); $result = db_process_sql_update('tevento', $values, array('id_evento' => $id));
if ($result === false) { if ($result === false) {

View File

@ -312,6 +312,8 @@ function config_update_config () {
$error_update[] = __('Autocreate profile group'); $error_update[] = __('Autocreate profile group');
if (!config_update_value ('default_assign_tags', implode(",",get_parameter ('default_assign_tags')))) if (!config_update_value ('default_assign_tags', implode(",",get_parameter ('default_assign_tags'))))
$error_update[] = __('Autocreate profile 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'))) if (!config_update_value ('autocreate_blacklist', get_parameter ('autocreate_blacklist')))
$error_update[] = __('Autocreate blacklist'); $error_update[] = __('Autocreate blacklist');
@ -1452,7 +1454,10 @@ function config_process_config () {
if (!isset ($config['default_assign_tags'])) { if (!isset ($config['default_assign_tags'])) {
config_update_value ( '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'])) { if (!isset ($config['ldap_server'])) {
config_update_value ( 'ldap_server', 'localhost'); config_update_value ( 'ldap_server', 'localhost');
} }

View File

@ -68,6 +68,7 @@ function groupview_get_modules_counters($groups_ids = false) {
ta.id_grupo AS g ta.id_grupo AS g
FROM $table ta FROM $table ta
WHERE ta.id_grupo IN ($groups_ids) WHERE ta.id_grupo IN ($groups_ids)
AND ta.disabled = 0
GROUP BY ta.id_grupo GROUP BY ta.id_grupo
UNION ALL UNION ALL
SELECT SUM(ta.normal_count) AS module_normal, SELECT SUM(ta.normal_count) AS module_normal,

View File

@ -735,8 +735,11 @@ function html_print_extended_select_for_post_process($name, $selected = '',
$selected_float = (float)$selected; $selected_float = (float)$selected;
$found = false; $found = false;
if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) if($selected){
$found = true; if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) {
$found = true;
}
}
if (!$found) { if (!$found) {
$fields[$selected] = floatval($selected); $fields[$selected] = floatval($selected);
@ -1017,7 +1020,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
++$idcounter; ++$idcounter;
$valid_attrs = array ("accept", "disabled", "maxlength", $valid_attrs = array ("accept", "disabled", "maxlength",
"name", "readonly", "size", "value", "accesskey", "name", "readonly", "placeholder", "size", "value", "accesskey",
"class", "dir", "id", "lang", "style", "tabindex", "class", "dir", "id", "lang", "style", "tabindex",
"title", "xml:lang", "onfocus", "onblur", "onselect", "title", "xml:lang", "onfocus", "onblur", "onselect",
"onchange", "onclick", "ondblclick", "onmousedown", "onchange", "onclick", "ondblclick", "onmousedown",

View File

@ -79,14 +79,10 @@ function profile_create_user_profile ($id_user,
$tags = '', $tags = '',
$no_hierarchy = false $no_hierarchy = false
) { ) {
global $config; global $config;
if (empty ($id_profile) || $id_group < 0) if (empty ($id_profile) || $id_group < 0)
return false; return false;
// Secondary server is an enterprise function
if (!enterprise_installed() && $no_hierarchy) return false;
// Checks if the user exists // Checks if the user exists
$result_user = users_get_user_by_id($id_user); $result_user = users_get_user_by_id($id_user);

View File

@ -278,6 +278,11 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
)); ));
$salida = ui_get_snapshot_image($link, $is_snapshot) . '&nbsp;&nbsp;'; $salida = ui_get_snapshot_image($link, $is_snapshot) . '&nbsp;&nbsp;';
} }
if($salida !== NULL){
$last_data_str = html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
}
$last_data_str .= $salida; $last_data_str .= $salida;
} }
else { else {

View File

@ -362,10 +362,11 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
tickFormatter: xFormatter, tickFormatter: xFormatter,
}, },
yaxis: { yaxis: {
color: tick_color, font: {
axisLabelUseCanvas: true, size: font_size + 2,
axisLabelFontSizePixels: font_size, color: 'rgb(84, 84, 84)',
axisLabelFontFamily: font+'Font', family: font+'Font'
},
ticks: yFormatter, ticks: yFormatter,
}, },
legend: { legend: {
@ -417,7 +418,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
div_attributes += "min-height: 2.5em;"; 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,'<div ' + div_attributes + '>' format.push([i,'<div ' + div_attributes + '>'
+ label + label

View File

@ -31,10 +31,10 @@ Hidden this macros because they cannot edit in the module form
--> -->
<li>_plugin_parameters_ : Plug-in Parameters of the module.</li> <li>_plugin_parameters_ : Plug-in Parameters of the module.</li>
<li>_name_tag_ : Nombre de los tags asociados al módulo.</li> <li>_name_tag_ : Names of the tags associated to the module.</li>
<li>_email_tag_ : Emails asociados a los tags de módulos.</li> <li>_email_tag_ : Emails associated to module tags.</li>
<li>_phone_tag_ : Teléfonos asociados a los tags de módulos.</li> <li>_phone_tag_ : Phone numbers associated to module tags.</li>
<li>_moduletags_ : Teléfonos asociados a los tags de módulos.</li> <li>_moduletags_ : URLs associated to module tags.</li>
<li>_agentcustomfield_<i>n</i>_: Agent custom field number <i>n</i> (eg. _agentcustomfield_9_).</li> <li>_agentcustomfield_<i>n</i>_: Agent custom field number <i>n</i> (eg. _agentcustomfield_9_).</li>
</ul> </ul>
<p> <p>

View File

@ -30,9 +30,9 @@ Hidden this macros because they cannot edit in the module form
--> -->
<li>_plugin_parameters_ : Parámetros del Plug-in del módulo.</li> <li>_plugin_parameters_ : Parámetros del Plug-in del módulo.</li>
<li>_name_tag_ : Names of the tags associated to the module.</li> <li>_name_tag_ : Nombre de los tags asociados al módulo.</li>
<li>_email_tag_ : Emails associated to the module tags.</li> <li>_email_tag_ : Emails asociados a los tags de módulos.</li>
<li>_phone_tag_ : Phone numbers associated to the module tags.</li> <li>_phone_tag_ : Teléfonos asociados a los tags de módulos.</li>
<li>_moduletags_ : URLs associated to the module tags.</li> <li>_moduletags_ : URLs asociadas a los tags de módulos.</li>
<li>_agentcustomfield_<i>n</i>_: Campo personalizado número <i>n</i> del agente (eg. _agentcustomfield_9_). </li> <li>_agentcustomfield_<i>n</i>_: Campo personalizado número <i>n</i> del agente (eg. _agentcustomfield_9_). </li>
</ul> </ul>

View File

@ -594,12 +594,51 @@ function post_process_select_init_unit(name,selected) {
function post_process_select_events_unit(name,selected) { function post_process_select_events_unit(name,selected) {
$('.' + name + '_toggler').click(function() { $('.' + name + '_toggler').click(function() {
$('#' + name + '_select option[value=none]').attr("selected",true); var value = $('#text-' + name + '_text').val();
$('#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($("<option>").val(value).text(value));
}
$('#' + name + '_select option')
.filter(function(i, item) {
if ($(item).val() == value)
return true;
else return false;
})
.prop("selected", true);
toggleBoth(name); toggleBoth(name);
$('#text-' + name + '_text').focus();
});
// When select a default period, is setted in seconds
$('#' + name + '_select').change(function() {
var value = $('#' + name + '_select').val();
$('.' + name).val(value);
$('#text-' + name + '_text').val(value);
});
$('#text-' + name + '_text').keyup (function () {
var value = $('#text-' + name + '_text').val();
$('.' + name).val(value);
}); });
} }
function post_process_select_events(name) { function post_process_select_events(name) {
$('.' + name + '_toggler').click(function() { $('.' + name + '_toggler').click(function() {
var value = $('#text-' + name + '_text').val(); var value = $('#text-' + name + '_text').val();

View File

@ -158,10 +158,11 @@ function show_response_dialog(event_id, response_id, response) {
var params = []; var params = [];
params.push("page=include/ajax/events"); params.push("page=include/ajax/events");
params.push("dialogue_event_response=1"); params.push("dialogue_event_response=1");
params.push("massive=0");
params.push("event_id="+event_id); params.push("event_id="+event_id);
params.push("target="+response['target']); params.push("target="+response['target']);
params.push("response_id="+response_id); params.push("response_id="+response_id);
jQuery.ajax ({ jQuery.ajax ({
data: params.join ("&"), data: params.join ("&"),
type: 'POST', type: 'POST',
@ -187,6 +188,57 @@ function show_response_dialog(event_id, response_id, response) {
}); });
} }
//Show the modal window of event responses when multiple events are selected
function show_massive_response_dialog(event_id, response_id, response, out_iterator, end) {
var ajax_file = $('#hidden-ajax_file').val();
var params = [];
params.push("page=include/ajax/events");
params.push("dialogue_event_response=1");
params.push("massive=1");
params.push("end="+end);
params.push("out_iterator="+out_iterator);
params.push("event_id="+event_id);
params.push("target="+response['target']);
params.push("response_id="+response_id);
jQuery.ajax ({
data: params.join ("&"),
response_tg: response['target'],
response_id: response_id,
out_iterator: out_iterator,
type: 'POST',
url: action=ajax_file,
dataType: 'html',
success: function (data) {
if (out_iterator === 0)
$("#event_response_window").empty();
$("#event_response_window").hide ()
.append (data)
.dialog ({
title: $('#select_custom_response option:selected').html(),
resizable: true,
draggable: true,
modal: false,
open: function(event, ui) {
$('#response_loading_dialog').hide();
$('#button-submit_event_response').show();
},
close: function(event, ui) {
$( ".chk_val" ).prop( "checked", false );
},
width: response['modal_width'],
height: response['modal_height']
})
.show ();
perform_response_massive(this.response_tg, this.response_id, this.out_iterator);
}
});
}
// Get an event response from db // Get an event response from db
function get_response(response_id) { function get_response(response_id) {
var ajax_file = $('#hidden-ajax_file').val(); var ajax_file = $('#hidden-ajax_file').val();
@ -371,6 +423,42 @@ function perform_response(target, response_id) {
return false; return false;
} }
// Perform a response and put the output into a div
function perform_response_massive(target, response_id, out_iterator) {
var ajax_file = $('#hidden-ajax_file').val();
$('#re_exec_command').hide();
$('#response_loading_command_'+out_iterator).show();
$('#response_out_'+out_iterator).html('');
var finished = 0;
var time = Math.round(+new Date()/1000);
var timeout = time + 10;
var params = [];
params.push("page=include/ajax/events");
params.push("perform_event_response=1");
params.push("target="+target);
params.push("response_id="+response_id)
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action=ajax_file,
async: true,
timeout: 10000,
dataType: 'html',
success: function (data) {
var out = data.replace(/[\n|\r]/g, "<br>");
$('#response_out_'+out_iterator).html(out);
$('#response_loading_command_'+out_iterator).hide();
$('#re_exec_command_'+out_iterator).show();
}
});
return false;
}
// Change the status of an event to new, in process or validated // Change the status of an event to new, in process or validated
function event_change_status(event_ids) { function event_change_status(event_ids) {
var ajax_file = $('#hidden-ajax_file').val(); var ajax_file = $('#hidden-ajax_file').val();

View File

@ -320,8 +320,23 @@ function configure_modules_form () {
$("#text-ff_event_normal").attr ("value", (data["min_ff_event_normal"] == 0) ? 0 : data["min_ff_event_normal"]); $("#text-ff_event_normal").attr ("value", (data["min_ff_event_normal"] == 0) ? 0 : data["min_ff_event_normal"]);
$("#text-ff_event_warning").attr ("value", (data["min_ff_event_warning"] == 0) ? 0 : data["min_ff_event_warning"]); $("#text-ff_event_warning").attr ("value", (data["min_ff_event_warning"] == 0) ? 0 : data["min_ff_event_warning"]);
$("#text-ff_event_critical").attr ("value", (data["min_ff_event_critical"] == 0) ? 0 : data["min_ff_event_critical"]); $("#text-ff_event_critical").attr ("value", (data["min_ff_event_critical"] == 0) ? 0 : data["min_ff_event_critical"]);
$("#text-post_process").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"]);
$("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"]); // Shows manual input if post_process field is setted
if (data["post_process"] != 0) {
$('#post_process_manual').show();
$('#post_process_default').hide();
}
$("#text-post_process_text").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"]);
// Shows manual input if unit field is setted
if (data["unit"] != '') {
$('#unit_manual').show();
$('#unit_default').hide();
}
$("#text-unit_text").attr("value", (data["unit"] == '') ? '' : data["unit"]);
$("#checkbox-critical_inverse").prop ("checked", data["critical_inverse"]); $("#checkbox-critical_inverse").prop ("checked", data["critical_inverse"]);
$("#checkbox-warning_inverse").prop ("checked", data["warning_inverse"]); $("#checkbox-warning_inverse").prop ("checked", data["warning_inverse"]);
$("#component_loading").hide (); $("#component_loading").hide ();

View File

@ -14,6 +14,17 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // 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();
} else {
error_log("Cannot find tideways_xhprof_enable function");
}
}
//Set character encoding to UTF-8 - fixes a lot of multibyte character headaches //Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
if (function_exists ('mb_internal_encoding')) { if (function_exists ('mb_internal_encoding')) {
mb_internal_encoding ("UTF-8"); mb_internal_encoding ("UTF-8");
@ -1277,3 +1288,8 @@ require('include/php_to_js_values.php');
*/ */
} }
</script> </script>
<?php
if (__PAN_XHPROF__ === 1) {
pandora_xhprof_display_result("node_index");
}
?>

View File

@ -116,7 +116,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.730'; $version = '7.0NG.730';
$build = '190103'; $build = '190115';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -18,6 +18,7 @@ global $config;
require_once ("include/functions_agents.php"); require_once ("include/functions_agents.php");
require_once ("include/functions_custom_graphs.php"); require_once ("include/functions_custom_graphs.php");
ui_require_javascript_file ('calendar');
if (! check_acl ($config['id_user'], $id_grupo, "AR") && ! check_acl ($config['id_user'], 0, "AW")) { if (! check_acl ($config['id_user'], $id_grupo, "AR") && ! check_acl ($config['id_user'], 0, "AW")) {
db_pandora_audit("ACL Violation", db_pandora_audit("ACL Violation",
@ -242,7 +243,7 @@ echo '</div>';
//Dialog to save the custom graph //Dialog to save the custom graph
echo "<div id='dialog_save_custom_graph' style='display: none;'>"; echo "<div id='dialog_save_custom_graph' style='display: none;'>";
$table = null; $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->style[0] = 'font-weight: bolder; text-align: right;'; $table->style[0] = 'font-weight: bolder; text-align: right;';
$table->data[0][0] = __('Name custom graph'); $table->data[0][0] = __('Name custom graph');

View File

@ -552,7 +552,7 @@ if (is_metaconsole()) {
$filters .= html_print_table($table, true); $filters .= html_print_table($table, true);
$filters .= "</form>"; $filters .= "</form>";
ui_toggle($filters, __('Show Options')); ui_toggle($filters, __('Show Options'), '', false);
} }
else { else {
$table->colspan[3][0] = 7; $table->colspan[3][0] = 7;
@ -778,84 +778,89 @@ $sql = 'SELECT
ORDER BY ' . $order['field'] . " " . $order['order'] . ' ORDER BY ' . $order['field'] . " " . $order['order'] . '
LIMIT '.$offset.",".$limit_sql; LIMIT '.$offset.",".$limit_sql;
if (! defined ('METACONSOLE')) { // When you enter for the first time you have less than 4 query params in the url
$result = db_get_all_rows_sql ($sql); $first_interaction = count($_GET) > 4;
// We do not show the modules until the user searches with the filter
if ($result === false) { if ($first_interaction) {
$result = array (); if (! defined ('METACONSOLE')) {
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = array();
} else {
ui_pagination($count, false, $offset);
}
} }
else else {
ui_pagination ($count, false, $offset); // For each server defined and not disabled:
} $servers = db_get_all_rows_sql('SELECT *
else {
// For each server defined and not disabled:
$servers = db_get_all_rows_sql ('SELECT *
FROM tmetaconsole_setup FROM tmetaconsole_setup
WHERE disabled = 0'); WHERE disabled = 0');
if ($servers === false) if ($servers === false)
$servers = array(); $servers = array();
$result = array(); $result = array();
$count_modules = 0; $count_modules = 0;
foreach ($servers as $server) { foreach ($servers as $server) {
// If connection was good then retrieve all data server // If connection was good then retrieve all data server
if (metaconsole_connect($server) == NOERR) if (metaconsole_connect($server) == NOERR)
$connection = true; $connection = true;
else else
$connection = false; $connection = false;
$result_server = db_get_all_rows_sql ($sql); $result_server = db_get_all_rows_sql($sql);
if (!empty($result_server)) { if (!empty($result_server)) {
// Create HASH login info // Create HASH login info
$pwd = $server['auth_token']; $pwd = $server['auth_token'];
$auth_serialized = json_decode($pwd,true); $auth_serialized = json_decode($pwd, true);
if (is_array($auth_serialized)) { if (is_array($auth_serialized)) {
$pwd = $auth_serialized['auth_token']; $pwd = $auth_serialized['auth_token'];
$api_password = $auth_serialized['api_password']; $api_password = $auth_serialized['api_password'];
$console_user = $auth_serialized['console_user']; $console_user = $auth_serialized['console_user'];
$console_password = $auth_serialized['console_password']; $console_password = $auth_serialized['console_password'];
} }
$user = $config['id_user']; $user = $config['id_user'];
$user_rot13 = str_rot13($config['id_user']); $user_rot13 = str_rot13($config['id_user']);
$hashdata = $user.$pwd; $hashdata = $user . $pwd;
$hashdata = md5($hashdata); $hashdata = md5($hashdata);
$url_hash = '&' . $url_hash = '&' .
'loginhash=auto&' . 'loginhash=auto&' .
'loginhash_data=' . $hashdata . '&' . 'loginhash_data=' . $hashdata . '&' .
'loginhash_user=' . $user_rot13; 'loginhash_user=' . $user_rot13;
foreach ($result_server as $result_element_key => $result_element_value) { foreach ($result_server as $result_element_key => $result_element_value) {
$result_server[$result_element_key]['server_id'] = $server['id']; $result_server[$result_element_key]['server_id'] = $server['id'];
$result_server[$result_element_key]['server_name'] = $server['server_name']; $result_server[$result_element_key]['server_name'] = $server['server_name'];
$result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; $result_server[$result_element_key]['server_url'] = $server['server_url'] . '/';
$result_server[$result_element_key]['hashdata'] = $hashdata; $result_server[$result_element_key]['hashdata'] = $hashdata;
$result_server[$result_element_key]['user'] = $config['id_user']; $result_server[$result_element_key]['user'] = $config['id_user'];
$result_server[$result_element_key]['groups_in_server'] = $result_server[$result_element_key]['groups_in_server'] =
agents_get_all_groups_agent( agents_get_all_groups_agent(
$result_element_value['id_agent'], $result_element_value['id_agent'],
$result_element_value['id_group'] $result_element_value['id_group']
); );
$count_modules++; $count_modules++;
}
$result = array_merge($result, $result_server);
} }
metaconsole_restore_db();
$result = array_merge($result, $result_server);
} }
metaconsole_restore_db();
if ($count_modules > $config['block_size']) {
ui_pagination($count_modules, false, $offset);
}
// Get number of elements of the pagination
$result = ui_meta_get_subset_array($result, $inferior_limit, $superior_limit);
} }
if ($count_modules > $config['block_size']) {
ui_pagination ($count_modules, false, $offset);
}
// Get number of elements of the pagination
$result = ui_meta_get_subset_array($result, $inferior_limit, $superior_limit);
} }
if (($config['dbtype'] == 'oracle') && ($result !== false)) { if (($config['dbtype'] == 'oracle') && ($result !== false)) {
@ -1391,9 +1396,14 @@ if (!empty($result)) {
} }
html_print_table ($table); html_print_table ($table);
} else {
if ($first_interaction) {
ui_print_info_message(array('no_close' => true, 'message' => __('This group doesn\'t have any monitor')));
} else {
ui_print_info_message(array('no_close' => true, 'message' => __('Sorry no search parameters')));
}
} }
else
ui_print_info_message ( array ( 'no_close' => true, 'message' => __('This group doesn\'t have any monitor') ) );
// End Build List Result // End Build List Result
///////////////////////////////////// /////////////////////////////////////

View File

@ -20,6 +20,8 @@ require_once ($config["homedir"] . "/include/functions_ui.php");
$sort_field = get_parameter("sort_field", "timestamp"); $sort_field = get_parameter("sort_field", "timestamp");
$sort = get_parameter("sort", "down"); $sort = get_parameter("sort", "down");
$response_id = get_parameter ("response_id", "");
$table = new stdClass(); $table = new stdClass();
if(!isset($table->width)) { if(!isset($table->width)) {
$table->width = '100%'; $table->width = '100%';
@ -887,9 +889,8 @@ else {
echo '<div style="width:' . $table->width . ';" class="action-buttons">'; echo '<div style="width:' . $table->width . ';" class="action-buttons">';
if (!$readonly && $show_validate_button) { if (!$readonly && $show_validate_button) {
html_print_button(__('In progress selected'), 'validate_button', false, 'validate_selected(2);', 'class="sub ok"'); $array_events_actions['in_progress_selected'] = 'In progress selected';
echo " "; $array_events_actions['validate_selected'] = 'Validate selected';
html_print_button(__('Validate selected'), 'validate_button', false, 'validate_selected(1);', 'class="sub ok"');
// Fix: validated_selected JS function has to be included with the proper user ACLs // Fix: validated_selected JS function has to be included with the proper user ACLs
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -899,12 +900,14 @@ else {
validate_event_advanced($(this).val(), new_status); validate_event_advanced($(this).val(), new_status);
} }
}); });
location.reload();
} }
</script> </script>
<?php <?php
} }
if (!$readonly && ($show_delete_button)) { if (!$readonly && ($show_delete_button)) {
html_print_button(__('Delete selected'), 'delete_button', false, 'delete_selected();', 'class="sub delete"'); $array_events_actions['delete_selected'] = 'Delete selected';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function delete_selected() { function delete_selected() {
@ -916,13 +919,126 @@ else {
</script> </script>
<?php <?php
} }
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
$sql_event_resp = "SELECT id, name FROM tevent_response WHERE type LIKE 'command'";
$event_responses = db_get_all_rows_sql ($sql_event_resp);
foreach ($event_responses as $val)
$array_events_actions[$val['id']] = $val['name'];
if ($config['event_replication'] != 1) {
echo '<div style="width:100%;text-align:right;">';
echo '<form method="post" id="form_event_response">';
html_print_select($array_events_actions, 'response_id', '', '', '', 0, false, false, false);
echo '&nbsp&nbsp';
html_print_button(__('Execute event response'), 'submit_event_response', false, 'execute_event_response(true);', 'class="sub next"');
echo "<span id='response_loading_dialog' style='display:none'>".html_print_image('images/spinner.gif', true)."</span>";
echo '</form>';
echo '<span id="max_custom_event_resp_msg" style="display:none; color:#FC4444; line-height: 200%;">'.__("A maximum of 10 event custom responses can be selected").'</span>';
echo '</div>';
}
} }
?>
<script type="text/javascript">
function execute_event_response(event_list_btn) {
$('#max_custom_event_resp_msg').hide();
var response_id = $('select[name=response_id]').val();
if (!isNaN(response_id)) { // It is a custom response
var response = get_response(response_id);
var counter=0;
var end=0;
// If cannot get response abort it
if (response == null) {
return;
}
var total_checked = $(".chk_val:checked").length;
// Limit number of events to apply custom responses to for performance reasons
if (total_checked > 10) {
$('#max_custom_event_resp_msg').show();
return;
}
if (event_list_btn) {
$('#button-submit_event_response').hide(function() {
$('#response_loading_dialog').show(function() {
$(".chk_val").each(function() {
if ($(this).is(":checked")) {
//var server_id = $('#hidden-server_id_'+).
event_id = $(this).val();
server_id = $('#hidden-server_id_'+event_id).val();
response['target'] = get_response_target(event_id, response_id, server_id);
if (total_checked-1 === counter) end=1;
show_massive_response_dialog(event_id, response_id, response, counter, end);
counter++;
}
});
});
});
}
else {
$('#button-btn_str').hide(function() {
$('#execute_again_loading').show(function() {
$(".chk_val").each(function() {
if ($(this).is(":checked")) {
//var server_id = $('#hidden-server_id_'+).
event_id = $(this).val();
server_id = $('#hidden-server_id_'+event_id).val();
response['target'] = get_response_target(event_id, response_id, server_id);
if (total_checked-1 === counter) end=1;
show_massive_response_dialog(event_id, response_id, response, counter, end);
counter++;
}
});
});
});
}
}
else { // It is not a custom response
switch (response_id) {
case 'in_progress_selected':
validate_selected(2);
break;
case 'validate_selected':
validate_selected(1);
break;
case 'delete_selected':
delete_selected();
break;
}
}
}
</script>
<?php
} }
else { else {
echo '<div class="nf">' . __('No events') . '</div>'; echo '<div class="nf">' . __('No events') . '</div>';
} }
echo '</div>'; echo '</div>';
} }
?> ?>

View File

@ -559,6 +559,18 @@ if ($validate) {
if ($delete) { if ($delete) {
$ids = (array) get_parameter ("validate_ids", -1); $ids = (array) get_parameter ("validate_ids", -1);
// Discard deleting in progress events
$in_process_status = db_get_all_rows_sql("
SELECT id_evento
FROM tevento
WHERE estado=2");
foreach ($in_process_status as $val) {
if (($key = array_search($val['id_evento'], $ids)) !== false) {
unset($ids[$key]);
}
}
if ($ids[0] != -1) { if ($ids[0] != -1) {
$return = events_delete_event ($ids, ($group_rep == 1), $meta); $return = events_delete_event ($ids, ($group_rep == 1), $meta);
ui_print_result_message ($return, ui_print_result_message ($return,

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.730 %define version 7.0NG.730
%define release 190103 %define release 190115
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.730 %define version 7.0NG.730
%define release 190103 %define release 190115
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.730-190103 Version: 7.0NG.730-190115
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.730-190103" pandora_version="7.0NG.730-190115"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -45,7 +45,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.730"; my $pandora_version = "7.0NG.730";
my $pandora_build = "190103"; my $pandora_build = "190115";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.730"; my $pandora_version = "7.0NG.730";
my $pandora_build = "190103"; my $pandora_build = "190115";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.730 %define version 7.0NG.730
%define release 190103 %define release 190115
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.730 %define version 7.0NG.730
%define release 190103 %define release 190115
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.730" PI_VERSION="7.0NG.730"
PI_BUILD="190103" PI_BUILD="190115"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.730 PS190103"; my $version = "7.0NG.730 PS190115";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.730 PS190103"; my $version = "7.0NG.730 PS190115";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -195,6 +195,7 @@ sub help_screen{
help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy'); help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy');
help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); help_screen_line('--apply_all_policies', '', 'Force apply to all the policies');
help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy'); help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy');
help_screen_line('--remove_agent_from_policy', '<policy_id> <agent_id>', 'Delete an agent to a policy');
help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file'); help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file');
help_screen_line('--disable_policy_alerts', '<policy_name>', 'Disable all the alerts of a policy'); help_screen_line('--disable_policy_alerts', '<policy_name>', 'Disable all the alerts of a policy');
help_screen_line('--create_policy', '<policy_name> <group_name> <description>'); help_screen_line('--create_policy', '<policy_name> <group_name> <description>');
@ -4101,6 +4102,19 @@ sub cli_policy_add_agent() {
} }
} }
##############################################################################
# delete an agent to a policy
# Related option: --remove_agent_from_policy
##############################################################################
sub cli_policy_delete_agent() {
my ($policy_id, $agent_id) = @ARGV[2..3];
my $result = api_call(\%conf,'set', 'remove_agent_from_policy', $policy_id, $agent_id);
print "$result \n\n ";
}
sub cli_create_planned_downtime() { sub cli_create_planned_downtime() {
my $name = @ARGV[2]; my $name = @ARGV[2];
my @todo = @ARGV[3..21]; my @todo = @ARGV[3..21];
@ -5836,6 +5850,10 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 2); param_check($ltotal, 2);
cli_policy_add_agent(); cli_policy_add_agent();
} }
elsif ($param eq '--remove_agent_from_policy') {
param_check($ltotal, 2);
cli_policy_delete_agent();
}
elsif ($param eq '--enable_user') { elsif ($param eq '--enable_user') {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_user_enable(); cli_user_enable();