Merge remote-tracking branch 'origin/develop' into ent-7288-correlacion-eventos-no-permite-crear-condiciones-complejas
This commit is contained in:
commit
50f580c112
|
@ -0,0 +1,168 @@
|
|||
#!/bin/bash
|
||||
|
||||
#export PANDORA_SERVER_IP='newdemos.artica.es' && curl -sSL http://firefly.artica.es/projects/pandora_deploy_agent.sh | bash
|
||||
|
||||
# define variables
|
||||
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
|
||||
S_VERSION='2021012801'
|
||||
LOGFILE="/tmp/pandora-agent-deploy-$(date +%F).log"
|
||||
|
||||
# Ansi color code variables
|
||||
red="\e[0;91m"
|
||||
green="\e[0;92m"
|
||||
bold="\e[1m"
|
||||
cyan="\e[0;36m"
|
||||
yellow="\e[0;33m"
|
||||
reset="\e[0m"
|
||||
|
||||
# Functions
|
||||
|
||||
execute_cmd () {
|
||||
local cmd="$1"
|
||||
local msg="$2"
|
||||
|
||||
echo -e "${cyan}$msg...${reset}"
|
||||
$cmd &>> $LOGFILE
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Fail${reset}"
|
||||
[[ $3 ]] && echo "$3 "
|
||||
echo "Error installing Pandora FMS Agent for detailed error please check log: $LOGFILE"
|
||||
rm -rf $HOME/pandora_deploy_tmp &>> $LOGFILE
|
||||
exit 1
|
||||
else
|
||||
echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_cmd_status () {
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Fail${reset}"
|
||||
[ "$1" ] && echo "$1"
|
||||
echo "Error installing Pandora FMS Agent for detailed error please check log: $LOGFILE"
|
||||
rm -rf $HOME/pandora_deploy_tmp/*.rpm* &>> $LOGFILE
|
||||
exit 1
|
||||
else
|
||||
echo -e "${green}OK${reset}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_repo_connection () {
|
||||
execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection"
|
||||
execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo"
|
||||
}
|
||||
|
||||
check_root_permissions () {
|
||||
echo -en "${cyan}Checking root account... ${reset}"
|
||||
if [ "$(whoami)" != "root" ]; then
|
||||
echo -e "${red}Fail${reset}"
|
||||
echo "Please use a root account or sudo for installing PandoraFMS"
|
||||
echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE"
|
||||
exit 1
|
||||
|
||||
else
|
||||
echo -e "${green}OK${reset}"
|
||||
fi
|
||||
}
|
||||
|
||||
install_autodiscover () {
|
||||
local arch=$1
|
||||
wget https://pandorafms.com/library/wp-content/uploads/2020/04/autodiscover-linux.zip
|
||||
unzip autodiscover-linux.zip
|
||||
chmod +x $arch/autodiscover
|
||||
mv -f $arch/autodiscover /etc/pandora/plugins/autodiscover
|
||||
}
|
||||
|
||||
## Main
|
||||
echo "Starting PandoraFMS Agent deployment ver. $S_VERSION"
|
||||
|
||||
execute_cmd "[ $PANDORA_SERVER_IP ]" 'Check Server IP Address' 'Please define env variable PANDORA_SERVER_IP'
|
||||
|
||||
# Check OS.
|
||||
OS=$([[ $(grep '^ID_LIKE=' /etc/os-release) ]] && grep ^ID_LIKE= /etc/os-release | cut -d '=' -f2 | tr -d '"' || grep ^ID= /etc/os-release | cut -d '=' -f2 | tr -d '"')
|
||||
|
||||
[[ $OS == 'rhel fedora' ]] && OS_RELEASE=$OS
|
||||
[[ $OS == 'debian' ]] && OS_RELEASE=$OS
|
||||
|
||||
# initialice logfile
|
||||
execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE"
|
||||
echo "Community installer version: $S_VERSION" >> $LOGFILE
|
||||
|
||||
# Pre checks
|
||||
echo -en "${cyan}Checking compatible OS... ${reset}"
|
||||
[[ $OS_RELEASE ]]
|
||||
check_cmd_status "Error not compatible OS, $OS"
|
||||
|
||||
# Root permisions
|
||||
check_root_permissions
|
||||
|
||||
# Connectivity
|
||||
check_repo_connection
|
||||
|
||||
# Execute tools check
|
||||
execute_cmd "grep --version" 'Checking needed tools: grep'
|
||||
execute_cmd "sed --version" 'Checking needed tools: sed'
|
||||
|
||||
# Creating working directory
|
||||
rm -rf $HOME/pandora_deploy_tmp/ &>> $LOGFILE
|
||||
mkdir $HOME/pandora_deploy_tmp &>> $LOGFILE
|
||||
execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp"
|
||||
|
||||
# Downloading and installing packages
|
||||
|
||||
if [[ $OS_RELEASE == 'rhel fedora' ]]; then
|
||||
yum install -y perl wget curl perl-Sys-Syslog unzip &>> $LOGFILE
|
||||
echo -e "${cyan}Instaling agent dependencies...${reset}" ${green}OK${reset}
|
||||
|
||||
yum install -y http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm &>> $LOGFILE
|
||||
echo -e "${cyan}Instaling Pandora FMS agent...${reset}" ${green}OK${reset}
|
||||
fi
|
||||
|
||||
if [[ $OS_RELEASE == 'debian' ]]; then
|
||||
execute_cmd "apt update" 'Updating repos'
|
||||
execute_cmd "apt install -y perl wget curl unzip procps python3 python3-pip" 'Instaling agent dependencies'
|
||||
execute_cmd 'wget http://firefly.artica.es/pandorafms/latest/Debian_Ubuntu/pandorafms.agent_unix_7.0NG.deb' 'Downloading Pandora FMS agent dependencies'
|
||||
execute_cmd 'apt install -y ./pandorafms.agent_unix_7.0NG.deb' 'Installing Pandora FMS agent'
|
||||
fi
|
||||
|
||||
# Configuring Agente
|
||||
|
||||
[[ $PANDORA_SERVER_IP ]] && sed -i "s/^server_ip.*$/server_ip $PANDORA_SERVER_IP/g" $PANDORA_AGENT_CONF
|
||||
[[ $PANDORA_REMOTE_CONFIG ]] && sed -i "s/^remote_config.*$/remote_config $PANDORA_REMOTE_CONFIG/g" $PANDORA_AGENT_CONF
|
||||
[[ $PANDORA_GROUP ]] && sed -i "s/^group.*$/group $PANDORA_GROUP/g" $PANDORA_AGENT_CONF
|
||||
[[ $PANDORA_DEBUG ]] && sed -i "s/^debug.*$/debug $PANDORA_DEBUG/g" $PANDORA_AGENT_CONF
|
||||
[[ $PANDORA_AGENT_NAME ]] && sed -i "s/^#agent_name.*$/agent_name $PANDORA_AGENT_NAME/g" $PANDORA_AGENT_CONF
|
||||
[[ $PANDORA_AGENT_ALIAS ]] && sed -i "s/^#agent_alias.*$/agent_alias $PANDORA_AGENT_ALIAS/g" $PANDORA_AGENT_CONF
|
||||
[[ $PANDORA_SECONDARY_GROUPS ]] && sed -i "s/^# secondary_groups.*$/secondary_groups $PANDORA_SECONDARY_GROUPS/g" $PANDORA_AGENT_CONF
|
||||
[[ $TIMEZONE ]] && ln -sfn /usr/share/zoneinfo/$TIMEZONE /etc/localtime
|
||||
|
||||
|
||||
#installing autodiscover
|
||||
|
||||
arch=$(uname -m)
|
||||
case $arch in
|
||||
|
||||
x86_64)
|
||||
execute_cmd 'install_autodiscover x86_64' "installing service autodiscover on $arch" 'Error unable to install autodiscovery'
|
||||
;;
|
||||
|
||||
x86)
|
||||
execute_cmd 'install_autodiscover x84' "installing service autodiscover on $arch" 'Error unable to install autodiscovery'
|
||||
;;
|
||||
|
||||
armv7l)
|
||||
echo -e "${cyan}Skiping autodiscover installation arch $arch not suported${reset}"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo -e "${yellow}Skiping autodiscover installation arch $arch not suported${reset}"
|
||||
;;
|
||||
esac
|
||||
|
||||
#Starting pandora agent daemon.
|
||||
execute_cmd '/etc/init.d/pandora_agent_daemon restart' 'Starting Pandora Agent'
|
||||
cd
|
||||
execute_cmd 'rm -rf $HOME/pandora_deploy_tmp' 'Cleaning up temporay files'
|
||||
|
||||
echo -e "${green}PandoraFMS Agent installed and running, sending data to: $PANDORA_SERVER_IP${reset}"
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.753-210415
|
||||
Version: 7.0NG.753-210419
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.753-210415"
|
||||
pandora_version="7.0NG.753-210419"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.753';
|
||||
use constant AGENT_BUILD => '210415';
|
||||
use constant AGENT_BUILD => '210419';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.753"
|
||||
PI_BUILD="210415"
|
||||
PI_BUILD="210419"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{210415}
|
||||
{210419}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.753(Build 210415)")
|
||||
#define PANDORA_VERSION ("7.0NG.753(Build 210419)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.753(Build 210415))"
|
||||
VALUE "ProductVersion", "(7.0NG.753(Build 210419))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.753-210415
|
||||
Version: 7.0NG.753-210419
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.753-210415"
|
||||
pandora_version="7.0NG.753-210419"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tgrupo` ADD COLUMN `max_agents` int(10) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE `tagent_custom_fields` MODIFY COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE `treport_content` MODIFY `external_source` MEDIUMTEXT;
|
||||
ALTER TABLE `treport_content_template` MODIFY `external_source` MEDIUMTEXT;
|
||||
|
|
|
@ -2869,6 +2869,12 @@ UPDATE twidget SET description='Show a visual console' WHERE class_name='MapsMad
|
|||
UPDATE twidget SET description='Clock' WHERE class_name='ClockWidget';
|
||||
UPDATE twidget SET description='Group status' WHERE class_name='SystemGroupStatusWidget';
|
||||
|
||||
--
|
||||
-- Modifies tgrupo table.
|
||||
--
|
||||
|
||||
ALTER TABLE tgrupo ADD COLUMN max_agents int(10) NOT NULL DEFAULT 0;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnode_relations`
|
||||
-- ----------------------------------------------------------------------
|
||||
|
|
|
@ -37,6 +37,8 @@ require_once $config['homedir'].'/include/functions_cron.php';
|
|||
ui_require_javascript_file('encode_decode_base64');
|
||||
ui_require_css_file('agent_manager');
|
||||
|
||||
use PandoraFMS\Event;
|
||||
|
||||
check_login();
|
||||
|
||||
// Get tab parameter to check ACL in each tabs.
|
||||
|
@ -229,6 +231,9 @@ if ($create_agent) {
|
|||
if ($alias == '') {
|
||||
$agent_creation_error = __('No agent alias specified');
|
||||
$agent_created_ok = 0;
|
||||
} else if (group_allow_more_agents($grupo, true, 'create') === false) {
|
||||
$agent_creation_error = __('Agent cannot be created due to the maximum agent limit for this group');
|
||||
$agent_created_ok = 0;
|
||||
} else {
|
||||
if ($alias_as_name) {
|
||||
$sql = 'SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"';
|
||||
|
@ -1034,6 +1039,8 @@ if ($update_agent) {
|
|||
|
||||
if ($grupo <= 0) {
|
||||
ui_print_error_message(__('The group id %d is incorrect.', $grupo));
|
||||
} else if (group_allow_more_agents($grupo, true, 'update') === false) {
|
||||
ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group'));
|
||||
} else if ($exists_ip) {
|
||||
ui_print_error_message(__('Duplicate main IP address'));
|
||||
} else {
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Configure agent groups.
|
||||
*
|
||||
* @category Agents group management.
|
||||
* @package Pandora FMS
|
||||
* @subpackage User interface.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
@ -27,7 +43,7 @@ require_once $config['homedir'].'/include/functions_groups.php';
|
|||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
enterprise_include_once('meta/include/functions_agents_meta.php');
|
||||
|
||||
// Init vars
|
||||
// Default values.
|
||||
$icon = '';
|
||||
$name = '';
|
||||
$id_parent = 0;
|
||||
|
@ -39,6 +55,7 @@ $skin = 0;
|
|||
$contact = '';
|
||||
$other = '';
|
||||
$description = '';
|
||||
$max_agents = 0;
|
||||
|
||||
$create_group = (bool) get_parameter('create_group');
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
|
@ -62,6 +79,7 @@ if ($id_group) {
|
|||
$description = $group['description'];
|
||||
$contact = $group['contact'];
|
||||
$other = $group['other'];
|
||||
$max_agents = $group['max_agents'];
|
||||
} else {
|
||||
ui_print_error_message(__('There was a problem loading group'));
|
||||
echo '</table>';
|
||||
|
@ -224,6 +242,10 @@ $i++;
|
|||
// $table->data[10][0] = __('Skin');
|
||||
// $table->data[10][1] = skins_print_select($config['id_user'], 'skin', $skin, '', __('None'), 0, true);
|
||||
// }
|
||||
$table->data[$i][0] = __('Max agents allowed').' '.ui_print_help_tip(__('Set the maximum of agents allowed for this group. 0 is unlimited.'), true);
|
||||
$table->data[$i][1] = html_print_input_text('max_agents', $max_agents, '', 10, 255, true);
|
||||
$i++;
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$sec = 'advanced';
|
||||
} else {
|
||||
|
@ -241,6 +263,7 @@ if (isset($config['metaconsole_node_id']) && $config['metaconsole_node_id'] > 0)
|
|||
echo '<form name="grupo" method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/group_list&pure='.$config['pure'].'"'.$confirm_bottom.' >';
|
||||
html_print_table($table);
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_button(__('Back'), 'button_back', false, '', 'class="sub cancel"');
|
||||
if ($id_group) {
|
||||
html_print_input_hidden('update_group', 1);
|
||||
html_print_input_hidden('id_group', $id_group);
|
||||
|
@ -331,5 +354,8 @@ function parent_changed () {
|
|||
$(document).ready (function () {
|
||||
$('#icon').change (icon_changed);
|
||||
$('#id_parent').change (parent_changed);
|
||||
$('#button-button_back').on('click', function(){
|
||||
window.location = '<?php echo ui_get_full_url('index.php?sec='.$sec.'&sec2=godmode/groups/group_list'); ?>';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -387,6 +387,7 @@ if (($create_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true))
|
|||
$description = (string) get_parameter('description');
|
||||
$contact = (string) get_parameter('contact');
|
||||
$other = (string) get_parameter('other');
|
||||
$max_agents = (int) get_parameter('max_agents', 0);
|
||||
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
|
||||
$propagate = (bool) get_parameter('propagate');
|
||||
|
||||
|
@ -411,6 +412,7 @@ if (($create_group) && ((bool) check_acl($config['id_user'], 0, 'PM') === true))
|
|||
'propagate' => $propagate,
|
||||
'other' => $other,
|
||||
'password' => io_safe_input($group_pass),
|
||||
'max_agents' => $max_agents,
|
||||
];
|
||||
|
||||
$result = db_process_sql_insert('tgrupo', $values);
|
||||
|
@ -444,6 +446,7 @@ if ($update_group) {
|
|||
$description = (string) get_parameter('description');
|
||||
$contact = (string) get_parameter('contact');
|
||||
$other = (string) get_parameter('other');
|
||||
$max_agents = (int) get_parameter('max_agents', 0);
|
||||
|
||||
$aviable_name = true;
|
||||
if (preg_match('/script/i', $name)) {
|
||||
|
@ -477,6 +480,7 @@ if ($update_group) {
|
|||
'propagate' => $propagate,
|
||||
'other' => $other,
|
||||
'password' => io_safe_input($group_pass),
|
||||
'max_agents' => $max_agents,
|
||||
];
|
||||
|
||||
$result = db_process_sql_update(
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC210415';
|
||||
$build_version = 'PC210419';
|
||||
$pandora_version = 'v7.0NG.753';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -1,27 +1,38 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Agents
|
||||
* Agents Functions.
|
||||
*
|
||||
* @category Agents functions.
|
||||
* @package Pandora FMS
|
||||
* @subpackage User interface.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
require_once $config['homedir'].'/include/functions.php';
|
||||
require_once $config['homedir'].'/include/functions_modules.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
use PandoraFMS\Enterprise\RCMDFile as RCMDFile;
|
||||
use PandoraFMS\Event;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -203,11 +214,13 @@ function agents_create_agent(
|
|||
$values=false,
|
||||
$alias_as_name=false
|
||||
) {
|
||||
if (empty($name)) {
|
||||
global $config;
|
||||
|
||||
if (empty($name) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($id_group) && (int) $id_group != 0) {
|
||||
if (empty($id_group) === true && (int) $id_group !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -216,11 +229,11 @@ function agents_create_agent(
|
|||
$interval = false;
|
||||
}
|
||||
|
||||
if (empty($interval)) {
|
||||
if (empty($interval) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! is_array($values)) {
|
||||
if (is_array($values) === false) {
|
||||
$values = [];
|
||||
}
|
||||
|
||||
|
@ -229,17 +242,22 @@ function agents_create_agent(
|
|||
$values['id_grupo'] = $id_group;
|
||||
$values['intervalo'] = $interval;
|
||||
|
||||
if (!empty($ip_address)) {
|
||||
if (empty($ip_address) === false) {
|
||||
$values['direccion'] = $ip_address;
|
||||
}
|
||||
|
||||
// Check if group has limit or overrides the agent limit.
|
||||
if (group_allow_more_agents($id_group, true, 'create') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$id_agent = db_process_sql_insert('tagente', $values);
|
||||
if ($id_agent === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create address for this agent in taddress.
|
||||
if (!empty($ip_address)) {
|
||||
if (empty($ip_address) === false) {
|
||||
agents_add_address($id_agent, $ip_address);
|
||||
}
|
||||
|
||||
|
@ -3857,6 +3875,70 @@ function agents_get_last_status_change($id_agent)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if group allow more agents due itself limitation.
|
||||
*
|
||||
* @param integer $id_group Id of the group.
|
||||
* @param boolean $generateEvent If true and the check fails, will generate an event.
|
||||
* @param string $action Action for perform (only if generateEvent is true).
|
||||
*
|
||||
* @return boolean True if allow more agents.
|
||||
*/
|
||||
function group_allow_more_agents(
|
||||
int $id_group,
|
||||
bool $generateEvent=false,
|
||||
string $action='create'
|
||||
):bool {
|
||||
global $config;
|
||||
|
||||
$groupMaxAgents = (int) db_get_value('max_agents', 'tgrupo', sprintf('id_grupo = %d', $id_group));
|
||||
$groupCountAgents = (int) db_get_num_rows(sprintf('SELECT nombre FROM tagente WHERE id_grupo = "%s"', $id_group));
|
||||
|
||||
// If `max_agents` is not defined or the count of agents in the group is below of max agents allowed.
|
||||
$output = ($groupMaxAgents === 0 || $groupCountAgents < $groupMaxAgents);
|
||||
|
||||
if ($output === false && $generateEvent === true) {
|
||||
// Get the group name.
|
||||
$groupName = db_get_value(
|
||||
'nombre',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$id_group
|
||||
);
|
||||
// New event.
|
||||
$evt = new Event;
|
||||
// Set parameters.
|
||||
$evt->evento(
|
||||
sprintf(
|
||||
'Agent cannot be %sd due to the maximum agent limit for group %s',
|
||||
$action,
|
||||
$groupName
|
||||
)
|
||||
);
|
||||
$evt->id_grupo($id_group);
|
||||
$evt->id_agente(0);
|
||||
$evt->id_agentmodule(0);
|
||||
$evt->id_usuario($config['id_user']);
|
||||
$evt->estado(EVENT_STATUS_NEW);
|
||||
$evt->event_type(EVENTS_SYSTEM);
|
||||
$evt->criticity(EVENT_CRIT_WARNING);
|
||||
$evt->timestamp(date('Y-m-d H:i:s'));
|
||||
$evt->utimestamp(time());
|
||||
$evt->data(0);
|
||||
$evt->source('agent_creation');
|
||||
// Any fields are only available in meta.
|
||||
if (is_metaconsole() === true) {
|
||||
$evt->id_source_event(0);
|
||||
}
|
||||
|
||||
// Save the event.
|
||||
$evt->save();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of agents for a planned downtime
|
||||
*
|
||||
|
@ -3866,7 +3948,7 @@ function agents_get_last_status_change($id_agent)
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str)
|
||||
function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str):array
|
||||
{
|
||||
$agents = [];
|
||||
|
||||
|
|
|
@ -1479,6 +1479,12 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
|
|||
return;
|
||||
}
|
||||
|
||||
// Check if group allow more agents or have limit stablished.
|
||||
if (group_allow_more_agents($idGroup, true, 'update') === false) {
|
||||
returnError('Agent cannot be updated due to the maximum agent limit for this group');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check selected parent
|
||||
if ($idParent != 0) {
|
||||
$parentCheck = agents_check_access_agent($idParent);
|
||||
|
@ -1680,6 +1686,8 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
|
|||
returnError('The agent name already exists in DB.');
|
||||
} else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) {
|
||||
returnError('The group does not exist.');
|
||||
} else if (group_allow_more_agents($grupo, true, 'create') === false) {
|
||||
returnError('Agent cannot be created due to the maximum agent limit for this group');
|
||||
} else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) {
|
||||
returnError('The OS does not exist.');
|
||||
} else if ($server_name === false) {
|
||||
|
@ -8403,6 +8411,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3)
|
|||
$values['custom_id'] = $safe_other_data[5];
|
||||
$values['contact'] = $safe_other_data[6];
|
||||
$values['other'] = $safe_other_data[7];
|
||||
$values['max_agents'] = $safe_other_data[8];
|
||||
|
||||
$id_group = groups_create_group($group_name, $values);
|
||||
|
||||
|
@ -8482,7 +8491,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
|
|||
$disabled = $other['data'][5];
|
||||
$custom_id = $other['data'][6];
|
||||
$contact = $other['data'][7];
|
||||
$other = $other['data'][8];
|
||||
$otherData = $other['data'][8];
|
||||
$maxAgents = $other['data'][9];
|
||||
|
||||
$return = db_process_sql_update(
|
||||
'tgrupo',
|
||||
|
@ -8495,7 +8505,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
|
|||
'disabled' => $disabled,
|
||||
'custom_id' => $custom_id,
|
||||
'contact' => $contact,
|
||||
'other' => $other,
|
||||
'other' => $otherData,
|
||||
'max_agents' => $maxAgents,
|
||||
],
|
||||
['id_grupo' => $id_group]
|
||||
);
|
||||
|
|
|
@ -60,18 +60,15 @@ class Event extends Entity
|
|||
*/
|
||||
public function __construct(?int $event_id=null)
|
||||
{
|
||||
$table = 'tevento';
|
||||
if ((bool) \is_metaconsole() === true) {
|
||||
$table = 'tmetaconsole_event';
|
||||
}
|
||||
$this->table = ((bool) \is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento';
|
||||
|
||||
if ($event_id === 0) {
|
||||
parent::__construct($table);
|
||||
parent::__construct($this->table);
|
||||
} else if (is_numeric($event_id) === true) {
|
||||
parent::__construct($table, ['id_evento' => $event_id]);
|
||||
parent::__construct($this->table, ['id_evento' => $event_id]);
|
||||
} else {
|
||||
// Empty skel.
|
||||
parent::__construct($table);
|
||||
parent::__construct($this->table);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -185,28 +182,26 @@ class Event extends Entity
|
|||
*/
|
||||
public function save()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($config['centralized_management']) === true
|
||||
&& (bool) $config['centralized_management'] === true
|
||||
) {
|
||||
throw new \Exception(
|
||||
'error, cannot save in centralized management environment.'
|
||||
);
|
||||
$values = $this->fields;
|
||||
// Clean null fields.
|
||||
foreach ($values as $k => $v) {
|
||||
if ($v === null) {
|
||||
unset($values[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->id_evento === null) {
|
||||
// New.
|
||||
return db_process_sql_insert(
|
||||
'tgrupo',
|
||||
$this->fields
|
||||
$this->table,
|
||||
$values
|
||||
);
|
||||
} else if ($this->fields['id_evento'] > 0) {
|
||||
// Update.
|
||||
return db_process_sql_update(
|
||||
'tgrupo',
|
||||
$this->fields,
|
||||
['id_evento' => $this->fields['id_evento']]
|
||||
$this->table,
|
||||
$values,
|
||||
['id_evento' => $values['id_evento']]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -5450,6 +5450,10 @@ table.info_table.policy_sub_table {
|
|||
min-width: 100px;
|
||||
}
|
||||
|
||||
div.label_select_child_left > span {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.label_select_child_right {
|
||||
width: 20%;
|
||||
min-width: 140px;
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.753';
|
||||
$build = '210415';
|
||||
$build = '210419';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -159,7 +159,7 @@ if ($upload_file && ($_FILES['userfile']['name'] != '')) {
|
|||
|
||||
$filecontent = base64_encode(file_get_contents($_FILES['userfile']['tmp_name']));
|
||||
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'attach_file', [$incident_id, $filename, $filesize, $filedescription, $filecontent]);
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'attach_file', [$incident_id, $filename, $filesize, $filedescription, $filecontent], false, '', ';');
|
||||
|
||||
// API method returns '0' string if success.
|
||||
$file_added = ($result_api_call === '0') ? true : false;
|
||||
|
@ -322,7 +322,7 @@ $table_comments_section->data[1][1] .= '<div class="w100p right">'.html_print_su
|
|||
|
||||
// Upload comment. If ticket is closed, this action cannot be performed.
|
||||
if ($upload_comment && $array_get_incidents[6] != 7) {
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0']);
|
||||
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0'], false, '', '|;|');
|
||||
|
||||
// API method returns id of new comment if success.
|
||||
$comment_added = ($result_api_call >= '0') ? true : false;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -723,6 +723,7 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
|
|||
`contact` text,
|
||||
`other` text,
|
||||
`password` varchar(45) default '',
|
||||
`max_agents` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id_grupo`),
|
||||
KEY `parent_index` (`parent`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.753-210415
|
||||
Version: 7.0NG.753-210419
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.753-210415"
|
||||
pandora_version="7.0NG.753-210419"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.753";
|
||||
my $pandora_build = "210415";
|
||||
my $pandora_build = "210419";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.753";
|
||||
my $pandora_build = "210415";
|
||||
my $pandora_build = "210419";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.753
|
||||
%define release 210415
|
||||
%define release 210419
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.753"
|
||||
PI_BUILD="210415"
|
||||
PI_BUILD="210419"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.753 PS210415";
|
||||
my $version = "7.0NG.753 PS210419";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.753 PS210415";
|
||||
my $version = "7.0NG.753 PS210419";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|
Loading…
Reference in New Issue