Merge remote-tracking branch 'origin/develop' into ent-3013-ipam-modo-configuracion-de-vlan

Former-commit-id: 8cfa910f14527759459b667c2d9b1303472c30ca
This commit is contained in:
daniel 2019-01-16 08:41:50 +01:00
commit c0398dfa5b
39 changed files with 569 additions and 187 deletions

View File

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

View File

@ -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-190111"
pandora_version="7.0NG.730-190116"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.730';
use constant AGENT_BUILD => '190111';
use constant AGENT_BUILD => '190116';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

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

View File

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

View File

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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{190111}
{190116}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.730(Build 190111)")
#define PANDORA_VERSION ("7.0NG.730(Build 190116)")
string pandora_path;
string pandora_dir;

View File

@ -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 190111))"
VALUE "ProductVersion", "(7.0NG.730(Build 190116))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

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

View File

@ -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-190111"
pandora_version="7.0NG.730-190116"
package_pear=0
package_pandora=1

View File

@ -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 '<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

@ -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'];
}

View File

@ -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') {

View File

@ -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 = "<br>> ";
switch($event_response['type']) {
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>";
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>";
if ($massive) {
echo "<div style='text-align:left'>";
echo $prompt.sprintf("(Event #$event_id) ".__('Executing command: %s',$command));
echo "</div><br>";
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;
case 'url':
$command = str_replace("localhost",$_SERVER['SERVER_NAME'],$command);

View File

@ -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
*

View File

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

View File

@ -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 "<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
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,

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_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) {

View File

@ -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');
}

View File

@ -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);

View File

@ -158,10 +158,11 @@ function show_response_dialog(event_id, response_id, response) {
var params = [];
params.push("page=include/ajax/events");
params.push("dialogue_event_response=1");
params.push("massive=0");
params.push("event_id="+event_id);
params.push("target="+response['target']);
params.push("response_id="+response_id);
jQuery.ajax ({
data: params.join ("&"),
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
function get_response(response_id) {
var ajax_file = $('#hidden-ajax_file').val();
@ -371,6 +423,42 @@ function perform_response(target, response_id) {
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
function event_change_status(event_ids) {
var ajax_file = $('#hidden-ajax_file').val();

View File

@ -14,6 +14,17 @@
// 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();
} else {
error_log("Cannot find tideways_xhprof_enable function");
}
}
//Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
if (function_exists ('mb_internal_encoding')) {
mb_internal_encoding ("UTF-8");
@ -1277,3 +1288,8 @@ require('include/php_to_js_values.php');
*/
}
</script>
<?php
if (__PAN_XHPROF__ === 1) {
pandora_xhprof_display_result("node_index");
}
?>

View File

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

View File

@ -552,7 +552,7 @@ if (is_metaconsole()) {
$filters .= html_print_table($table, true);
$filters .= "</form>";
ui_toggle($filters, __('Show Options'));
ui_toggle($filters, __('Show Options'), '', false);
}
else {
$table->colspan[3][0] = 7;
@ -778,84 +778,89 @@ $sql = 'SELECT
ORDER BY ' . $order['field'] . " " . $order['order'] . '
LIMIT '.$offset.",".$limit_sql;
if (! defined ('METACONSOLE')) {
$result = db_get_all_rows_sql ($sql);
if ($result === false) {
$result = array ();
// When you enter for the first time you have less than 4 query params in the url
$first_interaction = count($_GET) > 4;
// We do not show the modules until the user searches with the filter
if ($first_interaction) {
if (! defined ('METACONSOLE')) {
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = array();
} else {
ui_pagination($count, false, $offset);
}
}
else
ui_pagination ($count, false, $offset);
}
else {
// 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
WHERE disabled = 0');
if ($servers === false)
$servers = array();
$result = array();
$count_modules = 0;
foreach ($servers as $server) {
if ($servers === false)
$servers = array();
$result = array();
$count_modules = 0;
foreach ($servers as $server) {
// If connection was good then retrieve all data server
if (metaconsole_connect($server) == NOERR)
$connection = true;
else
$connection = false;
$result_server = db_get_all_rows_sql ($sql);
if (!empty($result_server)) {
if (metaconsole_connect($server) == NOERR)
$connection = true;
else
$connection = false;
$result_server = db_get_all_rows_sql($sql);
if (!empty($result_server)) {
// Create HASH login info
$pwd = $server['auth_token'];
$auth_serialized = json_decode($pwd,true);
if (is_array($auth_serialized)) {
$pwd = $auth_serialized['auth_token'];
$api_password = $auth_serialized['api_password'];
$console_user = $auth_serialized['console_user'];
$console_password = $auth_serialized['console_password'];
}
$user = $config['id_user'];
$user_rot13 = str_rot13($config['id_user']);
$hashdata = $user.$pwd;
$hashdata = md5($hashdata);
$url_hash = '&' .
'loginhash=auto&' .
'loginhash_data=' . $hashdata . '&' .
'loginhash_user=' . $user_rot13;
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_name'] = $server['server_name'];
$result_server[$result_element_key]['server_url'] = $server['server_url'].'/';
$result_server[$result_element_key]['hashdata'] = $hashdata;
$result_server[$result_element_key]['user'] = $config['id_user'];
$result_server[$result_element_key]['groups_in_server'] =
agents_get_all_groups_agent(
$pwd = $server['auth_token'];
$auth_serialized = json_decode($pwd, true);
if (is_array($auth_serialized)) {
$pwd = $auth_serialized['auth_token'];
$api_password = $auth_serialized['api_password'];
$console_user = $auth_serialized['console_user'];
$console_password = $auth_serialized['console_password'];
}
$user = $config['id_user'];
$user_rot13 = str_rot13($config['id_user']);
$hashdata = $user . $pwd;
$hashdata = md5($hashdata);
$url_hash = '&' .
'loginhash=auto&' .
'loginhash_data=' . $hashdata . '&' .
'loginhash_user=' . $user_rot13;
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_name'] = $server['server_name'];
$result_server[$result_element_key]['server_url'] = $server['server_url'] . '/';
$result_server[$result_element_key]['hashdata'] = $hashdata;
$result_server[$result_element_key]['user'] = $config['id_user'];
$result_server[$result_element_key]['groups_in_server'] =
agents_get_all_groups_agent(
$result_element_value['id_agent'],
$result_element_value['id_group']
);
$count_modules++;
);
$count_modules++;
}
$result = array_merge($result, $result_server);
}
$result = array_merge($result, $result_server);
metaconsole_restore_db();
}
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)) {
@ -1391,9 +1396,14 @@ if (!empty($result)) {
}
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
/////////////////////////////////////

View File

@ -20,6 +20,8 @@ require_once ($config["homedir"] . "/include/functions_ui.php");
$sort_field = get_parameter("sort_field", "timestamp");
$sort = get_parameter("sort", "down");
$response_id = get_parameter ("response_id", "");
$table = new stdClass();
if(!isset($table->width)) {
$table->width = '100%';
@ -887,9 +889,8 @@ else {
echo '<div style="width:' . $table->width . ';" class="action-buttons">';
if (!$readonly && $show_validate_button) {
html_print_button(__('In progress selected'), 'validate_button', false, 'validate_selected(2);', 'class="sub ok"');
echo " ";
html_print_button(__('Validate selected'), 'validate_button', false, 'validate_selected(1);', 'class="sub ok"');
$array_events_actions['in_progress_selected'] = 'In progress selected';
$array_events_actions['validate_selected'] = 'Validate selected';
// Fix: validated_selected JS function has to be included with the proper user ACLs
?>
<script type="text/javascript">
@ -899,12 +900,14 @@ else {
validate_event_advanced($(this).val(), new_status);
}
});
location.reload();
}
</script>
<?php
}
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">
function delete_selected() {
@ -916,13 +919,126 @@ else {
</script>
<?php
}
echo '</div>';
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 {
echo '<div class="nf">' . __('No events') . '</div>';
}
echo '</div>';
}
?>
?>

View File

@ -559,6 +559,18 @@ if ($validate) {
if ($delete) {
$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) {
$return = events_delete_event ($ids, ($group_rep == 1), $meta);
ui_print_result_message ($return,

View File

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

View File

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

View File

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

View File

@ -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-190111"
pandora_version="7.0NG.730-190116"
package_cpan=0
package_pandora=1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.730 PS190111";
my $version = "7.0NG.730 PS190116";
# save program name for logging
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_all_policies', '', 'Force apply to all the policies');
help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy');
help_screen_line('--remove_agent_from_policy', '<policy_id> <agent_id>', 'Delete an agent to a policy');
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('--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() {
my $name = @ARGV[2];
my @todo = @ARGV[3..21];
@ -5836,6 +5850,10 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 2);
cli_policy_add_agent();
}
elsif ($param eq '--remove_agent_from_policy') {
param_check($ltotal, 2);
cli_policy_delete_agent();
}
elsif ($param eq '--enable_user') {
param_check($ltotal, 1);
cli_user_enable();