Merge branch 'develop' into ent-11326-security-hardening-console

This commit is contained in:
Daniel Cebrian 2023-07-26 10:55:49 +02:00
commit 001ffc1799
150 changed files with 5931 additions and 1635 deletions

View File

@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
S_VERSION='2023050901'
S_VERSION='2023062901'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
@ -285,8 +285,7 @@ console_dependencies=" \
mod_ssl \
libzstd \
openldap-clients \
chromium \
http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"
chromium"
execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
# Server dependencies
@ -313,7 +312,6 @@ server_dependencies=" \
bind-utils \
whois \
cpanminus \
http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \
https://firefly.pandorafms.com/centos7/pandorawmic-1.0.0-1.x86_64.rpm"
execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
@ -341,7 +339,6 @@ execute_cmd "yum install -y $oracle_dependencies || yum reinstall -y $oracle_dep
#ipam dependencies
ipam_dependencies=" \
http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
perl(NetAddr::IP) \
perl(Sys::Syslog) \
perl(DBI) \
@ -719,6 +716,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro
systemctl enable pandora_agent_daemon &>> $LOGFILE
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
# Enable postrix
systemctl enable postfix --now &>> "$LOGFILE"
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)

View File

@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf
PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
S_VERSION='2023050901'
S_VERSION='2023062901'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
@ -344,8 +344,7 @@ console_dependencies=" \
http://firefly.pandorafms.com/centos8/chromium-110.0.5481.177-1.el7.x86_64.rpm \
http://firefly.pandorafms.com/centos8/chromium-common-110.0.5481.177-1.el7.x86_64.rpm \
http://firefly.pandorafms.com/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \
http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \
http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"
http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm"
execute_cmd "dnf install -y $console_dependencies" "Installing Pandora FMS Console dependencies"
# Server dependencies
@ -371,7 +370,7 @@ server_dependencies=" \
java \
bind-utils \
whois \
http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
libnsl \
http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \
https://firefly.pandorafms.com/centos8/pandorawmic-1.0.0-1.x86_64.rpm"
execute_cmd "dnf install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
@ -399,7 +398,6 @@ execute_cmd "dnf install -y $oracle_dependencies" "Installing Oracle Instant cli
#ipam dependencies
ipam_dependencies=" \
http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \
perl(NetAddr::IP) \
perl(Sys::Syslog) \
perl(DBI) \
@ -622,8 +620,9 @@ sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini
sed -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini
sed -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini
#adding 900s to httpd timeout
#adding 900s to httpd timeout and 300 to ProxyTimeout
echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf
echo 'ProxyTimeout 300' >> /etc/httpd/conf.d/timeout.conf
cat > /var/www/html/index.html << EOF_INDEX
<meta HTTP-EQUIV="REFRESH" content="0; url=/pandora_console/">
@ -787,6 +786,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro
systemctl enable pandora_agent_daemon &>> "$LOGFILE"
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
# Enable postfix
systemctl enable postfix --now &>> "$LOGFILE"
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)

View File

@ -17,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf
WORKDIR=/opt/pandora/deploy
S_VERSION='2023050901'
S_VERSION='2023062901'
LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
rm -f $LOGFILE &> /dev/null # remove last log before start
@ -265,7 +265,6 @@ server_dependencies=" \
openssh-client \
postfix \
unzip \
xprobe \
coreutils \
libio-compress-perl \
libmoosex-role-timer-perl \
@ -287,6 +286,7 @@ server_dependencies=" \
libgeo-ip-perl \
arping \
snmp-mibs-downloader \
libnsl2 \
openjdk-8-jdk "
execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies"
@ -299,17 +299,7 @@ echo -en "${cyan}Installing wmic and pandorawmic...${reset}"
chmod +x pandorawmic wmic &>> "$LOGFILE" && \
cp -a wmic /usr/bin/ &>> "$LOGFILE" && \
cp -a pandorawmic /usr/bin/ &>> "$LOGFILE"
check_cmd_status "Error Installing phanromjs"
# phantomjs
echo -en "${cyan}Installing phantomjs...${reset}"
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
export OPENSSL_CONF=/etc/ssl
curl -LSs -O "https://firefly.pandorafms.com/pandorafms/utils/$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \
tar xvjf "$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \
mv $PHANTOM_JS/bin/phantomjs /usr/bin &>> "$LOGFILE" && \
/usr/bin/phantomjs --version &>> "$LOGFILE"
check_cmd_status "Error Installing phanromjs"
check_cmd_status "Error Installing pandorawmic/wmic"
# create symlink for fping
rm -f /usr/sbin/fping &>> "$LOGFILE"
@ -370,7 +360,6 @@ source '/root/.profile' &>> "$LOGFILE"
#ipam dependencies
ipam_dependencies=" \
xprobe \
libnetaddr-ip-perl \
coreutils \
libdbd-mysql-perl \
@ -619,8 +608,9 @@ sed --follow-symlinks -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.i
sed --follow-symlinks -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini
sed --follow-symlinks -i -e "s/^disable_functions/;disable_functions/" /etc/php.ini
#adding 900s to httpd timeout
#echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf
#adding 900s to httpd timeout and 300 to ProxyTimeout
echo 'TimeOut 900' > /etc/apache2/conf-enabled/timeout.conf
echo 'ProxyTimeout 300' >> /etc/apache2/conf-enabled/timeout.conf
cat > /var/www/html/index.html << EOF_INDEX
<meta HTTP-EQUIV="REFRESH" content="0; url=/pandora_console/">
@ -792,6 +782,9 @@ systemctl enable pandora_agent_daemon &>> "$LOGFILE"
#fix path phantomjs
sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = openssl_init/g" /etc/ssl/openssl.cnf &>> "$LOGFILE"
# Enable postfix
systemctl enable postfix --now &>> "$LOGFILE"
#SSH banner
[ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me)

View File

@ -4,7 +4,7 @@ Architecture: all
Priority: optional
Section: admin
Installed-Size: 260
Maintainer: ÁRTICA ST <info@artica.es>
Maintainer: Pandora FMS <info@pandorafms.com>
Homepage: https://pandorafms.org/
Depends: coreutils, perl, unzip
Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. Its possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file.

View File

@ -4,7 +4,7 @@ Architecture: all
Priority: optional
Section: admin
Installed-Size: 260
Maintainer: ÁRTICA ST <info@artica.es>
Maintainer: Pandora FMS <info@pandorafms.com>
Homepage: http://pandorafms.org/
Depends: coreutils, perl
Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. Its possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file.

View File

@ -1,10 +1,10 @@
package: pandorafms-agent-unix
Version: 7.0NG.772-230712
Version: 7.0NG.772-230725
Architecture: all
Priority: optional
Section: admin
Installed-Size: 260
Maintainer: ÁRTICA ST <info@artica.es>
Maintainer: Pandora FMS <info@pandorafms.com>
Homepage: http://pandorafms.org/
Depends: coreutils, perl, unzip
Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. Its possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file.

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.772-230712"
pandora_version="7.0NG.772-230725"
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

@ -6,7 +6,7 @@
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.772</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.772 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.772 Pandora FMS Agent uninstaller for MacOS by Pandora FMS on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.772</string>
<key>NSPrincipalClass</key><string>NSApplication</string>

View File

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

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.772
%define release 230712
%define release 230725
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.772
%define release 230712
%define release 230725
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.772"
PI_BUILD="230712"
PI_BUILD="230725"
OS_NAME=`uname -s`
FORCE=0
@ -541,8 +541,17 @@ install () {
then
echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon."
else
echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
echo "to start automatically when system restarts":
# Enable startup service
if [ `command -v systemctl` ]
then
systemctl enable pandora_agent_daemon
elif [ `command -v chkconfig` ]
then
chkconfig pandora_agent_daemon on
else
echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
echo "to start automatically when system restarts":
fi
fi
# Restore the daemon script

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{230712}
{230725}
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.772 Build 230712")
#define PANDORA_VERSION ("7.0NG.772 Build 230725")
string pandora_path;
string pandora_dir;

View File

@ -6,12 +6,12 @@ BEGIN
BEGIN
BLOCK "080904E4"
BEGIN
VALUE "CompanyName", "Artica ST"
VALUE "CompanyName", "Pandora FMS"
VALUE "FileDescription", "Pandora FMS Agent for Windows Platform"
VALUE "LegalCopyright", "Artica ST"
VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.772(Build 230712))"
VALUE "ProductVersion", "(7.0NG.772(Build 230725))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,10 +1,10 @@
package: pandorafms-console
Version: 7.0NG.772-230712
Version: 7.0NG.772-230725
Architecture: all
Priority: optional
Section: admin
Installed-Size: 42112
Maintainer: Artica ST <deptec@artica.es>
Maintainer: Pandora FMS <info@pandorafms.com>
Homepage: https://pandorafms.com/
Depends: php, php-snmp, php-gd, php-mysqlnd, php-db, php-xmlrpc, php-curl, graphviz, dbconfig-common, php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc, php-zip, php-mbstring
Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process.

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.772-230712"
pandora_version="7.0NG.772-230725"
package_pear=0
package_pandora=1
@ -163,7 +163,7 @@ if [ $package_pear -eq 1 ]
then
echo "Make the package \"php-xml-rpc\"."
cd temp_package
dh-make-pear --maintainer "ÁRTICA ST <info@artica.es>" XML_RPC
dh-make-pear --maintainer "Pandora FMS <info@pandorafms.com>" XML_RPC
cd php-xml-rpc-*
dpkg-buildpackage -rfakeroot
cd ..

View File

@ -609,7 +609,7 @@
}
],
"description": "PHP library for ChartJS",
"homepage": "https://artica.es/",
"homepage": "https://pandorafms.com/",
"keywords": [
"chartjs",
"graph",

View File

@ -1692,3 +1692,14 @@ enterprise/godmode/modules/manage_inventory_modules_form.php
enterprise/operation/inventory/inventory.php
include/test.js
include/web2image.js
enterprise/meta/monitoring/wizard/wizard.agent.php
enterprise/meta/monitoring/wizard/wizard.create_agent.php
enterprise/meta/monitoring/wizard/wizard.create_module.php
enterprise/meta/monitoring/wizard/wizard.main.php
enterprise/meta/monitoring/wizard/wizard.manage_alert.php
enterprise/meta/monitoring/wizard/wizard.module.local.php
enterprise/meta/monitoring/wizard/wizard.module.network.php
enterprise/meta/monitoring/wizard/wizard.module.web.php
enterprise/meta/monitoring/wizard/wizard.php
enterprise/meta/monitoring/wizard/wizard.update_agent.php
enterprise/meta/monitoring/wizard/wizard.update_module.php

View File

@ -1,5 +1,23 @@
START TRANSACTION;
CREATE TABLE IF NOT EXISTS `tnetwork_explorer_filter` (
`id` INT NOT NULL,
`filter_name` VARCHAR(45) NULL,
`top` VARCHAR(45) NULL,
`action` VARCHAR(45) NULL,
`advanced_filter` TEXT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE IF NOT EXISTS `tnetwork_usage_filter` (
`id` INT NOT NULL auto_increment,
`filter_name` VARCHAR(45) NULL,
`top` VARCHAR(45) NULL,
`action` VARCHAR(45) NULL,
`advanced_filter` TEXT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tlayout`
ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`,
ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;

View File

@ -34,6 +34,22 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$notifications_numbers['notifications'],
$notifications_numbers['last_id']
).'</div>';
$header_welcome = '';
if (check_acl($config['id_user'], $group, 'AW')) {
$header_welcome .= '<div id="welcome-icon-header">';
$header_welcome .= html_print_image(
'images/wizard@svg.svg',
true,
[
'class' => 'main_menu_icon invert_filter',
'title' => __('Welcome dialog'),
'id' => 'Welcome-dialog',
'alt' => __('Welcome dialog'),
'style' => 'cursor: pointer;',
]
);
$header_welcome .= '</div>';
}
// ======= Servers List ===============================================
if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
@ -461,7 +477,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
} else {
echo '<div class="header_left"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$config['custom_subtitle_header'].'</span></div>
<div class="header_center">'.$header_searchbar.'</div>
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
}
?>
</div> <!-- Closes #table_header_inner -->
@ -904,6 +920,44 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$("#agent_access").css("display","");
});
$("#welcome-icon-header").click(function () {
if (!$('#welcome_modal_window').length){
$(document.body).append('<div id="welcome_modal_window"></div>');
$(document.body).append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'include/styles/new_installation_welcome_window.css') );
}
// Clean DOM.
load_modal({
target: $('#welcome_modal_window'),
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
modal: {
title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>",
cancel: '<?php echo __('Do not show anymore'); ?>',
ok: '<?php echo __('Close'); ?>'
},
onshow: {
page: 'include/ajax/welcome_window',
method: 'loadWelcomeWindow',
},
oncancel: {
page: 'include/ajax/welcome_window',
title: "<?php echo __('Cancel Configuration Window'); ?>",
method: 'cancelWelcome',
confirm: function (fn) {
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want to cancel this tutorial?'); ?>',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Continue execution.
fn();
}
})
}
}
});
});
<?php if (enterprise_installed()) { ?>
// Feedback.
$("#feedback-header").click(function () {

View File

@ -100,21 +100,23 @@ if ($initial && users_is_admin()) {
);
}
$welcome = !$initial;
try {
$welcome_window = new WelcomeWindow($welcome);
if ($welcome_window !== null) {
$welcome_window->run();
if (check_acl($config['id_user'], 0, 'AW')) {
$welcome = !$initial;
try {
$welcome_window = new WelcomeWindow($welcome);
if ($welcome_window !== null) {
$welcome_window->run();
}
} catch (Exception $e) {
$welcome = false;
}
} catch (Exception $e) {
$welcome = false;
}
try {
if (isset($_SESSION['showed_tips_window']) === false) {
$tips_window = new TipsWindow();
if ($tips_window !== null) {
$tips_window->run();
$tips_window->run();
}
}
} catch (Exception $e) {

View File

@ -212,7 +212,7 @@ $groups = users_get_groups($config['id_user'], 'AR', false);
// Get modules.
$modules = db_get_all_rows_sql(
'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
WHERE id_agente = '.$id_parent
WHERE id_agente = '.$id_agente
);
$modules_values = [];
$modules_values[0] = __('Any');

View File

@ -80,7 +80,7 @@ if (isset($_POST['template_id']) === true) {
$values = [
'id_agente' => $id_agente,
'id_tipo_modulo' => $row2['type'],
'descripcion' => __('Created by template ').$name_template.' . '.$row2['description'],
'descripcion' => $row2['description'],
'max' => $row2['max'],
'min' => $row2['min'],
'module_interval' => $row2['module_interval'],

View File

@ -460,6 +460,18 @@ if ($id_agente) {
$templatetab['active'] = ($tab === 'template');
// Policy tab.
$policyTab['text'] = html_print_menu_button(
[
'href' => 'index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=policy&amp;id_agente='.$id_agente,
'image' => 'images/policy@svg.svg',
'title' => __('Manage policy'),
],
true
);
$policyTab['active'] = ($tab === 'policy');
// Inventory.
$inventorytab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=inventory&id_agente='.$id_agente.'">'.html_print_image(
'images/hardware-software-component@svg.svg',
@ -638,6 +650,7 @@ if ($id_agente) {
'template' => $templatetab,
'inventory' => $inventorytab,
'pluginstab' => $pluginstab,
'policy' => (enterprise_installed() === true) ? $policyTab : '',
'collection' => $collectiontab,
'group' => $grouptab,
'gis' => $gistab,
@ -654,11 +667,11 @@ if ($id_agente) {
'template' => $templatetab,
'inventory' => $inventorytab,
'pluginstab' => $pluginstab,
'policy' => (enterprise_installed() === true) ? $policyTab : '',
'collection' => $collectiontab,
'group' => $grouptab,
'gis' => $gistab,
'agent_wizard' => $agent_wizard,
];
}
@ -725,6 +738,11 @@ if ($id_agente) {
$tab_name = __('Inventory');
break;
case 'policy':
$help_header = 'policy_tab';
$tab_name = __('Policies');
break;
case 'plugins':
$help_header = 'plugins_tab';
$tab_name = __('Agent plugins');
@ -2428,6 +2446,10 @@ switch ($tab) {
include 'inventory_manager.php';
break;
case 'policy':
enterprise_include('operation/agentes/policy_manager.php');
break;
default:
if (enterprise_hook('switch_agent_tab', [$tab])) {
// This will make sure that blank pages will have at least some

View File

@ -1072,16 +1072,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
function () {
$(".actions", this).css ("visibility", "hidden");
});
$("#ag_group").click (
function () {
$(this).css ("width", "auto");
$(this).css ("min-width", "100px");
});
$("#ag_group").blur (function () {
$(this).css ("width", "100px");
});
var show_deploy_agent = "<?php echo get_parameter('show_deploy_agent', 0); ?>";
if (show_deploy_agent !== '0'){
$('#button-modal_deploy_agent').click();
}
});
</script>

View File

@ -89,7 +89,7 @@ if (is_ajax() === true) {
[
'id' => 'agent_modules_affected_planned_downtime',
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'godmode/agentes/planned_downtime.list',

View File

@ -40,6 +40,8 @@ $table->size = [];
$table->style[0] = 'width: 50%';
$table->style[1] = 'width: 50%';
$modules = [];
if (is_metaconsole() === true) {
$params = [];
$params['return'] = true;
@ -79,8 +81,6 @@ if (is_metaconsole() === true) {
}
}
$modules = [];
$table->data[0][1] = html_print_label_input_block(
__('Module'),
html_print_select(

View File

@ -184,7 +184,7 @@ if (empty($result) === false) {
]
).'</a>&nbsp;&nbsp;';
$data[1] .= '<a href="index.php?sec=advanced&sec2=godmode/category/category&delete_category='.$category['id'].'&pure='.(int) $config['pure'].'"onclick="if (! confirm (\''.__('Are you sure?').'\')) return false">'.html_print_image(
'images/delet.svg',
'images/delete.svg',
true,
[
'title' => __('Delete'),

View File

@ -187,7 +187,7 @@ try {
[
'id' => 'list_agents_tactical',
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $columnNames,
'return' => true,

View File

@ -86,31 +86,39 @@ if ($do_operation) {
$groups = users_get_groups();
$table = new stdClass();
$table->class = 'databox filters';
$table->width = '100%';
$table->data = [];
$table->style = [];
$table->style[0] = 'font-weight: bold;';
$table->style[2] = 'font-weight: bold';
$table->style[4] = 'font-weight: bold';
$table->style[6] = 'font-weight: bold';
// Source selection
$table->id = 'source_table';
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(
false,
'AW',
true,
'source_id_group',
$source_id_group,
false,
'',
'',
true
$table->class = 'databox filters filter-table-adv';
$table->width = '100%';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = [];
// Source selection.
$table->data[0][0] = html_print_label_input_block(
__('Group'),
html_print_select_groups(
false,
'AW',
true,
'source_id_group',
$source_id_group,
false,
'',
'',
true,
false,
false,
'w100p',
false,
'width:100%'
)
);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox('source_recursion', 1, $source_recursion, true, false);
$table->data[0][1] = html_print_label_input_block(
__('Group recursion'),
html_print_checkbox('source_recursion', 1, $source_recursion, true, false)
);
$status_list = [];
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
@ -118,37 +126,52 @@ $status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[0][4] = __('Status');
$table->data[0][5] = html_print_select(
$status_list,
'status_agents_source',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true
$table->data[1][0] = html_print_label_input_block(
__('Status'),
html_print_select(
$status_list,
'status_agents_source',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true,
false,
true,
'w100p'
)
);
$table->data[0][6] = __('Agent');
$table->data[0][6] .= ' <span id="source_agent_loading" class="invisible">';
$table->data[0][6] .= html_print_image('images/spinner.png', true);
$table->data[0][6] .= '</span>';
// $table->data[0][7] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"),
// 'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
$agents = ( $source_id_group ? agents_get_group_agents($source_id_group, false, 'none') : agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false))) );
$table->data[0][7] = html_print_select($agents, 'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
echo '<form '.'action="index.php?'.'sec=gmassive&'.'sec2=godmode/massive/massive_operations&'.'option=copy_modules" '.'id="manage_config_form" '.'method="post">';
$table->data[1][1] = html_print_label_input_block(
__('Agent').' <span id="source_agent_loading" class="invisible">'.html_print_image('images/spinner.png', true).'</span>',
html_print_select(
$agents,
'source_id_agent',
$source_id_agent,
false,
__('Select'),
0,
true
)
);
echo '<form action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=copy_modules" id="manage_config_form" method="post" class="max_floating_element_size">';
echo '<fieldset id="fieldset_source">';
echo '<legend>';
echo '<span>'.__('Source');
echo '</legend>';
echo '<legend><span>'.__('Source').'</span></legend>';
html_print_table($table);
echo '</fieldset>';
// Target selection
unset($table);
// Target selection.
$table = new stdClass();
$table->id = 'target_table';
$table->class = 'databox filters';
$table->class = 'databox filters filter-table-adv';
$table->width = '100%';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = [];
$modules = [];
@ -169,66 +192,64 @@ foreach ($agent_alerts as $alert) {
}
$tags = tags_get_user_tags();
$table->data['tags'][0] = __('Tags');
$table->data['tags'][1] = html_print_select(
$tags,
'tags[]',
$tags_name,
false,
__('Any'),
-1,
true,
true,
true
$table->colspan[0][0] = 2;
$table->data[0][0] = html_print_label_input_block(
__('Tags'),
html_print_select(
$tags,
'tags[]',
$tags_name,
false,
__('Any'),
-1,
true,
true,
true,
'',
false,
'overflow-x: hidden;white-space: nowrap;max-width: 1136px;'
)
);
$table->data['operations'][0] = __('Operations');
$table->data['operations'][1] = '<span class="with_modules'.(empty($modules) ? ' invisible' : '').'">';
$table->data['operations'][1] .= html_print_checkbox('copy_modules', 1, true, true);
$table->data['operations'][1] .= html_print_label(__('Copy modules'), 'checkbox-copy_modules', true);
$table->data['operations'][1] .= '</span><br />';
$table->data['operations'][1] .= '<span class="with_alerts'.(empty($alerts) ? ' invisible' : '').'">';
$table->data['operations'][1] .= html_print_checkbox('copy_alerts', 1, true, true);
$table->data['operations'][1] .= html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true);
$table->data['operations'][1] .= '</span>';
$table->data['form_modules_filter'][0] = __('Filter Modules');
$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true);
$table->data[1][0] = __('Modules');
$table->data[1][1] = '<span class="with_modules'.(empty($modules) ? ' invisible' : '').'">';
$table->data[1][1] .= html_print_select(
$modules,
'target_modules[]',
0,
false,
'',
'',
true,
true
$table->data[1][0] = html_print_label_input_block(
__('Operations'),
'<span class="with_modules'.(empty($modules) ? ' invisible' : '').'">'.html_print_checkbox('copy_modules', 1, true, true).html_print_label(__('Copy modules'), 'checkbox-copy_modules', true).'</span><span class="with_alerts'.(empty($alerts) ? ' invisible' : '').'">'.html_print_checkbox('copy_alerts', 1, true, true).html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true).'</span>'
);
$table->data[1][1] .= '</span>';
$table->data[1][1] .= '<span class="without_modules'.(! empty($modules) ? ' invisible' : '').'">';
$table->data[1][1] .= '<em>'.__('No modules for this agent').'</em>';
$table->data[1][1] .= '</span>';
$table->data[2][0] = __('Alerts');
$table->data[2][1] = '<span class="with_alerts'.(empty($alerts) ? ' invisible' : '').'">';
$table->data[2][1] .= html_print_select(
$alerts,
'target_alerts[]',
0,
false,
'',
'',
true,
true
$table->data[1][1] = html_print_label_input_block(
__('Filter Modules'),
html_print_input_text('filter_modules', '', '', 20, 255, true)
);
$table->colspan[2][0] = 2;
$table->data[2][0] = html_print_label_input_block(
__('Modules'),
'<span class="with_modules'.(empty($modules) ? ' invisible' : '').'">'.html_print_select(
$modules,
'target_modules[]',
0,
false,
'',
'',
true,
true
).'</span><span class="without_modules'.(! empty($modules) ? ' invisible' : '').'"><em>'.__('No modules for this agent').'</em></span>'
);
$table->colspan[3][0] = 2;
$table->data[3][0] = html_print_label_input_block(
__('Alerts'),
'<span class="with_alerts'.(empty($alerts) ? ' invisible' : '').'">'.html_print_select(
$alerts,
'target_alerts[]',
0,
false,
'',
'',
true,
true
).'</span><span class="without_alerts'.(! empty($modules) ? ' invisible' : '').'"><em>'.__('No alerts for this agent').'</em></span>'
);
$table->data[2][1] .= '</span>';
$table->data[2][1] .= '<span class="without_alerts'.(! empty($modules) ? ' invisible' : '').'">';
$table->data[2][1] .= '<em>'.__('No alerts for this agent').'</em>';
$table->data[2][1] .= '</span>';
echo '<div id="modules_loading" class="loading invisible">';
html_print_image('images/spinner.png');
@ -240,35 +261,50 @@ echo '<legend><span>'.__('Targets').'</span></legend>';
html_print_table($table);
echo '</fieldset>';
// Destiny selection
unset($table);
// Destiny selection.
$table = new stdClass();
$table->id = 'destiny_table';
$table->class = 'databox filters';
$table->class = 'databox filters filter-table-adv';
$table->width = '100%';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = [];
$table->size[0] = '20%';
$table->size[1] = '30%';
$table->size[2] = '20%';
$table->size[3] = '30%';
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(
false,
'AW',
true,
'destiny_id_group',
$destiny_id_group,
false,
'',
'',
true
$table->data[0][0] = html_print_label_input_block(
__('Group'),
html_print_select_groups(
false,
'AW',
true,
'destiny_id_group',
$destiny_id_group,
false,
'',
'',
true,
false,
false,
'w100p',
false,
'width:100%'
)
);
$table->data[0][2] = __('Group recursion');
$table->data[0][3] = html_print_checkbox(
'destiny_recursion',
1,
$destiny_recursion,
true,
false
$table->data[0][1] = html_print_label_input_block(
__('Group recursion'),
html_print_checkbox(
'destiny_recursion',
1,
$destiny_recursion,
true,
false
)
);
$table->data[1][0] = html_print_label_input_block(
__('Filter Agents'),
html_print_input_text('filter_agents', '', '', 20, 255, true)
);
$status_list = [];
@ -278,32 +314,30 @@ $status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select(
$status_list,
'status_agents_destiny',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true
$table->data[1][1] = html_print_label_input_block(
__('Status'),
html_print_select(
$status_list,
'status_agents_destiny',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true
)
);
$table->data['form_agents_filter'][0] = __('Filter Agents');
$table->data['form_agents_filter'][1] = html_print_input_text('filter_agents', '', '', 20, 255, true);
$table->data[2][0] = __('Agent');
$table->data[2][0] .= '<span id="destiny_agent_loading" class="invisible">';
$table->data[2][0] .= html_print_image('images/spinner.png', true);
$table->data[2][0] .= '</span>';
$agents = [];
if ($source_id_agent) {
$agents = ( $destiny_id_group ? agents_get_group_agents($destiny_id_group, false, 'none') : agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false))) );
unset($agents[$source_id_agent]);
}
$table->data[2][1] = html_print_select($agents, 'destiny_id_agent[]', 0, false, '', '', true, true);
$table->colspan[2][0] = 2;
$table->data[2][0] = html_print_label_input_block(
__('Agent').'<span id="destiny_agent_loading" class="invisible">'.html_print_image('images/spinner.png', true).'</span>',
html_print_select($agents, 'destiny_id_agent[]', 0, false, '', '', true, true)
);
echo '<fieldset id="fieldset_destiny"'.($source_id_agent ? '' : ' class="invisible"').'>';
echo '<legend><span>'.__('To agent(s)').'</span></legend>';

View File

@ -189,6 +189,14 @@ echo get_table_inputs_masive_agents($params);
if (is_metaconsole() === true || is_management_allowed() === true) {
attachActionButton('delete', 'delete', '100%', false, $SelectAction);
} else {
html_print_action_buttons(
'',
[
'right_content' => $SelectAction,
'class' => 'pdd_t_15px_important pdd_b_15px_important',
]
);
}
echo '</form>';

View File

@ -310,45 +310,47 @@ foreach ($module_types as $type) {
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->class = 'databox filters filter-table-adv';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = [];
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->data['selection_mode'][0] = __('Selection mode');
$table->data['selection_mode'][1] = '<span class="massive_span">'.__('Select modules first ').'</span>'.html_print_radio_button_extended('selection_mode', 'modules', '', $selection_mode, false, '', 'class="mrgn_right_40px"', true).'<br>';
$table->data['selection_mode'][1] .= '<span class="massive_span">'.__('Select agents first ').'</span>'.html_print_radio_button_extended('selection_mode', 'agents', '', $selection_mode, false, '', 'class="mrgn_right_40px"', true);
$table->rowclass['form_modules_1'] = 'select_modules_row';
$table->data['form_modules_1'][0] = __('Module type');
$table->data['form_modules_1'][0] .= '<span id="module_loading" class="invisible">';
$table->data['form_modules_1'][0] .= html_print_image('images/spinner.png', true);
$table->data['form_modules_1'][0] .= '</span>';
$types[0] = __('All');
$table->colspan['form_modules_1'][1] = 2;
$table->data['form_modules_1'][1] = html_print_select(
$types,
'module_type',
'',
false,
__('Select'),
-1,
true,
false,
true,
'',
false,
'width:100%'
$table->data[0][0] = html_print_label_input_block(
__('Selection mode'),
'<div class="flex"><span class="massive_span">'.__('Select modules first ').'</span>'.html_print_radio_button_extended('selection_mode', 'modules', '', $selection_mode, false, '', 'class="mrgn_right_40px"', true).'<br><span class="massive_span">'.__('Select agents first ').'</span>'.html_print_radio_button_extended('selection_mode', 'agents', '', $selection_mode, false, '', 'class="mrgn_right_40px"', true).'</div>'
);
$table->data['form_modules_1'][3] = __('Select all modules of this type').' '.html_print_checkbox_extended(
'force_type',
'type',
'',
'',
false,
'class="mrgn_right_40px"',
true,
''
$table->rowclass[1] = 'select_modules_row';
$types[0] = __('All');
$table->data[1][0] = html_print_label_input_block(
__('Module type').'<span id="module_loading" class="invisible">'.html_print_image('images/spinner.png', true).'</span>',
html_print_select(
$types,
'module_type',
'',
false,
__('Select'),
-1,
true,
false,
true,
'',
false,
'width:100%'
)
);
$table->data[1][1] = html_print_label_input_block(
__('Select all modules of this type'),
html_print_checkbox_extended(
'force_type',
'type',
'',
'',
false,
'class="mrgn_right_40px"',
true,
''
)
);
$modules = [];
@ -368,52 +370,59 @@ foreach ($names as $name) {
$modules[$name['nombre']] = $name['nombre'];
}
$table->rowclass['form_agents_1'] = 'select_agents_row';
$table->data['form_agents_1'][0] = __('Agent group');
$table->rowclass[2] = 'select_agents_row';
$groups = users_get_groups($config['id_user'], 'AW', false);
$groups[0] = __('All');
$table->colspan['form_agents_1'][1] = 2;
$table->data['form_agents_1'][1] = html_print_select_groups(
false,
'AW',
true,
'groups_select',
'',
false,
'',
'',
true
).' '.__('Group recursion').' '.html_print_checkbox('recursion', 1, false, true, false);
$table->data['form_agents_1'][3] = __('Select all modules of this group').' '.html_print_checkbox_extended(
'force_group',
'group',
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
$table->data[2][0] = html_print_label_input_block(
__('Agent group'),
html_print_select_groups(
false,
'AW',
true,
'groups_select',
'',
false,
'',
'',
true
).' '.__('Group recursion').' '.html_print_checkbox('recursion', 1, false, true, false)
);
$table->data[2][1] = html_print_label_input_block(
__('Select all modules of this group'),
html_print_checkbox_extended(
'force_group',
'group',
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
)
);
$tags = tags_get_user_tags();
$table->rowstyle['form_modules_4'] = 'vertical-align: top;';
$table->rowclass['form_modules_4'] = 'select_modules_row select_modules_row_2';
$table->data['form_modules_4'][0] = __('Tags');
$table->data['form_modules_4'][1] = html_print_select(
$tags,
'tags[]',
$tags_name,
false,
__('Any'),
-1,
true,
true,
true
$table->rowclass[3] = 'select_modules_row select_modules_row_2';
$table->colspan[3][0] = 2;
$table->data[3][0] = html_print_label_input_block(
__('Tags'),
html_print_select(
$tags,
'tags[]',
$tags_name,
false,
__('Any'),
-1,
true,
true,
true,
'',
false,
'overflow-x: hidden;white-space: nowrap;max-width: 1136px;'
)
);
$table->rowclass['form_agents_2'] = 'select_agents_row';
$table->data['form_agents_2'][0] = __('Status');
$table->colspan['form_agents_2'][1] = 2;
$status_list = [];
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_STATUS_WARNING] = __('Warning');
@ -421,166 +430,194 @@ $status_list[AGENT_STATUS_CRITICAL] = __('Critical');
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data['form_agents_2'][1] = html_print_select(
$status_list,
'status_agents',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true
$table->data[4][0] = html_print_label_input_block(
__('Module Status'),
html_print_select(
$status_list,
'status_module',
'selected',
'',
__('All'),
AGENT_MODULE_STATUS_ALL,
true,
false,
true,
'w100p',
false,
'width: 100%'
)
);
$table->data['form_agents_2'][3] = '';
$table->rowclass['form_modules_3'] = '';
$table->data['form_modules_3'][0] = __('Module Status');
$table->colspan['form_modules_3'][1] = 2;
$status_list = [];
$status_list[AGENT_MODULE_STATUS_NORMAL] = __('Normal');
$status_list[AGENT_MODULE_STATUS_WARNING] = __('Warning');
$status_list[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical');
$status_list[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
$status_list[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal');
$status_list[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
$table->data['form_modules_3'][1] = html_print_select(
$status_list,
'status_module',
'selected',
'',
__('All'),
AGENT_MODULE_STATUS_ALL,
true
$table->cellclass[4][1] = 'select_agents_row';
$table->data[4][1] = html_print_label_input_block(
__('Status'),
html_print_select(
$status_list,
'status_agents',
'selected',
'',
__('All'),
AGENT_STATUS_ALL,
true,
false,
true,
'w100p',
false,
'width: 100%'
)
);
$table->data['form_modules_3'][3] = '';
$table->rowstyle['form_modules_filter'] = 'vertical-align: top;';
$table->rowclass['form_modules_filter'] = 'select_modules_row select_modules_row_2';
$table->data['form_modules_filter'][0] = __('Filter Modules');
$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true);
$table->rowstyle['form_modules_2'] = 'vertical-align: top;';
$table->rowclass['form_modules_2'] = 'select_modules_row select_modules_row_2';
$table->data['form_modules_2'][0] = __('Modules');
$table->data['form_modules_2'][1] = html_print_select(
$modules,
'module_name[]',
$module_name,
false,
__('Select'),
-1,
true,
true,
true,
'',
false,
'width:100%'
).' '.__('Select all modules').' '.html_print_checkbox('select_all_modules', 1, false, true, false, '', false, "class='static'");
$table->data['form_modules_2'][2] = __('When select modules');
$table->data['form_modules_2'][2] .= '<br>';
$table->data['form_modules_2'][2] .= html_print_select(
[
'common' => __('Show common agents'),
'all' => __('Show all agents'),
],
'agents_selection_mode',
'common',
false,
'',
'',
true,
false,
true,
'',
false
$table->rowclass[5] = 'select_modules_row select_modules_row_2';
$table->data[5][0] = html_print_label_input_block(
__('Filter Modules'),
html_print_input_text('filter_modules', '', '', 20, 255, true)
);
$table->data['form_modules_2'][3] = html_print_select(
[],
'agents[]',
$agents_select,
false,
__('None'),
0,
true,
true,
false,
'',
false,
'width:100%'
$table->data[5][1] = html_print_label_input_block(
__('When select modules'),
html_print_select(
[
'common' => __('Show common agents'),
'all' => __('Show all agents'),
],
'agents_selection_mode',
'common',
false,
'',
'',
true,
false,
true,
'w100p',
false,
'width:100%'
)
);
$table->rowclass[6] = 'select_modules_row select_modules_row_2';
$table->data[6][0] = html_print_label_input_block(
__('Modules'),
html_print_select(
$modules,
'module_name[]',
$module_name,
false,
__('Select'),
-1,
true,
true,
true,
'',
false,
'width:100%'
).' '.__('Select all modules').' '.html_print_checkbox('select_all_modules', 1, false, true, false, '', false, "class='static'")
);
$table->data[6][1] = html_print_label_input_block(
__('Agents'),
html_print_select(
[],
'agents[]',
$agents_select,
false,
__('None'),
0,
true,
true,
false,
'',
false,
'width:100%'
)
);
$tags = tags_get_user_tags();
$table->rowstyle['form_agents_4'] = 'vertical-align: top;';
$table->rowclass['form_agents_4'] = 'select_agents_row select_agents_row_2';
$table->data['form_agents_4'][0] = __('Tags');
$table->data['form_agents_4'][1] = html_print_select(
$tags,
'tags[]',
$tags_name,
false,
__('Any'),
-1,
true,
true,
true
$table->rowclass[7] = 'select_agents_row select_agents_row_2';
$table->colspan[7][0] = 2;
$table->data[7][0] = html_print_label_input_block(
__('Tags'),
html_print_select(
$tags,
'tags[]',
$tags_name,
false,
__('Any'),
-1,
true,
true,
true,
'',
false,
'overflow-x: hidden;white-space: nowrap;max-width: 1136px;'
)
);
$table->rowstyle['form_agents_filter'] = 'vertical-align: top;';
$table->rowclass['form_agents_filter'] = 'select_agents_row select_agents_row_2';
$table->data['form_agents_filter'][0] = __('Filter Agents');
$table->data['form_agents_filter'][1] = html_print_input_text('filter_agents', '', '', 20, 255, true);
$table->rowstyle['form_agents_3'] = 'vertical-align: top;';
$table->rowclass['form_agents_3'] = 'select_agents_row select_agents_row_2';
$table->data['form_agents_3'][0] = __('Agents');
$table->data['form_agents_3'][1] = html_print_select(
$agents,
'id_agents[]',
$agents_id,
false,
'',
'',
true,
true,
false,
'',
false,
'width:100%'
).' '.__('Select all agents').' '.html_print_checkbox('select_all_agents', 1, false, true, false, '', false, "class='static'");
$table->data['form_agents_3'][2] = __('When select agents');
$table->data['form_agents_3'][2] .= '<br>';
$table->data['form_agents_3'][2] .= html_print_select(
[
'common' => __('Show common modules'),
'all' => __('Show all modules'),
'unknown' => __('Show unknown and not init modules'),
],
'modules_selection_mode',
'common',
false,
'',
'',
true
);
$table->data['form_agents_3'][3] = html_print_select(
[],
'module[]',
$modules_select,
false,
'',
'',
true,
true,
false,
'',
false,
'width:100%'
$table->rowclass[8] = 'select_agents_row select_agents_row_2';
$table->data[8][0] = html_print_label_input_block(
__('Filter Agents'),
html_print_input_text('filter_agents', '', '', 20, 255, true)
);
$table->data[8][1] = html_print_label_input_block(
__('When select agents'),
html_print_select(
[
'common' => __('Show common modules'),
'all' => __('Show all modules'),
'unknown' => __('Show unknown and not init modules'),
],
'modules_selection_mode',
'common',
false,
'',
'',
true,
false,
true,
'w100p',
false,
'width: 100%'
)
);
$table->rowclass[9] = 'select_agents_row select_agents_row_2';
$table->data[9][0] = html_print_label_input_block(
__('Agents'),
html_print_select(
$agents,
'id_agents[]',
$agents_id,
false,
'',
'',
true,
true,
false,
'',
false,
'width:100%;white-space: nowrap;max-width: 1136px;'
).' '.__('Select all agents').' '.html_print_checkbox('select_all_agents', 1, false, true, false, '', false, "class='static'")
);
echo '<form method="post" id="form_modules" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_modules" >';
$table->data[9][1] = html_print_label_input_block(
__('Modules'),
html_print_select(
[],
'module[]',
$modules_select,
false,
'',
'',
true,
true,
false,
'w100p',
false,
'width:100%'
)
);
echo '<form method="post" class="max_floating_element_size" id="form_modules" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_modules" >';
html_print_table($table);
attachActionButton('delete', 'delete', $table->width, false, $SelectAction);
@ -617,7 +654,9 @@ $(document).ready (function () {
$("#module_name").trigger('change');
} else {
$("#module_name option").prop('selected', false);
$("#module_name").trigger('change');
if ($('#agents_selection_mode :selected').val() === 'all'){
$("#module_name").trigger('change');
}
}
});
@ -760,14 +799,6 @@ $(document).ready (function () {
else if (this.id == "checkbox-recursion") {
$("#groups_select").trigger("change");
}
else {
if (this.checked) {
$(".select_agents_row_2").css('display', 'none');
}
else {
$(".select_agents_row_2").css('display', '');
}
}
}
);

View File

@ -174,6 +174,13 @@ if ($access_console_node === true) {
}
$sub = [];
if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
$sub['wizard']['text'] = __('Configuration wizard');
$sub['wizard']['id'] = 'conf_wizard';
$sub['wizard']['type'] = 'direct';
$sub['wizard']['subtype'] = 'nolink_no_arrow';
}
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$sub['templates']['text'] = __('Templates');
$sub['templates']['id'] = 'Templates';
@ -620,3 +627,55 @@ if ((bool) $config['pure'] === false) {
}
echo '<div id="about-div"></div>';
// Need to be here because the translate string.
if (check_acl($config['id_user'], $group, 'AW')) {
?>
<script type="text/javascript">
$("#conf_wizard").click(function() {
$("#conf_wizard").addClass("selected");
if (!$("#welcome_modal_window").length) {
$(document.body).append('<div id="welcome_modal_window"></div>');
$(document.body).append(
$('<link rel="stylesheet" type="text/css" />').attr(
"href",
"include/styles/new_installation_welcome_window.css"
)
);
}
load_modal({
target: $('#welcome_modal_window'),
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
modal: {
title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>",
cancel: '<?php echo __('Do not show anymore'); ?>',
ok: '<?php echo __('Close'); ?>'
},
onshow: {
page: 'include/ajax/welcome_window',
method: 'loadWelcomeWindow',
},
oncancel: {
page: 'include/ajax/welcome_window',
title: "<?php echo __('Cancel Configuration Window'); ?>",
method: 'cancelWelcome',
confirm: function (fn) {
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want to cancel this tutorial?'); ?>',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Continue execution.
fn();
}
})
}
}
});
});
</script>
<?php
}

View File

@ -488,14 +488,38 @@ if (!empty($graphs)) {
true
);
$ActionButtons[] = '</form>';
$offset = (int) get_parameter('offset', 0);
$block_size = (int) $config['block_size'];
$tablePagination = ui_pagination(
count($graphs),
false,
$offset,
$block_size,
true,
'offset',
false
);
}
// FALTA METER EL PRINT TABLE.
html_print_table($table);
html_print_action_buttons(
implode('', $ActionButtons),
['type' => 'form_action']
);
if (is_metaconsole() === true) {
html_print_action_buttons(
implode('', $ActionButtons),
['type' => 'form_action']
);
} else {
html_print_action_buttons(
implode('', $ActionButtons),
[
'type' => 'form_action',
'right_content' => $tablePagination,
]
);
}
}
echo '</div>';

View File

@ -38,6 +38,9 @@ require_once $config['homedir'].'/include/db/oracle.php';
// Login check.
check_login();
// Validate enterprise.
$is_enterprise = enterprise_installed();
if (! check_acl($config['id_user'], 0, 'RW')
&& ! check_acl($config['id_user'], 0, 'RM')
) {
@ -3682,25 +3685,28 @@ $class = 'databox filters';
?>
</td>
</tr>
<tr id="row_landscape" class="datos">
<td class="bolder">
<?php
echo __('Show item in landscape format (only PDF)');
<?php
if ($is_enterprise) {
?>
</td>
<td><?php html_print_checkbox_switch('landscape', 1, $landscape); ?></td>
</tr>
<tr id="row_pagebreak" class="datos">
<td class="bolder">
<tr id="row_landscape" class="datos">
<td class="bolder">
<?php
echo __('Show item in landscape format (only PDF)');
?>
</td>
<td><?php html_print_checkbox_switch('landscape', 1, $landscape); ?></td>
</tr>
<tr id="row_pagebreak" class="datos">
<td class="bolder">
<?php
echo __('Page break at the end of the item (only PDF)');
?>
</td>
<td><?php html_print_checkbox_switch('pagebreak', 1, $pagebreak); ?></td>
</tr>
<?php
echo __('Page break at the end of the item (only PDF)');
?>
</td>
<td><?php html_print_checkbox_switch('pagebreak', 1, $pagebreak); ?></td>
</tr>
}
?>
<tr id="row_agents_inventory_display_options" class="datos">
<td class="bolder">
<?php
@ -6714,6 +6720,8 @@ function chooseType() {
$("#row_agent").show();
$("#row_module").show();
$("#row_historical_db_check").hide();
period_set_value($("#hidden-period").attr('class'), 3600);
$("#row_period").find('select').val('3600').trigger('change');
break;
case 'SLA_monthly':

View File

@ -116,10 +116,13 @@ if (!$report_r && !$report_w && !$report_m) {
}
require_once $config['homedir'].'/include/functions_reports.php';
require_once $config['homedir'].'/godmode/wizards/DiscoveryTaskList.class.php';
// Load enterprise extensions.
enterprise_include('operation/reporting/custom_reporting.php');
enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('include/functions_tasklist.php');
enterprise_include_once('include/functions_cron.php');
@ -782,7 +785,7 @@ switch ($action) {
'<span class="subsection_header_title">'.__('Filters').'</span>',
'filter_form',
'',
false,
true,
false,
'',
'white-box-content',
@ -1251,7 +1254,12 @@ switch ($action) {
array_push($table->data, $data);
}
html_print_table($table);
$reports_table = '<div class="white_box">';
$reports_table .= '<span class="white_table_graph_header">'.__('Reports').'</span>';
$reports_table .= html_print_table($table, true);
$reports_table .= '<br></div>';
echo $reports_table;
$tablePagination = ui_pagination(
$total_reports,
$url,
@ -1259,7 +1267,7 @@ switch ($action) {
$pagination,
true,
'offset',
false,
false
);
} else {
ui_print_info_message(
@ -1270,6 +1278,21 @@ switch ($action) {
);
}
$discovery_tasklist = new DiscoveryTaskList();
$report_task_data = $discovery_tasklist->showListConsoleTask(true);
if (is_array($report_task_data) === true || strpos($report_task_data, 'class="nf"') === false) {
$task_table = '<div class="mrgn_top_15px white_box">';
$task_table .= '<span class="white_table_graph_header">'.__('Report tasks');
$task_table .= ui_print_help_tip(__('To schedule a report, do it from the editing view of each report.'), true);
$task_table .= '</span><div>';
$task_table .= $report_task_data;
$task_table .= '</div></div>';
echo $task_table;
} else {
ui_print_info_message($report_task_data.__('To schedule a report, do it from the editing view of each report.'));
}
if (check_acl($config['id_user'], 0, 'RW')
|| check_acl($config['id_user'], 0, 'RM')
) {

View File

@ -161,7 +161,7 @@ if ($classname_selected === null) {
$wiz_data = [];
foreach ($classes as $classpath) {
if (is_reporting_console_node() === true) {
if ($classpath !== '/var/www/html/pandora_console/godmode/wizards/DiscoveryTaskList.class.php') {
if ($classpath !== $config['homedir'].'/godmode/wizards/DiscoveryTaskList.class.php') {
continue;
}
}

View File

@ -212,7 +212,7 @@ if (isset($_GET['server']) === true) {
false,
'servers',
true,
[],
$buttons,
[
[
'link' => '',

View File

@ -560,7 +560,14 @@ if (empty($create) === false || empty($view) === false) {
// $data[0] = html_print_div(['id' => 'command_preview', 'class' => 'mono'], true);
$data[0] = html_print_label_input_block(
__('Command preview'),
html_print_div(['id' => 'command_preview', 'class' => 'mono'], true)
html_print_div(
[
'id' => 'command_preview',
'class' => 'mono',
'style' => 'max-width: 1050px;overflow-wrap: break-word;',
],
true
)
);
$table->data['plugin_preview_inputs'] = $data;
$table->colspan['plugin_preview_inputs'][0] = 2;

View File

@ -101,6 +101,13 @@ foreach ($servers as $server) {
}
}
$ext = '';
// Check for any data-type server present in servers list. If none, enable server access for first server.
if (array_search('data', array_column($servers, 'type')) === false) {
$ext = '_server';
}
foreach ($servers as $server) {
$data = [];
@ -185,14 +192,12 @@ foreach ($servers as $server) {
$data[7] = ui_print_timestamp($server['keepalive'], true);
$ext = '_server';
if ($server['type'] != 'data') {
$ext = '';
if ($server['type'] === 'data') {
$ext = '_server';
}
$safe_server_name = servers_get_name($server['id_server']);
if (($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) {
if (($ext === '_server' || $server['type'] == 'enterprise satellite')) {
if (servers_check_remote_config($safe_server_name.$ext) && enterprise_installed()) {
$names_servers[$safe_server_name] = true;
} else {
@ -253,7 +258,7 @@ foreach ($servers as $server) {
);
$data[8] .= '</a>';
if (($names_servers[$safe_server_name] === true) && ($server['type'] === 'data' || $server['type'] === 'enterprise satellite')) {
if (($names_servers[$safe_server_name] === true) && ($ext === '_server' || $server['type'] === 'enterprise satellite')) {
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext.'&tab=agent_editor').'">';
$data[8] .= html_print_image(
'images/agents@svg.svg',
@ -298,6 +303,8 @@ foreach ($servers as $server) {
unset($data[8]);
}
$ext = '';
array_push($table->data, $data);
}

View File

@ -210,7 +210,7 @@ if (is_ajax() === true) {
// Ldapsearch timeout.
// Default Ldapsearch timeout.
set_when_empty($config['ldap_searh_timeout'], 5);
set_when_empty($config['ldap_search_timeout'], 5);
$row = [];
$row['name'] = __('Ldap search timeout (secs)');
$row['control'] = html_print_input_text(
@ -558,7 +558,13 @@ echo '</form>';
if ($('input[type=checkbox][name=secondary_ldap_enabled]:checked').val() == 1) {
$("tr[id*='ldap_'][id$='_secondary']").show();
} else {
$( "tr[id*='ldap_'][id$='_secondary']" ).hide();
$( "tr[id*='ldap_'][id$='_secondary']" ).hide();
}
if ($('input[type=checkbox][name=secondary_active_directory]:checked').val() == 1) {
$("tr[id*='ad_'][id$='_secondary']").show();
} else {
$( "tr[id*='ad_'][id$='_secondary']" ).hide();
}
}
$( document ).ready(function() {

View File

@ -681,15 +681,19 @@ $table->data[$i++][] = html_print_label_input_block(
)
);
$help_tip = ui_print_help_tip(
__('This log is recommended to be DISABLED by default due to the large amount of debug data it generates.'),
true
);
$table->data[$i][] = html_print_label_input_block(
__('Enable console log'),
__('Enable console log').$help_tip,
html_print_checkbox_switch(
'console_log_enabled',
1,
$config['console_log_enabled'],
true
).ui_print_input_placeholder(
__('Log location').': pandora_console/log/console.log',
__('Log location').': /var/log/php-fpm/error.log',
true
)
);
@ -743,6 +747,16 @@ $table->data[$i][] = html_print_label_input_block(
)
);
$table->data[$i][] = html_print_label_input_block(
__('Show experimental features'),
html_print_checkbox_switch(
'show_experimental_features',
1,
$config['show_experimental_features'],
true
)
);
echo '<form class="max_floating_element_size" id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';
echo '<fieldset class="margin-bottom-10">';

View File

@ -50,7 +50,7 @@ try {
[
'id' => $tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'include/ajax/update_manager',

View File

@ -129,6 +129,11 @@ class DiscoveryTaskList extends HTML
}
$delete_console_task = (bool) get_parameter('delete_console_task');
$report_task = (bool) get_parameter('report_task', 0);
if ($report_task === true) {
$this->url = ui_get_full_url('index.php?sec=reporting&sec2=godmode/reporting/reporting_builder');
}
if ($delete_console_task === true) {
return $this->deleteConsoleTask();
}
@ -287,6 +292,10 @@ class DiscoveryTaskList extends HTML
}
$id_console_task = (int) get_parameter('id_console_task');
$report_task = (bool) get_parameter('report_task', 0);
if ($report_task === true) {
$this->url = ui_get_full_url('index.php?sec=reporting&sec2=godmode/reporting/reporting_builder');
}
if ($id_console_task != null) {
// --------------------------------
@ -352,6 +361,10 @@ class DiscoveryTaskList extends HTML
}
$id_console_task = (int) get_parameter('id_console_task');
$report_task = (bool) get_parameter('report_task', 0);
if ($report_task === true) {
$this->url = ui_get_full_url('index.php?sec=reporting&sec2=godmode/reporting/reporting_builder');
}
if ($id_console_task > 0) {
$result = db_process_sql_update(
@ -1096,9 +1109,9 @@ class DiscoveryTaskList extends HTML
*
* @return boolean Success or not.
*/
public function showListConsoleTask()
public function showListConsoleTask($report_task=false)
{
return enterprise_hook('tasklist_showListConsoleTask', [$this]);
return enterprise_hook('tasklist_showListConsoleTask', [$this, $report_task]);
}
@ -1137,6 +1150,9 @@ class DiscoveryTaskList extends HTML
case DISCOVERY_CLOUD_AWS_S3:
return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&sub=s3&page=0';
case DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE:
return 'wiz=cloud&mode=gcp&ki='.$task['auth_strings'].'&sub=compute&page=0';
default:
return 'wiz=cloud';
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="12px" height="12px" viewBox="0 0 12 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>EB094270-FB38-4A58-BE94-D40EA44EA568</title>
<g id="Agentes" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="1.a1-Agentes---Listado" transform="translate(-362.500000, -268.000000)" fill="#C1CCDC">
<g id="Contenido" transform="translate(310.000000, 188.000000)">
<g transform="translate(20.000000, 20.000000)" id="Agentes">
<g id="Content" transform="translate(29.308511, 20.000000)">
<g id="Top" transform="translate(0.191489, 0.000000)">
<g id="Icons/Light/24/example" transform="translate(3.000000, 40.000000)">
<circle id="Oval" cx="6" cy="6" r="6"></circle>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Reportes programados@svg</title>
<g id="Reportes-programados" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M8.00059781,0 C8.54059781,0 9.00059781,0.363636364 9.00059781,0.909090909 L9.00059781,4.07934284 C9.00059781,5.35207011 9.69059781,6 10.9505978,6 L14.1005978,6 C14.6405978,6 15.0005978,6.45454545 15.0005978,7 L15.0005978,16.3636364 C15.0005978,18.3636364 13.3805978,20 11.4005978,20 L5.24310254,20.0009635 C7.48899044,18.7052484 9.00059781,16.2791516 9.00059781,13.5 C9.00059781,9.35786438 5.64273343,6 1.50059781,6 C0.986687841,6 0.484850221,6.05168787 -2.12052598e-14,6.15014855 L0.000597808993,3.63636364 C0.000597808993,1.63636364 1.62059781,0 3.60059781,0 Z M10.0001439,1 L14.0005978,5 L11.0001439,5 C10.4478591,5 10.0001439,4.55228475 10.0001439,4 L10.0001439,1 Z" id="Shape" fill="#3F3F3F" transform="translate(7.500299, 10.000482) scale(-1, 1) translate(-7.500299, -10.000482) "></path>
<path d="M13.5,7 C17.0898509,7 20,9.91014913 20,13.5 C20,17.0898509 17.0898509,20 13.5,20 C9.91014913,20 7,17.0898509 7,13.5 C7,9.91014913 9.91014913,7 13.5,7 Z M14.0002191,9 C13.4873832,9 13.0647119,9.38604019 13.0069468,9.88337887 L13.0002191,10 L13.0002191,13.382 L11.4068856,14.2067645 C10.9481913,14.4361116 10.742785,14.9704208 10.9135349,15.4410874 L10.959672,15.5484052 C11.1890192,16.0070996 11.7233284,16.2125059 12.193995,16.0417559 L12.3013128,15.9956188 L14.4474327,14.8944272 C14.748574,14.7438565 14.9511225,14.4535358 14.9924154,14.1248553 L15.0002191,14 L15.0002191,10 C15.0002191,9.44771525 14.5525038,9 14.0002191,9 Z" id="Oval-2" fill="#3F3F3F"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -84,7 +84,7 @@ if ($save_log_filter) {
if ($recover_aduit_log_select) {
echo json_encode(audit_get_audit_filter_select());
echo json_encode(audit_get_audit_filter_select_fix_order());
}
if ($update_log_filter) {
@ -190,7 +190,7 @@ function show_filter() {
draggable: true,
modal: false,
closeOnEscape: true,
width: 380
width: "auto"
});
}
@ -207,12 +207,13 @@ function load_filter_values() {
},
success: function(data) {
var options = "";
console.log(data);
$.each(data,function(i,value){
if (i == 'text'){
$("#text-filter_text").val(value);
}
if (i == 'period'){
$("#text-filter_period").val(value);
$("#filter_period").val(value).change();
}
if (i == 'ip'){
$("#text-filter_ip").val(value);
@ -395,7 +396,7 @@ function save_new_filter() {
"save_log_filter" : 1,
"id_name" : $("#text-id_name").val(),
"text" : $("#text-filter_text").val(),
"period" : $("#text-filter_period").val(),
"period" : $("#filter_period :selected").val(),
"ip" : $('#text-filter_ip').val(),
"type" : $('#filter_type :selected').val(),
"user" : $('#filter_user :selected').val(),
@ -431,7 +432,7 @@ function save_update_filter() {
"update_log_filter" : 1,
"id" : $("#overwrite_filter :selected").val(),
"text" : $("#text-filter_text").val(),
"period" : $("#text-filter_period").val(),
"period" : $("#filter_period :selected").val(),
"ip" : $('#text-filter_ip').val(),
"type" : $('#filter_type :selected').val(),
"user" : $('#filter_user :selected').val(),

View File

@ -17,6 +17,8 @@ $save_custom_graph = (bool) get_parameter('save_custom_graph');
$print_custom_graph = (bool) get_parameter('print_custom_graph', false);
$print_sparse_graph = (bool) get_parameter('print_sparse_graph');
$get_graphs = (bool) get_parameter('get_graphs_container');
$width = get_parameter('width', 0);
$height = get_parameter('height', 0);
if ($save_custom_graph) {
$return = [];
@ -25,8 +27,6 @@ if ($save_custom_graph) {
$name = get_parameter('name', '');
$description = get_parameter('description', '');
$stacked = get_parameter('stacked', CUSTOM_GRAPH_LINE);
$width = get_parameter('width', 0);
$height = get_parameter('height', 0);
$events = get_parameter('events', 0);
$period = get_parameter('period', 0);
$fullscale = get_parameter('fullscale', 0);
@ -126,6 +126,8 @@ if ($print_sparse_graph) {
'force_interval' => '',
'time_interval' => 300,
'array_data_create' => 0,
'height' => $height,
'width' => $width,
];
echo grafico_modulo_sparse($params);

View File

@ -97,6 +97,21 @@ if (check_login()) {
return;
}
$id_plugin = get_parameter('id_plugin', 0);
if ($id_plugin !== 0) {
$id_module_plugin = db_get_value(
'id_plugin',
'tagente_modulo',
'id_agente_modulo',
$get_module_macros
);
if ($id_plugin !== $id_module_plugin) {
$get_plugin_macros = true;
$get_module_macros = 0;
}
}
if ($get_plugin_macros) {
if (https_is_running()) {
header('Content-type: application/json');

View File

@ -182,6 +182,7 @@ try {
if ($method == 'snmp_browser_create_modules') {
// Get target ids from form.
$use_agent_ip = get_parameter('use_agent_ip', '');
$id_items = get_parameter('id_item2', null);
$id_target = null;
if (empty($id_items) === false) {
@ -209,7 +210,8 @@ try {
$module_target,
$snmp_conf_values,
$id_target,
$server_to_exec
$server_to_exec,
$use_agent_ip
);
// Return fail modules for error/success message.

View File

@ -0,0 +1,190 @@
<?php
/**
* Extension to schedule tasks on Pandora FMS Console
*
* @category Wizard
* @package Pandora FMS
* @subpackage Host&Devices
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 PandoraFMS S.L.
* 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 '../functions.php';
require_once '../functions_welcome_wizard.php';
global $config;
$check_web = get_parameter('check_web', 0);
$check_connectivity = get_parameter('check_connectivity', 0);
$create_net_scan = get_parameter('create_net_scan', 0);
$create_mail_alert = get_parameter('create_mail_alert', 0);
$create_unknown_template_alert = get_parameter('create_unknown_template_alert', 0);
// Begin.
global $config;
if ($check_web) {
include_once '../functions_api.php';
include_once '../functions_servers.php';
$status_webserver = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_WEB], 'status')['status'];
if ($status_webserver === '1') {
$name = array_keys(servers_get_names())[0];
$id_group = get_parameter('id_group', 4);
$array_other['data'] = [
'Web monitoring',
'',
2,
$id_group,
0,
30,
30,
9,
$name,
0,
0,
0,
__('Agent Web monitoring created on welcome'),
];
$id_agent = api_set_new_agent(0, '', $array_other, '', true);
if ($id_agent > 0) {
$module_name = get_parameter('module_name', 'Web_monitoring_module');
$text_to_search = get_parameter('text_to_search', '');
$url_goliat = get_parameter('url_goliat', 'https://pandorafms.com/en/');
$module_latency = create_module_latency_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search);
$module_status = create_module_status_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search);
if ($module_latency > 0 && $module_status > 0) {
ui_print_success_message(__('Your check has been created, <a href='.ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agent).'>click here to view the data</a>. Please note that it may take a few seconds to see data if your server is busy'));
}
} else {
ui_print_error_message(__('The Name is not valid for the modules.'));
}
} else {
ui_print_error_message(__('Web server is not enabled.'));
}
}
if ($check_connectivity) {
include_once '../functions_api.php';
include_once '../functions_servers.php';
$status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status'];
$status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status'];
if ($status_newtwork === '1' && $status_pluggin === '1') {
$name = array_keys(servers_get_names())[0];
$id_group = get_parameter('id_group', 4);
$agent_name = get_parameter('agent_name', __('Agent check connectivity'));
$array_other['data'] = [
$agent_name,
'',
2,
$id_group,
0,
30,
30,
9,
$name,
0,
0,
0,
__('Basic connectivity'),
];
$id_agent = api_set_new_agent(0, '', $array_other, '', true);
if ($id_agent > 0) {
$ip_target = get_parameter('ip_target', '127.0.0.1');
$basic_network = create_module_basic_network($id_agent, $id_group, $ip_target);
$latency_network = create_module_latency_network($id_agent, $id_group, $ip_target);
$packet_lost = create_module_packet_lost($id_agent, $id_group, $ip_target);
if ($basic_network > 0 && $latency_network > 0 && $packet_lost > 0) {
ui_print_success_message(__('Your check has been created, <a href='.ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agent).'>click here to view the data</a>. Please note that it may take a few seconds to see data if your server is busy'));
}
} else {
ui_print_error_message(__('The Name is not valid for the modules.'));
}
} else {
ui_print_error_message(__('Web server is not enabled.'));
}
}
if ($create_net_scan) {
$ip_target = get_parameter('ip_target', '192.168.10.0/24');
$id_net_scan = create_net_scan($ip_target);
if ($id_net_scan > 0) {
$id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server'];
ui_print_success_message(__('Basic net created and scan in progress. <a href='.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_recon_server.'&force='.$id_net_scan).'>Click here to view the data</a>. Please note that it may take a few seconds to see data if your server is busy'));
} else {
ui_print_error_message(__('Basic net already exists. <a href='.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist').'>Click here to view the data</a>'));
}
}
if ($create_mail_alert) {
include_once '../functions_alerts.php';
$id_action = db_get_row_filter('talert_actions', ['name' => 'Email to '.$config['id_user']], 'id')['id'];
if (!$id_action) {
$al_action = alerts_get_alert_action($id);
$id_action = alerts_clone_alert_action(1, $al_action['id_group'], 'Email to '.$config['id_user']);
}
$id_alert_template = get_parameter('id_condition', 0);
$id_agent_module = get_parameter('id_agent_module', 0);
$exist = db_get_value_sql(
sprintf(
'SELECT COUNT(id)
FROM talert_template_modules
WHERE id_agent_module = %d
AND id_alert_template = %d
AND id_policy_alerts = 0
',
$id_agent_module,
$id_alert_template
)
);
if ($exist > 0) {
ui_print_error_message(__('Alert already exists. <a href='.ui_get_full_url('index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&pure=0').'>Click here to view the data</a>'));
} else {
$id = alerts_create_alert_agent_module($id_agent_module, $id_alert_template);
if ($id !== false) {
$values = [];
$values['fires_min'] = (int) get_parameter('fires_min');
$values['fires_max'] = (int) get_parameter('fires_max');
$values['module_action_threshold'] = (int) 300;
$alert_created = alerts_add_alert_agent_module_action($id, $id_action, $values);
}
}
if ($alert_created === true) {
ui_print_success_message(__('Congratulations, you have already created a simple alert. <a href='.ui_get_full_url('index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&pure=0').'>You can see it.</a> Pandora FMS alerts are very flexible, you can do many more things with them, we recommend you to read the <a href="https://pandorafms.com/manual/start?id=en/documentation/04_using/01_alerts">documentation</a> for more information. You can create advanced alerts from <a href='.ui_get_full_url('index.php?sec=galertas&sec2=godmode/alerts/alert_actions').'>here</a>.'));
}
}
if ($create_unknown_template_alert) {
if (is_array(alerts_get_alert_templates(['name' => io_safe_input('Unknown condition')]))) {
echo 1;
} else {
echo create_template_alert_unknown();
}
}

View File

@ -35,6 +35,13 @@ if (is_ajax() === false) {
}
$ajaxPage = 'include/ajax/welcome_window';
// Ajax controller.
$method = get_parameter('method', '');
if ($method === 'loadWelcomeWindow') {
unset($config['welcome_state']);
}
// Control call flow.
try {
@ -44,9 +51,6 @@ try {
exit;
}
// Ajax controller.
$method = get_parameter('method', '');
if (method_exists($welcome_actions, $method) === true) {
if ($welcome_actions->ajaxMethod($method) === true) {
$welcome_actions->{$method}();

View File

@ -129,6 +129,14 @@ if (empty($apiPassword) === true
// Compat.
$config['id_user'] = 'admin';
$correctLogin = true;
// Bypass credentials if server-auth and api-pass are correct.
} else if (($config['server_unique_identifier'] === get_parameter('server_auth'))
&& ($api_password === $apiPassword)
&& ((bool) isInACL($ipOrigin) === true)
) {
$config['id_usuario'] = 'admin';
$config['id_user'] = 'admin';
$correctLogin = true;
} else if ((bool) isInACL($ipOrigin) === true) {
// External access.
// Token is valid. Bypass the credentials.

View File

@ -237,8 +237,13 @@ function process_user_login_remote($login, $pass, $api=false)
// Active Directory.
case 'ad':
if (enterprise_hook('ad_process_user_login', [$login, $pass]) === false) {
$config['auth_error'] = 'User not found in database or incorrect password';
$sr = enterprise_hook('ad_process_user_login', [$login, $pass]);
// Try with secondary server.
if ($sr === false && (bool) $config['secondary_active_directory'] === true) {
$sr = enterprise_hook('ad_process_user_login', [$login, $pass, true]);
}
if ($sr === false) {
return false;
}
break;

View File

@ -165,6 +165,9 @@ $hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.symbol.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.exportdata.pandora.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.axislabels.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script type="text/javascript">
var phpTimezone = "<?php echo date_default_timezone_get(); ?>";
</script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/pandora.flot.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/chartjs/chart.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/chartjs/chartjs-plugin-datalabels.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>

View File

@ -178,7 +178,7 @@ class AuditLog extends HTML
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,
@ -469,7 +469,7 @@ class AuditLog extends HTML
success: function(data) {
var options = "";
$.each(data,function(key,value){
options += "<option value='"+key+"'>"+value+"</option>";
options += "<option value='"+value+"'>"+key+"</option>";
});
$('#overwrite_filter').html(options);
$('#overwrite_filter').select2();
@ -509,8 +509,12 @@ class AuditLog extends HTML
/* Filter management */
$('#button-load-filter').click(function (){
if($('#load-filter-select').length) {
$('#load-filter-select').dialog({width: "20%",
maxWidth: "25%",
$('#load-filter-select').dialog({
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
width: "auto",
title: "<?php echo __('Load filter'); ?>"
});
$.ajax({
@ -523,8 +527,9 @@ class AuditLog extends HTML
},
success: function(data) {
var options = "";
console.log(data)
$.each(data,function(key,value){
options += "<option value='"+key+"'>"+value+"</option>";
options += "<option value='"+value+"'>"+key+"</option>";
});
$('#filter_id').html(options);
$('#filter_id').select2();

View File

@ -1040,7 +1040,7 @@ class CalendarManager
'id' => 'templates_alerts_special_days',
'return' => true,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'godmode/alerts/alert_special_days',

View File

@ -612,7 +612,7 @@ class ConfigPEN extends HTML
'id' => $tableId,
'return' => true,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,

View File

@ -1807,7 +1807,8 @@ class ConsoleSupervisor
$this->cleanNotifications('NOTIF.PHP.SERIALIZE_PRECISION');
}
if (version_compare('8.1', PHP_VERSION) >= 0) {
// If PHP_VERSION is lower than 8.0.27 version_compare() returns 1.
if (version_compare('8.0.27', PHP_VERSION) === 1) {
$url = 'https://www.php.net/supported-versions.php';
$this->notify(
[

View File

@ -827,7 +827,7 @@ class CredentialStore extends Wizard
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,

View File

@ -1579,7 +1579,7 @@ class Diagnostics extends Wizard
[
'id' => $tableId,
'class' => 'info_table caption_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $columnNames,
'ajax_data' => [
@ -1591,6 +1591,7 @@ class Diagnostics extends Wizard
'no_sortable_columns' => [-1],
'caption' => $title,
'print' => true,
'mini_csv' => true,
]
);
} else {

View File

@ -320,7 +320,7 @@ class EventSound extends HTML
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,

View File

@ -162,7 +162,7 @@ class SatelliteAgent extends HTML
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,

View File

@ -142,7 +142,7 @@ class SatelliteCollection extends HTML
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,

View File

@ -326,7 +326,7 @@ class SnmpConsole extends HTML
[
'id' => $tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,

View File

@ -475,7 +475,7 @@ class TipsWindow
[
'id' => 'list_tips_windows',
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'dom_elements' => 'lpfti',
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
'columns' => $columns,

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC230712';
$build_version = 'PC230725';
$pandora_version = 'v7.0NG.772';
// Do not overwrite default timezone set if defined.

View File

@ -4348,6 +4348,11 @@ function generator_chart_to_pdf(
curl_close($curl);
$page->setHtml($response);
/*
//For debug url with parameters.
$navigation = $page->navigate($url.'?data='.urlencode(json_encode($data)));
$navigation->waitForNavigation(Page::DOM_CONTENT_LOADED);
*/
// Dynamic.
$dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue();

View File

@ -2770,6 +2770,69 @@ function agents_delete_agent($id_agents, $disableACL=false)
enterprise_include_once('include/functions_agents.php');
enterprise_hook('agent_delete_from_cache', [$id_agent]);
// Delete agent from visual console.
db_process_sql_delete(
'tlayout_data',
['id_agent' => $id_agent]
);
// Delete agent from visual dashboards.
db_process_sql(
'UPDATE twidget_dashboard
SET options = NULL
WHERE options LIKE ("%\"agentid\":\"'.$id_agent.'\"%")'
);
// Delete agent from treport.
db_process_sql_delete(
'treport_content',
['id_agent' => $id_agent]
);
// Delete rules from tevent alerts (correlative alerts)
db_process_sql_delete(
'tevent_rule',
[
'agent' => $id_agent,
'operator_agent' => '==',
]
);
db_process_sql_delete(
'tevent_rule',
[
'log_agent' => $id_agent,
'operator_log_agent' => '==',
]
);
// Delete from gis maps history
db_process_sql_delete(
'tgis_data_history',
['tagente_id_agente' => $id_agent]
);
// Delete from policies.
db_process_sql_delete(
'tpolicy_agents',
['id_agent' => $id_agent]
);
// Delete from tnetwork maps
db_process_sql_delete(
'titem',
['source_data' => $id_agent]
);
db_process_sql_delete(
'trel_item',
[
'id_parent_source_data' => $id_agent,
'id_child_source_data' => $id_agent,
],
'OR'
);
// Delete agent from fav menu.
db_process_sql_delete(
'tfavmenu_user',

View File

@ -455,7 +455,7 @@ function alerts_delete_alert_action($id_alert_action)
*
* @return mixed Id of the cloned action or false in case of fail.
*/
function alerts_clone_alert_action($id_alert_action, $id_group)
function alerts_clone_alert_action($id_alert_action, $id_group, $copy_name='')
{
$id_alert_action = safe_int($id_alert_action, 1);
if (empty($id_alert_action)) {
@ -474,7 +474,13 @@ function alerts_clone_alert_action($id_alert_action, $id_group)
unset($action['id']);
return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action);
if ($copy_name !== '') {
$copy_name = $copy_name;
} else {
$copy_name = $action['name'].' '.__('copy');
}
return alerts_create_alert_action($copy_name, $action['id_alert_command'], $action);
}

View File

@ -1916,7 +1916,7 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
*
* @param $thrash3 Don't use.
*/
function api_set_new_agent($id_node, $thrash2, $other, $trhash3)
function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false)
{
global $config;
@ -2038,13 +2038,17 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3)
}
}
returnData(
'string',
[
'type' => 'string',
'data' => $id_agente,
]
);
if ($return === false) {
returnData(
'string',
[
'type' => 'string',
'data' => $id_agente,
]
);
} else {
return $id_agente;
}
} catch (\Exception $e) {
returnError($e->getMessage());
return;

View File

@ -378,6 +378,10 @@ function config_update_config()
$error_update[] = __('keep_in_process_status_extra_id');
}
if (config_update_value('show_experimental_features', get_parameter('show_experimental_features'), true) === false) {
$error_update[] = __('show_experimental_features');
}
if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) {
$error_update[] = __('Console log enabled');
}
@ -627,6 +631,30 @@ function config_update_config()
$error_update[] = __('Domain');
}
if (config_update_value('secondary_active_directory', get_parameter('secondary_active_directory'), true) === false) {
$error_update[] = __('Secondary active directory');
}
if (config_update_value('ad_server_secondary', get_parameter('ad_server_secondary'), true) === false) {
$error_update[] = __('Secondary active directory server');
}
if (config_update_value('ad_port_secondary', get_parameter('ad_port_secondary'), true) === false) {
$error_update[] = __('Secondary active directory port');
}
if (config_update_value('ad_start_tls_secondary', get_parameter('ad_start_tls_secondary'), true) === false) {
$error_update[] = __('Secondary start TLS');
}
if (config_update_value('ad_search_timeout', get_parameter('ad_search_timeout'), true) === false) {
$error_update[] = __('AD search timeout');
}
if (config_update_value('ad_domain_secondary', get_parameter('ad_domain_secondary'), true) === false) {
$error_update[] = __('Secondary domain');
}
if (config_update_value('ad_adv_perms', get_parameter('ad_adv_perms'), true) === false) {
$error_update[] = __('Advanced Permisions AD');
}
@ -2377,6 +2405,10 @@ function config_process_config()
config_update_value('keep_in_process_status_extra_id', 0);
}
if (!isset($config['show_experimental_features'])) {
config_update_value('show_experimental_features', 0);
}
if (!isset($config['console_log_enabled'])) {
config_update_value('console_log_enabled', 0);
}
@ -3100,6 +3132,14 @@ function config_process_config()
config_update_value('ad_port', 389);
}
if (!isset($config['ad_server_secondary'])) {
config_update_value('ad_server_secondary', 'localhost');
}
if (!isset($config['ad_port_secondary'])) {
config_update_value('ad_port_secondary', 389);
}
if (!isset($config['ad_start_tls'])) {
config_update_value('ad_start_tls', 0);
}

View File

@ -4624,7 +4624,10 @@ function graph_netflow_circular_mesh($data)
include_once $config['homedir'].'/include/graphs/functions_d3.php';
return d3_relationship_graph($data['elements'], $data['matrix'], 900, true);
$width = (empty($data['width']) === false) ? $data['width'] : 900;
$height = (empty($data['height']) === false) ? $data['height'] : 900;
return d3_relationship_graph($data['elements'], $data['matrix'], $width, true, $height);
}
@ -4983,19 +4986,18 @@ function graph_monitor_wheel($width=550, $height=600, $filter=false)
$filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false;
if ($filter['group'] != 0) {
$filter_subgroups = '';
if (!$filter['dont_show_subgroups']) {
$filter_subgroups = ' || parent IN ('.$filter['group'].')';
if ($filter['dont_show_subgroups'] === false) {
$groups = groups_get_children($filter['group']);
$groups_ax = [];
foreach ($groups as $g) {
$groups_ax[$g['id_grupo']] = $g;
}
$groups = $groups_ax;
} else {
$groups = groups_get_group_by_id($filter['group']);
$groups[$group['id_grupo']] = $group;
}
$groups = db_get_all_rows_sql('SELECT * FROM tgrupo where id_grupo IN ('.$filter['group'].') '.$filter_subgroups);
$groups_ax = [];
foreach ($groups as $g) {
$groups_ax[$g['id_grupo']] = $g;
}
$groups = $groups_ax;
} else {
$groups = users_get_groups(false, 'AR', false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null));
}

View File

@ -671,6 +671,7 @@ function html_print_select_groups(
step: params.page || 1,
strict: "<?php echo $strict_user; ?>",
not_condition: $('#not_condition_switch').prop('checked'),
returnAllGroup: <?php echo (int) $returnAllGroup; ?>
}
return query;
@ -5503,7 +5504,10 @@ function html_print_input($data, $wrapper='div', $input_only=false)
($data['attributes'] ?? null),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['password']) === true) ? $data['password'] : false),
((isset($data['function']) === true) ? $data['function'] : '')
((isset($data['function']) === true) ? $data['function'] : ''),
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : 'off'),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['hide_div_eye']) === true) ? $data['hide_div_eye'] : false),
);
break;
@ -7194,3 +7198,44 @@ function html_print_code_picker(
echo $output;
}
}
function html_print_wizard_diagnosis(
$title,
$id_button,
$description='',
$status=true,
$return=false,
) {
$button = '';
if ($status === true) {
$status = 'Connected';
$img = '/images/configuration@svg.svg';
} else {
$status = 'Disconnected';
$img = '/images/change-active.svg';
}
$button = html_print_image(
$img,
true,
[
'class' => 'main_menu_icon invert_filter float-right mrgn_right_10px',
'id' => $id_button,
]
);
$output = '<div class="rectangle rectangle_'.$status.'">
<span class="status '.$status.'">'.__($status).$button.'</span>
<div class="title">'.html_print_image('/images/circle_title.svg', true, ['class' => 'invert_filter']).'<span>'.$title.'</span></div>
<div class="description">
<span>'.$description.'</span>
</div>
</div>';
if ($return === true) {
return $output;
} else {
echo $output;
}
}

View File

@ -324,6 +324,8 @@ function menu_print_menu(&$menu)
if (isset($sub['subtype']) && $sub['subtype'] == 'nolink') {
$submenu_output .= '<div class=" SubNoLink '.$sub_tree_class.'"><span class="w70p span_has_menu_text">'.$sub['text'].'</span><div class="w21p arrow_menu_down"></div></div>';
} else if (isset($sub['subtype']) && $sub['subtype'] == 'nolink_no_arrow') {
$submenu_output .= '<div class=" SubNoLink '.$sub_tree_class.'"><span class="w70p span_has_menu_text">'.$sub['text'].'</span><div class="w21p"></div></div>';
} else if (isset($sub['subtype']) && $sub['subtype'] == 'new_blank') {
$submenu_output .= '<a href="'.$subsec2.'" target="_blank"><div class="'.$sub_tree_class.'">'.$sub['text'].'</div></a>';
} else {

View File

@ -743,7 +743,8 @@ function modules_create_agent_module(
string $name,
array $values=[],
bool $disableACL=false,
$tags=false
$tags=false,
$use_agent_ip=false,
) {
global $config;
@ -785,6 +786,10 @@ function modules_create_agent_module(
return ERR_EXIST;
}
if ($use_agent_ip === true) {
$values['ip_target'] = agents_get_address($id_agent);
}
// Encrypt passwords.
if (isset($values['plugin_pass']) === true) {
// Avoid two times encryption.

View File

@ -1233,7 +1233,9 @@ function netflow_draw_item(
$max_aggregates,
$connection_name='',
$output='HTML',
$address_resolution=false
$address_resolution=false,
$width_content=false,
$height_content=false
) {
$aggregate = $filter['aggregate'];
$interval = ($end_date - $start_date);
@ -1432,6 +1434,9 @@ function netflow_draw_item(
netflow_aggregate_is_ip($aggregate)
);
$data_circular['width'] = $width_content;
$data_circular['height'] = $height_content;
$html = '<div class="center">';
$html .= graph_netflow_circular_mesh($data_circular);
$html .= '</div>';
@ -1734,7 +1739,12 @@ function netflow_get_top_summary(
switch ($top_action) {
case 'listeners':
if (empty(!$filter)) {
$netflow_filter['ip_src'] = $filter;
if (!is_array($filter)) {
$netflow_filter['ip_src'] = $filter;
} else {
$netflow_filter['ip_src'] = $filter['ip'];
$netflow_filter['advanced_filter'] = $filter['advanced_filter'];
}
}
$sort = 'dstip';
@ -1742,7 +1752,12 @@ function netflow_get_top_summary(
case 'talkers':
if (empty(!$filter)) {
$netflow_filter['ip_dst'] = $filter;
if (!is_array($filter)) {
$netflow_filter['ip_dst'] = $filter;
} else {
$netflow_filter['ip_dst'] = $filter['ip'];
$netflow_filter['advanced_filter'] = $filter['advanced_filter'];
}
}
$sort = 'srcip';
@ -2069,7 +2084,7 @@ function netflow_aggregate_is_ip($aggregate)
*
* @return array With map structure.
*/
function netflow_build_map_data($start_date, $end_date, $top, $aggregate)
function netflow_build_map_data($start_date, $end_date, $top, $aggregate, $advanced_filter='')
{
// Pass an empty filter data structure.
$data = netflow_get_relationships_raw_data(
@ -2083,7 +2098,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate)
'ip_src' => '',
'dst_port' => '',
'src_port' => '',
'advanced_filter' => '',
'advanced_filter' => $advanced_filter,
'router_ip' => '',
],
$top,

View File

@ -1411,3 +1411,24 @@ function servers_get_master()
return $result;
}
/**
* Return true if all servers are up.
*
* @return boolean
*/
function check_all_servers_up()
{
$status = true;
$servers = servers_get_info();
foreach ($servers as $server) {
if ($server['status'] !== '1') {
return false;
}
}
return $status;
}

View File

@ -1291,7 +1291,8 @@ function snmp_browser_create_modules_snmp(
string $module_target,
array $snmp_values,
?array $id_target,
?string $server_to_exec=null
?string $server_to_exec=null,
?string $use_agent_ip=''
) {
$target_ip = null;
$target_port = null;
@ -1350,6 +1351,12 @@ function snmp_browser_create_modules_snmp(
}
}
if (empty($use_agent_ip) === false) {
$use_agent_ip = true;
} else {
$use_agent_ip = false;
}
$fail_modules = [];
foreach ($targets_oids as $key => $target_oid) {
@ -1514,7 +1521,7 @@ function snmp_browser_create_modules_snmp(
'history_data' => 1,
];
foreach ($id_target as $agent) {
$ids[] = modules_create_agent_module($agent, $oid['oid'], $values);
$ids[] = modules_create_agent_module($agent, $oid['oid'], $values, false, false, $use_agent_ip);
}
} else if ($module_target == 'policy') {
// Policies only in enterprise version.
@ -1803,6 +1810,16 @@ function snmp_browser_print_create_module_massive(
true
);
$table->data[4][0] = html_print_label_input_block(
__('Use agent IP'),
html_print_checkbox(
'use_agent_ip',
1,
false,
true
)
);
$output .= html_print_table($table, true);
// SNMP extradata.

View File

@ -795,8 +795,14 @@ function tags_get_acl_tags(
$acltags = [];
foreach ($raw_acltags as $group => $taglist) {
if (empty($id_group) === false && array_key_exists($group, $id_group) === false) {
continue;
if ($return_mode === 'module_condition') {
if (!empty($id_group) && !in_array($group, $id_group)) {
continue;
}
} else {
if (empty($id_group) === false && array_key_exists($group, $id_group) === false) {
continue;
}
}
if (!empty($taglist)) {

View File

@ -650,16 +650,28 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
// Agent name.
$row = [];
$row['title'] = __('Agent name');
$row['data'] = html_print_anchor(
[
'href' => 'javascript:void(0)',
'title' => __('Click here for view this agent'),
'class' => 'font_11',
'content' => $cellName,
'onClick' => "sendHash('".$urlAgent."')",
],
true
);
if (is_metaconsole() === true) {
$row['data'] = html_print_anchor(
[
'href' => 'javascript:void(0)',
'title' => __('Click here for view this agent'),
'class' => 'font_11',
'content' => $cellName,
'onClick' => "sendHash('".$urlAgent."')",
],
true
);
} else {
$row['data'] = html_print_anchor(
[
'href' => $urlAgent,
'title' => __('Click here for view this agent'),
'class' => 'font_11',
'content' => $cellName,
],
true
);
}
$table->data['name'] = $row;

View File

@ -3324,6 +3324,32 @@ function ui_print_module_status(
}
/**
* Returns html code to print a shape for a module.
*
* @param integer $color Hex color.
* @param boolean $return True or false.
* @param string $class Custom class or use defined.
* @param string $div_content Content.
*
* @return string HTML code for shape.
*/
function ui_print_diagnosis_status(
$color,
$return=false,
$class='status_rounded_rectangles',
$div_content=''
) {
$output = '<div style="background: '.$color.'" class="'.$class.'">'.$div_content.'</div>';
if ($return === false) {
echo $output;
}
return $output;
}
/**
* Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status.
*
@ -3716,28 +3742,71 @@ function ui_progress_extend(
* Generate needed code to print a datatables jquery plugin.
*
* @param array $parameters All desired data using following format:
* [
* 'print' => true (by default printed)
* 'id' => datatable id.
* 'class' => datatable class.
* 'style' => datatable style.
* 'order' => [
* 'field' => column name
* 'direction' => asc or desc
* ],
* 'default_pagination' => integer, default pagination is set to block_size
* 'ajax_url' => 'include/ajax.php' ajax_url.
* 'ajax_data' => [ operation => 1 ] extra info to be sent.
* 'ajax_postprocess' => a javscript function to postprocess data received
* by ajax call. It is applied foreach row and must
* use following format:
* * [code]
* * function (item) {
* * // Process received item, for instance, name:
* * tmp = '<span class=label>' + item.name + '</span>';
* * item.name = tmp;
* * }
* * [/code]
*
* ```php
* $parameters = [
* // JS Parameters
* 'serverside' => true,
* 'paging' => true,
* 'default_pagination' => $config['block_size'],
* 'searching' => false,
* 'dom_elements' => "plfrtiB",
* 'pagination_options' => [default_pagination, 5, 10, 20, 100, 200, 500, 1000, "All"],
* 'ordering' => true,
* 'order' => [[0, "asc"]], //['field' => 'column_name', 'direction' => 'asc/desc']
* 'zeroRecords' => "No matching records found",
* 'emptyTable' => "No data available in table",
* 'no_sortable_columns' => [], //Allows the column name (db) from "columns" parameter
* 'csv_field_separator' => ",",
* 'csv_header' => true,
* 'mini_csv' => false,
* 'mini_pagination' => false,
* 'mini_search' => false,
* 'drawCallback' => undefined, //'console.log(123),'
* 'data_element' => undefined, //Rows processed
* 'ajax_postprocess' => undefined, //'process_datatables_item(item)'
* 'ajax_data' => undefined, //Extra data to be sent ['field1' => 1, 'field2 => 0]
* 'ajax_url' => undefined,
* 'caption' => undefined,
*
* // PHP Parameters
* 'id' => undefined, //Used for table and form id,
* 'columns' =>,
* 'column_names' =>,
* 'filter_main_class' =>,
* 'toggle_collapsed' =>true,
* 'search_button_class' => 'sub filter',
* 'csv' =>=1,
* 'form' =>
* ..[
* ....'id' => $form_id,
* ....'class' => 'flex-row',
* ....'style' => 'width: 100%,',
* ....'js' => '',
* ....'html' => $filter,
* ....'inputs' => [],
* ....'extra_buttons' => $buttons,
* ..],
* 'no_toggle' => false,
* 'form_html' => undefined,
* 'toggle_collapsed' => true,
* 'class' => "", //Datatable class.
* 'style' => "" ,//Datatable style.
* 'return' => false,
* 'print' => true,
* ]
*
* ```
*
* ```php
* ajax_postprocess => a javscript function to postprocess data received
* by ajax call. It is applied foreach row and must
* use following format:
* function (item) {
* // Process received item, for instance, name:
* tmp = '<span class=label>' + item.name + '</span>';
* item.name = tmp;
* }
* 'columns_names' => [
* 'column1' :: Used as th text. Direct text entry. It could be array:
* OR
@ -3754,7 +3823,6 @@ function ui_progress_extend(
* 'column2',
* ...
* ],
* 'no_sortable_columns' => [ indexes ] 1,2... -1 etc. Avoid sorting.
* 'form' => [
* 'html' => 'html code' a directly defined inputs in HTML.
* 'extra_buttons' => [
@ -3786,12 +3854,7 @@ function ui_progress_extend(
* ]
* ],
* 'extra_html' => HTML content to be placed after 'filter' section.
* 'drawCallback' => function to be called after draw. Sample in:
* https://datatables.net/examples/advanced_init/row_grouping.html
* ]
* 'zeroRecords' => Message when zero records obtained from filter.(Leave blank for default).
* 'emptyTable' => Message when table data empty.(Leave blank for default).
* End.
* ```
*
* @return string HTML code with datatable.
* @throws Exception On error.
@ -3808,6 +3871,9 @@ function ui_print_datatable(array $parameters)
$form_id = uniqid('datatable_filter_');
}
$parameters['table_id'] = $table_id;
$parameters['form_id'] = $form_id;
if (!isset($parameters['columns']) || !is_array($parameters['columns'])) {
throw new Exception('[ui_print_datatable]: You must define columns for datatable');
}
@ -3827,10 +3893,6 @@ function ui_print_datatable(array $parameters)
$parameters['default_pagination'] = $config['block_size'];
}
if (!isset($parameters['paging'])) {
$parameters['paging'] = true;
}
if (!isset($parameters['filter_main_class'])) {
$parameters['filter_main_class'] = '';
}
@ -3839,13 +3901,9 @@ function ui_print_datatable(array $parameters)
$parameters['toggle_collapsed'] = true;
}
$no_sortable_columns = json_encode([]);
if (isset($parameters['no_sortable_columns'])) {
$no_sortable_columns = json_encode($parameters['no_sortable_columns']);
}
if (!is_array($parameters['order'])) {
$order = '0, "asc"';
$order = 0;
$direction = 'asc';
} else {
if (!isset($parameters['order']['direction'])) {
$direction = 'asc';
@ -3864,47 +3922,35 @@ function ui_print_datatable(array $parameters)
}
}
$order .= ', "'.$parameters['order']['direction'].'"';
$direction = $parameters['order']['direction'];
}
if (!isset($parameters['ajax_data'])) {
$parameters['ajax_data'] = '';
$parameters['order']['order'] = $order;
$parameters['order']['direction'] = $direction;
foreach ($parameters['no_sortable_columns'] as $key => $find) {
$found = array_search(
$parameters['no_sortable_columns'][$key],
$parameters['columns']
);
if ($found !== false) {
unset($parameters['no_sortable_columns'][$key]);
array_push($parameters['no_sortable_columns'], $found);
}
if (is_int($parameters['no_sortable_columns'][$key]) === false) {
unset($parameters['no_sortable_columns'][$key]);
}
}
$search_button_class = 'sub filter';
$parameters['csvTextInfo'] = __('Export current page to CSV');
$parameters['csvFileTitle'] = sprintf(__('export_%s_current_page_%s'), $table_id, date('Y-m-d'));
if (isset($parameters['search_button_class'])) {
$search_button_class = $parameters['search_button_class'];
}
if (isset($parameters['pagination_options'])) {
$pagination_options = $parameters['pagination_options'];
} else {
$pagination_options = [
[
// There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows.
// -1 Retun error or only 1 row.
$parameters['default_pagination'],
5,
10,
25,
100,
200,
500,
1000,
18446744073709551615,
],
[
$parameters['default_pagination'],
5,
10,
25,
100,
200,
500,
1000,
'All',
],
];
$search_button_class = 'sub filter';
}
if (isset($parameters['datacolumns']) === false
@ -3917,16 +3963,12 @@ function ui_print_datatable(array $parameters)
$parameters['csv'] = 1;
}
$dom_elements = '"plfrtiB"';
if (isset($parameters['dom_elements'])) {
$dom_elements = '"'.$parameters['dom_elements'].'"';
}
$filter = '';
// Datatable filter.
if (isset($parameters['form']) && is_array($parameters['form'])) {
if (isset($parameters['form']['id'])) {
$form_id = $parameters['form']['id'];
$parameters['form_id'] = $form_id;
}
if (isset($parameters['form']['class'])) {
@ -4044,10 +4086,13 @@ function ui_print_datatable(array $parameters)
)
);
$processing .= '</div>';
$parameters['processing'] = $processing;
$zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found');
$emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table');
$parameters['zeroRecords'] = $zeroRecords;
$parameters['emptyTable'] = $emptyTable;
// Extra html.
$extra = '';
if (isset($parameters['extra_html']) && !empty($parameters['extra_html'])) {
@ -4056,8 +4101,8 @@ function ui_print_datatable(array $parameters)
// Base table.
$table = '<table id="'.$table_id.'" ';
$table .= 'class="'.$parameters['class'].' invisible"';
$table .= 'style="'.$parameters['style'].'">';
$table .= 'class="'.$parameters['class'].'"';
$table .= 'style="box-sizing: border-box;'.$parameters['style'].'">';
$table .= '<thead><tr class="datatables_thead_tr">';
if (isset($parameters['column_names'])
@ -4084,335 +4129,60 @@ function ui_print_datatable(array $parameters)
}
$table .= '</tr></thead>';
if (isset($parameters['data_element']) === true) {
$table .= '<tbody>';
foreach ($parameters['data_element'] as $row) {
$table .= '<tr>';
foreach ($row as $td_data) {
$table .= '<td>'.$td_data.'</td>';
}
$table .= '</tr>';
}
$table .= '</tbody>';
$js = '<script>
$.fn.dataTable.ext.classes.sPageButton = "pandora_pagination mini-pandora-pagination"
var table = $("#'.$table_id.'").DataTable({
"dom": "'.$parameters['dom_elements'].'"
});
$("div.spinner-fixed").hide();
$("table#'.$table_id.'").removeClass("invisible");
$("#'.$table_id.'_filter > label > input").addClass("mini-search-input");
if (table.page.info().pages == 1) {
$("#'.$table_id.'_paginate").hide();
}
</script>';
}
$table .= '</table>';
$pagination_class = 'pandora_pagination';
if (!empty($parameters['pagination_class'])) {
$pagination_class = $parameters['pagination_class'];
$parameters['ajax_url_full'] = ui_get_full_url('ajax.php', false, false, false);
$parameters['spinnerLoading'] = html_print_image(
'images/spinner.gif',
true,
[
'id' => $form_id.'_loading',
'class' => 'loading-search-datatables-button',
]
);
$language = substr(get_user_language(), 0, 2);
if (is_metaconsole() === false) {
$parameters['language'] = 'include/javascript/i18n/dataTables.'.$language.'.json';
} else {
$parameters['language'] = '../../include/javascript/i18n/dataTables.'.$language.'.json';
}
$columns = '';
for ($i = 1; $i <= (count($parameters['columns']) - 3); $i++) {
if ($i != (count($parameters['columns']) - 3)) {
$columns .= $i.',';
} else {
$columns .= $i;
}
$parameters['phpDate'] = date('Y-m-d');
$parameters['dataElements'] = json_encode($parameters['data_element']);
// * START JAVASCRIPT.
if (is_metaconsole() === false) {
$file_path = ui_get_full_url('include/javascript/datatablesFunction.js');
} else {
$file_path = ui_get_full_url('../../include/javascript/datatablesFunction.js');
}
$export_columns = '';
if (isset($parameters['csv_exclude_latest']) === true
&& $parameters['csv_exclude_latest'] === true
) {
$export_columns = ',columns: \'th:not(:last-child)\'';
}
$file_content = file_get_contents($file_path);
$json_data = json_encode($parameters);
$json_config = json_encode($config);
if (isset($parameters['data_element']) === false || isset($parameters['print_pagination_search_csv'])) {
if (isset($parameters['ajax_url'])) {
$type_data = 'ajax: {
url: "'.ui_get_full_url('ajax.php', false, false, false).'",
type: "POST",
dataSrc: function (json) {
if($("#'.$form_id.'_search_bt") != undefined) {
$("#'.$form_id.'_loading").remove();
}
$js = '<script>';
$js .= 'var dt = '.$json_data.';';
$js .= 'var config = '.$json_config.';';
$js .= '</script>';
if (json.error) {
console.error(json.error);
$("#error-'.$table_id.'").html(json.error);
$("#error-'.$table_id.'").dialog({
title: "Filter failed",
width: 630,
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
buttons: {
"Ok" : function () {
$(this).dialog("close");
}
}
}).parent().addClass("ui-state-error");
} else {';
if (isset($parameters['ajax_return_operation']) === true
&& empty($parameters['ajax_return_operation']) === false
&& isset($parameters['ajax_return_operation_function']) === true
&& empty($parameters['ajax_return_operation_function']) === false
) {
$type_data .= '
if (json.'.$parameters['ajax_return_operation'].' !== undefined) {
'.$parameters['ajax_return_operation_function'].'(json.'.$parameters['ajax_return_operation'].');
}
';
}
if (isset($parameters['ajax_postprocess'])) {
$type_data .= '
if (json.data) {
json.data.forEach(function(item) {
'.$parameters['ajax_postprocess'].'
});
} else {
json.data = {};
}';
}
$type_data .= '
return json.data;
}
},
data: function (data) {
if($("#button-'.$form_id.'_search_bt") != undefined) {
var loading = \''.html_print_image(
'images/spinner.gif',
true,
[
'id' => $form_id.'_loading',
'class' => 'loading-search-datatables-button',
]
).'\';
$("#button-'.$form_id.'_search_bt").parent().append(loading);
}
inputs = $("#'.$form_id.' :input");
values = {};
inputs.each(function() {
values[this.name] = $(this).val();
})
$.extend(data, {
filter: values,'."\n";
if (is_array($parameters['ajax_data'])) {
foreach ($parameters['ajax_data'] as $k => $v) {
$type_data .= $k.':'.json_encode($v).",\n";
}
}
$type_data .= 'page: "'.$parameters['ajax_url'].'"
});
return data;
}
},';
} else {
$type_data = 'data: '.json_encode($parameters['data_element']).',';
}
$serverside = 'true';
if (isset($parameters['data_element'])) {
$serverside = 'false';
}
// Javascript controller.
$js = '<script type="text/javascript">
$(document).ready(function(){
$.fn.dataTable.ext.errMode = "none";
$.fn.dataTable.ext.classes.sPageButton = "'.$pagination_class.'";
var settings_datatable = {
drawCallback: function(settings) {';
if (!isset($parameters['data_element'])) {
$js .= 'if (dt_'.$table_id.'.page.info().pages > 1) {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show()
} else {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").hide()
}';
}
$js .= 'if ($("#'.$table_id.' tr td").length == 1) {
$(".datatable-msg-info-'.$table_id.'").show();
$(".datatable-msg-info-'.$table_id.'").removeClass(\'invisible_important\');
$("table#'.$table_id.'").hide();
$("div.dataTables_paginate").hide();
$("div.dataTables_info").hide();
$("div.dataTables_length").hide();
$("div.dt-buttons").hide();
if (dt_'.$table_id.'.page.info().pages > 1) {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show()
}
} else {
$(".datatable-msg-info-'.$table_id.'").hide();
$("table#'.$table_id.'").show();
$("#'.$table_id.'_wrapper > div.dataTables_paginate").show();
$("#'.$table_id.'_wrapper > div.dataTables_info").hide();
$("#'.$table_id.'_wrapper > div.dataTables_length").show();
$("#'.$table_id.'_wrapper > div.dt-buttons").show();
if (dt_'.$table_id.'.page.info().pages == 1) {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").hide()
}
}';
if (isset($parameters['drawCallback'])) {
$js .= $parameters['drawCallback'];
}
$searching = 'false';
if (isset($parameters['searching']) && $parameters['searching'] === true) {
$searching = 'true';
}
$ordering = 'true';
if (isset($parameters['ordering']) && $parameters['ordering'] === false) {
$ordering = 'false';
}
$js .= '},';
$languaje = substr(get_user_language(), 0, 2);
$js .= '
processing: true,
serverSide: '.$serverside.',
paging: '.$parameters['paging'].',
pageLength: '.$parameters['default_pagination'].',
searching: '.$searching.',
responsive: true,
dom: '.$dom_elements.',
language: {
url: "/pandora_console/include/javascript/i18n/dataTables.'.$languaje.'.json",
processing:"'.$processing.'",
zeroRecords:"'.$zeroRecords.'",
emptyTable:"'.$emptyTable.'",
},
buttons: '.$parameters['csv'].'== 1 ? [
{
extend: "csv",
text : "'.__('Export current page to CSV').'",
titleAttr: "'.__('Export current page to CSV').'",
title: "export_'.$parameters['id'].'_current_page_'.date('Y-m-d').'",
fieldSeparator: "'.$config['csv_divider'].'",
action: function ( e, dt, node, config ) {
blockResubmit(node);
// Call the default csvHtml5 action method to create the CSV file
$.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, node, config);
},
exportOptions : {
modifier : {
// DataTables core
order : "current",
page : "All",
search : "applied"
}'.$export_columns.'
},
}
] : [],
lengthMenu: '.json_encode($pagination_options).',
columnDefs: [
{ className: "no-class", targets: "_all" },
{ bSortable: false, targets: '.$no_sortable_columns.' }
],
ordering: '.$ordering.',
initComplete: function(settings, json) {
// Move elements to table_action_buttons bar.
$(".action_buttons_right_content").html("<div class=\"pagination-child-div\"></div>");
$(".action_buttons_right_content").html("<div class=\"pagination-child-div\"></div>");
$(".action_buttons_right_content").html("<div class=\"pagination-child-div\"></div>");
$(".action_buttons_right_content").html("<div class=\"pagination-child-div\"></div>");
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").attr("style","margin-right: 10px;"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_length"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dt-buttons"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_filter"));
$("div.spinner-fixed").hide();
},
columns: [';
foreach ($parameters['datacolumns'] as $data) {
if (is_array($data)) {
$js .= '{data : "'.$data['text'].'",className: "'.$data['class'].'"},';
} else {
$js .= '{data : "'.$data.'",className: "no-class"},';
}
}
$js .= '
],
order: [[ '.$order.' ]],';
$js .= $type_data;
$js .= '
};
dt_'.$table_id.' = $("#'.$table_id.'").DataTable(settings_datatable);
$("#button-'.$form_id.'_search_bt").click(function (){
dt_'.$table_id.'.draw().page(0)
});
';
if (isset($parameters['caption']) === true
&& empty($parameters['caption']) === false
) {
$js .= '$("#'.$table_id.'").append("<caption>'.$parameters['caption'].'</caption>");';
$js .= '$(".datatables_thead_tr").css("height", 0);';
}
if (isset($parameters['csv']) === true) {
$js."'$('#".$table_id."').on( 'buttons-processing', function ( e, indicator ) {
if ( indicator ) {
console.log('a');
}
else {
console.log('b');
}";
}
$js .= '$("table#'.$table_id.'").removeClass("invisible");
});';
$js .= '
$(function() {
$(document).on("preInit.dt", function (ev, settings) {
$("div.dataTables_length").hide();
$("div.dt-buttons").hide();
});
});
';
$js .= '</script>';
}
// Order.
$js .= '<script>';
$js .= 'function '.$table_id.'(dt, config) { ';
$js .= $file_content;
$js .= '}';
$js .= $table_id.'(dt, config)';
$js .= '</script>';
// * END JAVASCRIPT.
$info_msg_arr = [];
$info_msg_arr['message'] = $emptyTable;
$info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id;
$spinner = '<div class="spinner-fixed"><span></span><span></span><span></span><span></span></div>';
$spinner = '<div id="'.$table_id.'-spinner" class="spinner-fixed"><span></span><span></span><span></span><span></span></div>';
$info_msg = '<div>'.ui_print_info_message($info_msg_arr).'</div>';
$err_msg = '<div id="error-'.$table_id.'"></div>';
$output = $info_msg.$err_msg.$filter.$extra.$spinner.$table.$js;
if (is_ajax() === false) {
@ -4436,7 +4206,7 @@ function ui_print_datatable(array $parameters)
false,
false
);
$output .= '?v='.$config['current_package'].'"/>';
$output .= '"/>';
// Load tables.css.
$output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url(

View File

@ -0,0 +1,568 @@
<?php
/**
* Agents Functions.
*
* @category Agents functions.
* @package Pandora FMS
* @subpackage User interface.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 PandoraFMS 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.
/**
* Create_module_latency_goliat and return module id.
*
* @param mixed $id_agent Id agent.
* @param mixed $module_name Module name.
* @param mixed $id_group Id group.
* @param mixed $url_search Url to search.
* @param mixed $string_search Text to search.
*
* @return interger Module id.
*/
function create_module_latency_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='')
{
if ($string_search !== '') {
$str_search = 'check_string '.$string_search.'';
}
include_once 'include/functions_modules.php';
$array_values = [
'id_tipo_modulo' => '30',
'descripcion' => '',
'max' => '0',
'min' => '0',
'snmp_oid' => '',
'snmp_community' => 'public',
'id_module_group' => $id_group,
'module_interval' => '300',
'module_ff_interval' => '0',
'ip_target' => '',
'tcp_port' => '0',
'tcp_rcv' => '',
'tcp_send' => '',
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => 'task_begin
get '.$url_search.'
resource 1
'.$str_search.'
task_end',
'id_plugin' => '0',
'post_process' => '0',
'prediction_module' => '0',
'max_timeout' => '0',
'max_retries' => '0',
'disabled' => '',
'id_modulo' => '7',
'custom_id' => '',
'history_data' => '1',
'dynamic_interval' => '0',
'dynamic_max' => '0',
'dynamic_min' => '0',
'dynamic_two_tailed' => '0',
'parent_module_id' => '0',
'min_warning' => '0',
'max_warning' => '0',
'str_warning' => '',
'min_critical' => '0',
'max_critical' => '0',
'str_critical' => '',
'custom_string_1' => '',
'custom_string_2' => '',
'custom_string_3' => '',
'custom_integer_1' => '0',
'custom_integer_2' => '0',
'min_ff_event' => '0',
'min_ff_event_normal' => '0',
'min_ff_event_warning' => '0',
'min_ff_event_critical' => '0',
'ff_type' => '0',
'each_ff' => '0',
'ff_timeout' => '0',
'unit' => '',
'macros' => '',
'quiet' => '0',
'cps' => '0',
'critical_instructions' => '',
'warning_instructions' => '',
'unknown_instructions' => '',
'critical_inverse' => '0',
'warning_inverse' => '0',
'percentage_critical' => '0',
'percentage_warning' => '0',
'cron_interval' => '* * * * *',
'id_category' => '0',
'disabled_types_event' => '{\"going_unknown\":0}',
'module_macros' => 'W10=',
'warning_time' => '0',
];
return modules_create_agent_module($id_agent, $module_name.'_latency', $array_values);
}
/**
* Create_module_status_goliat and return module id.
*
* @param mixed $id_agent Id agent.
* @param mixed $module_name Module name.
* @param mixed $id_group Id group.
* @param mixed $url_search Url to search.
* @param mixed $string_search Text to search.
*
* @return interger Module id.
*/
function create_module_status_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='')
{
if ($string_search !== '') {
$str_search = 'check_string '.$string_search.' ';
}
include_once 'include/functions_modules.php';
$array_values = [
'id_tipo_modulo' => '31',
'descripcion' => '',
'max' => '0',
'min' => '0',
'snmp_oid' => '',
'snmp_community' => 'public',
'id_module_group' => $id_group,
'module_interval' => '300',
'module_ff_interval' => '0',
'ip_target' => '',
'tcp_port' => '0',
'tcp_rcv' => '',
'tcp_send' => '',
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => 'task_begin
get '.$url_search.'
resource 1
'.$str_search.'
task_end',
'id_plugin' => '0',
'post_process' => '0',
'prediction_module' => '0',
'max_timeout' => '0',
'max_retries' => '0',
'disabled' => '',
'id_modulo' => '7',
'custom_id' => '',
'history_data' => '1',
'dynamic_interval' => '0',
'dynamic_max' => '0',
'dynamic_min' => '0',
'dynamic_two_tailed' => '0',
'parent_module_id' => '0',
'min_warning' => '0',
'max_warning' => '0',
'str_warning' => '',
'min_critical' => '0',
'max_critical' => '0',
'str_critical' => '',
'custom_string_1' => '',
'custom_string_2' => '',
'custom_string_3' => '',
'custom_integer_1' => '0',
'custom_integer_2' => '0',
'min_ff_event' => '0',
'min_ff_event_normal' => '0',
'min_ff_event_warning' => '0',
'min_ff_event_critical' => '0',
'ff_type' => '0',
'each_ff' => '0',
'ff_timeout' => '0',
'unit' => '',
'macros' => '',
'quiet' => '0',
'cps' => '0',
'critical_instructions' => '',
'warning_instructions' => '',
'unknown_instructions' => '',
'critical_inverse' => '0',
'warning_inverse' => '0',
'percentage_critical' => '0',
'percentage_warning' => '0',
'cron_interval' => '* * * * *',
'id_category' => '0',
'disabled_types_event' => '{\"going_unknown\":0}',
'module_macros' => 'W10=',
'warning_time' => '0',
];
return modules_create_agent_module($id_agent, $module_name.'_status', $array_values);
}
/**
* Create module basic network and return module id.
*
* @param mixed $id_agent Id agent.
* @param mixed $id_group Id group.
* @param mixed $ip_target Ip target.
*
* @return interger Module id.
*/
function create_module_basic_network($id_agent, $id_group, $ip_target)
{
include_once 'include/functions_modules.php';
$array_values = [
'id_tipo_modulo' => '6',
'descripcion' => 'Basic network check (ping)',
'max' => '0',
'min' => '0',
'snmp_oid' => '',
'snmp_community' => 'public',
'id_module_group' => $id_group,
'module_interval' => '300',
'module_ff_interval' => '0',
'ip_target' => $ip_target,
'tcp_port' => '0',
'tcp_rcv' => '',
'tcp_send' => '',
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => '',
'id_plugin' => '0',
'post_process' => '0',
'prediction_module' => '0',
'max_timeout' => '0',
'max_retries' => '0',
'disabled' => '',
'id_modulo' => '2',
'custom_id' => '',
'history_data' => '1',
'dynamic_interval' => '0',
'dynamic_max' => '0',
'dynamic_min' => '0',
'dynamic_two_tailed' => '0',
'parent_module_id' => '0',
'min_warning' => '0',
'max_warning' => '0',
'str_warning' => '',
'min_critical' => '0',
'max_critical' => '0',
'str_critical' => '',
'custom_string_1' => '',
'custom_string_2' => '',
'custom_string_3' => '',
'custom_integer_1' => '0',
'custom_integer_2' => '0',
'min_ff_event' => '0',
'min_ff_event_normal' => '0',
'min_ff_event_warning' => '0',
'min_ff_event_critical' => '0',
'ff_type' => '0',
'each_ff' => '0',
'ff_timeout' => '0',
'unit' => '',
'macros' => '',
'quiet' => '0',
'cps' => '0',
'critical_instructions' => '',
'warning_instructions' => '',
'unknown_instructions' => '',
'critical_inverse' => '0',
'warning_inverse' => '0',
'percentage_critical' => '0',
'percentage_warning' => '0',
'cron_interval' => '* * * * *',
'id_category' => '0',
'disabled_types_event' => '{\"going_unknown\":0}',
'module_macros' => 'W10=',
'warning_time' => '0',
];
return modules_create_agent_module($id_agent, 'Basic_Network_Check', $array_values);
}
/**
* Create module latency network and return module id.
*
* @param mixed $id_agent Id agent.
* @param mixed $id_group Id group.
* @param mixed $ip_target Ip target.
*
* @return interger Module id.
*/
function create_module_latency_network($id_agent, $id_group, $ip_target)
{
include_once 'include/functions_modules.php';
$array_values = [
'id_tipo_modulo' => '7',
'descripcion' => 'Basic network connectivity check to measure network latency in miliseconds',
'max' => '0',
'min' => '0',
'snmp_oid' => '',
'snmp_community' => 'public',
'id_module_group' => $id_group,
'module_interval' => '300',
'module_ff_interval' => '0',
'ip_target' => $ip_target,
'tcp_port' => '0',
'tcp_rcv' => '',
'tcp_send' => '',
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => '',
'id_plugin' => '0',
'post_process' => '0',
'prediction_module' => '0',
'max_timeout' => '0',
'max_retries' => '0',
'disabled' => '',
'id_modulo' => '2',
'custom_id' => '',
'history_data' => '1',
'dynamic_interval' => '0',
'dynamic_max' => '0',
'dynamic_min' => '0',
'dynamic_two_tailed' => '1',
'parent_module_id' => '0',
'min_warning' => '0',
'max_warning' => '0',
'str_warning' => '',
'min_critical' => '0',
'max_critical' => '0',
'str_critical' => '',
'custom_string_1' => '',
'custom_string_2' => '',
'custom_string_3' => '',
'custom_integer_1' => '0',
'custom_integer_2' => '0',
'min_ff_event' => '0',
'min_ff_event_normal' => '0',
'min_ff_event_warning' => '0',
'min_ff_event_critical' => '0',
'ff_type' => '0',
'each_ff' => '0',
'ff_timeout' => '0',
'unit' => '',
'macros' => '',
'quiet' => '0',
'cps' => '0',
'critical_instructions' => '',
'warning_instructions' => '',
'unknown_instructions' => '',
'critical_inverse' => '0',
'warning_inverse' => '0',
'percentage_critical' => '0',
'percentage_warning' => '0',
'cron_interval' => '* * * * *',
'id_category' => '0',
'disabled_types_event' => '{\"going_unknown\":0}',
'module_macros' => 'W10=',
'warning_time' => '0',
];
return modules_create_agent_module($id_agent, 'Basic_Network_Latency', $array_values);
}
/**
* Create module packet lost and return module id.
*
* @param mixed $id_agent Id agent.
* @param mixed $id_group Id group.
* @param mixed $ip_target Ip target.
*
* @return interger Module id.
*/
function create_module_packet_lost($id_agent, $id_group, $ip_target)
{
include_once 'include/functions_modules.php';
$array_values = [
'id_tipo_modulo' => '1',
'descripcion' => 'Basic network connectivity check to measure packet loss in %',
'max' => '0',
'min' => '0',
'snmp_oid' => '',
'snmp_community' => 'public',
'id_module_group' => $id_group,
'module_interval' => '300',
'module_ff_interval' => '0',
'ip_target' => '',
'tcp_port' => '0',
'tcp_rcv' => '',
'tcp_send' => '',
'id_export' => '0',
'plugin_user' => '',
'plugin_pass' => '0',
'plugin_parameter' => '',
'id_plugin' => '9',
'post_process' => '0',
'prediction_module' => '0',
'max_timeout' => '0',
'max_retries' => '0',
'disabled' => '',
'id_modulo' => '4',
'custom_id' => '',
'history_data' => '1',
'dynamic_interval' => '0',
'dynamic_max' => '0',
'dynamic_min' => '0',
'dynamic_two_tailed' => '1',
'parent_module_id' => '0',
'min_warning' => '0',
'max_warning' => '0',
'str_warning' => '',
'min_critical' => '0',
'max_critical' => '0',
'str_critical' => '',
'custom_string_1' => '',
'custom_string_2' => '',
'custom_string_3' => '',
'custom_integer_1' => '0',
'custom_integer_2' => '0',
'min_ff_event' => '0',
'min_ff_event_normal' => '0',
'min_ff_event_warning' => '0',
'min_ff_event_critical' => '0',
'ff_type' => '0',
'each_ff' => '0',
'ff_timeout' => '0',
'unit' => '',
'macros' => '{"1":{"macro":"_field1_","desc":"Test time","help":"","value":"8","hide":""},"2":{"macro":"_field2_","desc":"Target IP","help":"","value":"'.$ip_target.'","hide":""}}',
'quiet' => '0',
'cps' => '0',
'critical_instructions' => '',
'warning_instructions' => '',
'unknown_instructions' => '',
'critical_inverse' => '0',
'warning_inverse' => '0',
'percentage_critical' => '0',
'percentage_warning' => '0',
'cron_interval' => '* * * * *',
'id_category' => '0',
'disabled_types_event' => '{\"going_unknown\":0}',
'module_macros' => 'W10=',
'warning_time' => '0',
];
return modules_create_agent_module($id_agent, 'Basic_Network_Packetloss', $array_values);
}
/**
* Create module packet lost and return module id.
*
* @param string $ip_target Ip and red mask.
*
* @return interger Module id.
*/
function create_net_scan($ip_target)
{
global $config;
include_once $config['homedir'].'/godmode/wizards/HostDevices.class.php';
$HostDevices = new HostDevices(1);
$id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server'];
$_POST = [
'page' => '1',
'interval_manual_defined' => '1',
'interval_select' => '-1',
'interval_text' => '0',
'interval' => '0',
'interval_units' => '1',
'taskname' => __('Basic network'),
'id_recon_server' => $id_recon_server,
'network' => $ip_target,
'id_group' => '8',
'comment' => __('Created on welcome'),
];
$task_created = $HostDevices->parseNetScan();
if ($task_created === true) {
$HostDevicesFinal = new HostDevices(2);
$_POST = [
'task' => $HostDevices->task['id_rt'],
'page' => '2',
'recon_ports' => '',
'auto_monitor' => 'on',
'id_network_profile' => ['0' => '2'],
'review_results' => 'on',
'review_limited' => '0',
'snmp_enabled' => 'on',
'snmp_version' => '1',
'snmp_skip_non_enabled_ifs' => 'on',
'community' => '',
'snmp_context' => '',
'snmp_auth_user' => '',
'snmp_security_level' => 'authNoPriv',
'snmp_auth_method' => 'MD5',
'snmp_auth_pass' => '',
'snmp_privacy_method' => 'AES',
'snmp_privacy_pass' => '',
'os_detect' => 'on',
'resolve_names' => 'on',
'parent_detection' => 'on',
'parent_recursion' => 'on',
'vlan_enabled' => 'on',
];
$task_final_created = $HostDevicesFinal->parseNetScan();
if ($task_final_created === true) {
$net_scan_id = $HostDevices->task['id_rt'];
unset($HostDevices, $HostDevicesFinal);
return $net_scan_id;
}
} else {
return 0;
}
}
/**
* Create new template unknown.
*
* @return boolean 1 correct create 0 bad create.
*/
function create_template_alert_unknown()
{
$name = io_safe_input(__('Unknown condition'));
$type = 'critical';
$values = [
'description' => __('This is a generic alert template to fire on UNKNOWN condition'),
'max_value' => 0,
'min_value' => 0,
'id_group' => 0,
'priority' => 4,
'wizard_level' => 'nowizard',
'time_threshold' => '300',
'min_alerts_reset_counter' => 1,
'schedule' => '{"monday":[{"start":"00:00:00","end":"00:00:00"}],"tuesday":[{"start":"00:00:00","end":"00:00:00"}],"wednesday":[{"start":"00:00:00","end":"00:00:00"}],"thursday":[{"start":"00:00:00","end":"00:00:00"}],"friday":[{"start":"00:00:00","end":"00:00:00"}],"saturday":[{"start":"00:00:00","end":"00:00:00"}],"sunday":[{"start":"00:00:00","end":"00:00:00"}]}',
'recovery_notify' => true,
'field2' => '[PANDORA] Alert for UNKNOWN status on _agent_ / _module_',
'field2_recovery' => '[PANDORA] Alert RECOVERED for UNKNOWN status on _agent_ / _module_',
'field3' => '<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"><table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"><thead><tr><td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank" rel="noopener"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td><td style="padding: 0px 0px 5px;"><p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p></td></tr><tr><td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td></tr></thead><tbody><tr><td colspan="2"><img style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" src="https://pandorafms.com/wp-content/uploads/2022/03/Warning-news.png" width="105px"></td></tr><tr><td colspan="2"><p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have bad news for you, something is on <span style="text-transform: uppercase; font-weight: 800;">UNKNOWN</span>&nbsp;status!</p><div><!-- [if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!-- [if mso]></center></v:rect><![endif]--></div></td></tr><tr><td colspan="2"><div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"><p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(warning)</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p></div></td></tr><tr><td style="padding: 20px 0px;" colspan="2"><p style="font-size: 18px; line-height: 30px; color: #223549;">This is a graph of latest 24hr data for this module</p><p style="font-weight: 400!important;">_modulegraph_24h_</p></td></tr></tbody></table><div style="text-align: center; margin-top: 10px;"><p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p></div></div>',
'field3_recovery' => '<div style="background-color:#EAF0F6; font-family: Arial, Helvetica, sans-serif; padding:30px; margin:0;"><table style="max-width:560px; background-color:white; border-radius:10px; padding:10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"><thead><tr><td style="padding:0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td><td style="padding:0px 0px 5px;"><p style="text-align:right; color:#223549; font-weight:700; line-height:36px; padding:0px; font-size:12px;">Automatic alert system</p></td></tr><tr><td colspan="2" style="padding:0px 0px 5px;"><hr style="border: 1px solid #f5f5f5; width:100%; margin:0px;"></td></tr></thead><tbody><tr><td colspan="2"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Good-news.png" style="display: block; margin-left: auto; margin-right: auto; width:105px; margin-top:20px; padding:0px;" width="105px"></td></tr><tr><td colspan="2"><p style="font-size:24px; text-align:center; color:#223549; padding:0px 10%; line-height:34px; margin:20px 0px;">We have good news for you, alert has been <span style="text-transform:uppercase; font-weight:800;">recovered</span></p><div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius:100px; max-width:50%; margin-top:0px; font-weight:700;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div></td></tr><tr><td colspan="2"><div style="background-color:#F6F6F6; border-radius:10px; padding:10px 20px; margin-top:40px;"><p style="font-size:18px; line-height:30px; color:#223549;">Monitoring details</p><p style="font-size:15px; color:#333333; font-weight:800; line-height:15px;">Data: <span style="font-weight:400!important;">_data_ <em>(normal)</em></span></p><p style="font-size:15px; color:#333333; font-weight:800; line-height:15px;">Agent: <span style="font-weight:400!important;">_agent_ <em>_address_</em></span></p><p style="font-size:15px; color:#333333; font-weight:800; line-height:15px;">Module: <span style="font-weight:400!important;">_module_ <em>_moduledescription_</em></span></p><p style="font-size:15px; color:#333333; font-weight:800; line-height:15px;">Timestamp: <span style="font-weight:400!important;">_timestamp_</span></p></div></td></tr><tr><td style="padding:20px 0px;" colspan="2"><p style="font-size:18px; line-height:30px; color:#223549;">This is a graph of latest 24hr data for this module</p><p style="font-weight:400!important;">_modulegraph_24h_</p></td></tr></tbody></table><div style="text-align:center; margin-top:10px;"><p style="font-size:12px; text-decoration: none; font-weight:400; color:#777;"><a href="https://pandorafms.com/en/contact/" style="font-size:12px; text-decoration: none; font-weight:400; color:#777;">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="https://pandorafms.com/community/forums/forum/english/" style="font-size:12px; text-decoration: none; font-weight:400; color:#777;">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="https://pandorafms.com/manual/en/start" style="font-size:12px; text-decoration: none; font-weight:400; color:#777;">Docs</a></p></div></div>',
];
$result = alerts_create_alert_template($name, $type, $values);
return $result;
}

View File

@ -57,7 +57,7 @@ function include_javascript_d3($return=false)
}
function d3_relationship_graph($elements, $matrix, $width=700, $return=false)
function d3_relationship_graph($elements, $matrix, $width=700, $return=false, $height=700)
{
global $config;
@ -72,7 +72,7 @@ function d3_relationship_graph($elements, $matrix, $width=700, $return=false)
$output = '<div id="chord_diagram"></div>';
$output .= include_javascript_d3(true);
$output .= "<script language=\"javascript\" type=\"text/javascript\">
chordDiagram('#chord_diagram', $elements, $matrix, $width);
chordDiagram('#chord_diagram', $elements, $matrix, $width, $height);
</script>";
if (!$return) {
@ -150,7 +150,7 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false)
}
function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true)
function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true, $id_container=false)
{
global $config;
@ -158,6 +158,8 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $toolt
$data = json_encode($data);
}
$id_container = ($id_container === false) ? '#sunburst' : $id_container;
$output = "<div id=\"sunburst\" style='overflow: hidden;'></div>";
$output .= include_javascript_d3(true);
$output .= '<style type="text/css">
@ -167,7 +169,7 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $toolt
}
</style>';
$output .= "<script language=\"javascript\" type=\"text/javascript\">
sunburst('#sunburst', $data, '$width', '$height', '$tooltip');
sunburst('$id_container', $data, '$width', '$height', '$tooltip');
</script>";
if (!$return) {

View File

@ -259,7 +259,7 @@ function flot_area_graph(
$return .= html_print_input_hidden(
'line_width_graph',
$config['custom_graph_width'],
(empty($params['line_width']) === true) ? $config['custom_graph_width'] : $params['line_width'],
true
);
$return .= "<div id='timestamp_$graph_id'

View File

@ -22,7 +22,7 @@
// matrix = [[0, 0, 2], // a[a => a, a => b, a => c]
// [5, 0, 1], // b[b => a, b => b, b => c]
// [2, 3, 0]]; // c[c => a, c => b, c => c]
function chordDiagram(recipient, elements, matrix, width) {
function chordDiagram(recipient, elements, matrix, width, height) {
d3.chart = d3.chart || {};
d3.chart.chordWheel = function(options) {
// Default values
@ -59,10 +59,13 @@ function chordDiagram(recipient, elements, matrix, width) {
.enter()
.append("svg:svg")
.attr("width", width)
.attr("height", width)
.attr("height", height)
.attr("class", "dependencyWheel")
.append("g")
.attr("transform", "translate(" + width / 2 + "," + width / 2 + ")");
.attr(
"transform",
"translate(" + width / 2 + "," + height / 2 + ") scale(1.2)"
);
var arc = d3.svg
.arc()
@ -206,8 +209,8 @@ function chordDiagram(recipient, elements, matrix, width) {
.on("mousemove", move_tooltip);
function move_tooltip(d) {
x = d3.event.pageX + 10;
y = d3.event.pageY + 10;
x = d3.event.layerX + 10;
y = d3.event.layerY + 10;
$("#tooltip").css("left", x + "px");
$("#tooltip").css("top", y + "px");

View File

@ -0,0 +1,378 @@
var dt = dt;
var config = config;
var datacolumns = [];
var datacolumnsTemp = [];
dt.datacolumns.forEach(column => {
if (column === null) return;
if (typeof column !== "string") {
datacolumnsTemp = { data: column.text, className: column.class };
datacolumns.push(datacolumnsTemp);
} else {
datacolumnsTemp = { data: column, className: "no-class" };
datacolumns.push(datacolumnsTemp);
}
});
var paginationClass = "pandora_pagination";
if (typeof dt.pagination_class !== "undefined") {
paginationClass = dt.pagination_class;
}
var processing = "";
if (typeof dt.processing === "undefined") {
processing = dt.processing;
}
var ajaxReturn = "";
var ajaxReturnFunction = "";
if (
typeof dt.ajax_return_operation !== "undefined" &&
dt.ajax_return_operation !== "" &&
typeof dt.ajax_return_operation_function !== "undefined" &&
dt.ajax_return_operation_function !== ""
) {
ajaxReturn = dt.ajax_return_operation;
ajaxReturnFunction = dt.ajax_return_operation_function;
}
var serverSide = true;
if (typeof dt.data_element !== "undefined") {
serverSide = false;
}
var paging = true;
if (typeof dt.paging !== "undefined") {
paging = dt.paging;
}
var pageLength = parseInt(dt.default_pagination);
var searching = false;
if (typeof dt.searching !== "undefined" && dt.searching === true) {
searching = dt.searching;
}
var dom = "plfrtiB";
if (typeof dt.dom_elements !== "undefined") {
dom = dt.dom_elements;
}
var lengthMenu = [
[pageLength, 5, 10, 20, 100, 200, 500, 1000, -1],
[pageLength, 5, 10, 20, 100, 200, 500, 1000, "All"]
];
if (typeof dt.pagination_options !== "undefined") {
lengthMenu = dt.pagination_options;
}
var ordering = true;
if (typeof dt.ordering !== "undefined" && dt.ordering === false) {
ordering = dt.ordering;
}
var order = [[0, "asc"]];
if (typeof dt.order !== "undefined") {
order = [[dt.order.order, dt.order.direction]];
}
var zeroRecords = "";
if (typeof dt.zeroRecords !== "undefined") {
zeroRecords = `${dt.zeroRecords}`;
}
var emptyTable = "";
if (typeof dt.emptyTable !== "undefined") {
emptyTable = `${dt.emptyTable}`;
}
var no_sortable_columns = [];
if (typeof dt.no_sortable_columns !== "undefined") {
no_sortable_columns = Object.values(dt.no_sortable_columns);
}
var columnDefs = [];
if (typeof dt.columnDefs === "undefined") {
columnDefs = [
{ className: "no-class", targets: "_all" },
{ bSortable: false, targets: no_sortable_columns }
];
} else {
columnDefs = dt.columnDefs;
}
var csvClassName = "csv-button";
if (dt.mini_csv === true) {
csvClassName = "mini-csv-button";
}
var csvFieldSeparator = ";";
if (typeof dt.csv_field_separator !== "undefined") {
csvFieldSeparator = dt.csv_field_separator;
}
var csvHeader = true;
if (dt.csv_header === false) {
csvHeader = false;
}
var csvExcludeLast = "";
if (dt.csv_exclude_latest === true) {
csvExcludeLast = "th:not(:last-child)";
}
var ajaxData = "";
if (typeof dt.ajax_data !== "undefined") {
ajaxData = dt.ajax_data;
}
$(document).ready(function() {
function checkPages() {
if (dt_table.page.info().pages > 1) {
$(
"div.pagination-child-div > .dataTables_paginate.paging_simple_numbers"
).show();
$(`#${dt.id}_paginate`).show();
} else {
$(
"div.pagination-child-div > .dataTables_paginate.paging_simple_numbers"
).hide();
$(`#${dt.id}_paginate`).hide();
}
}
function moveElementsToActionButtons() {
$(".action_buttons_right_content").html(
'<div class="pagination-child-div"></div>'
);
$(".pagination-child-div").append(
$(`#${dt.id}_wrapper > .dataTables_paginate.paging_simple_numbers`).attr(
"style",
"margin-right: 10px;"
)
);
$(".pagination-child-div").append(
$(`#${dt.id}_wrapper > .dataTables_length`)
);
$(".pagination-child-div").append($(`#${dt.id}_wrapper > .dt-buttons`));
$(".pagination-child-div").append(
$(`#${dt.id}_wrapper > .dataTables_filter`)
);
}
$.fn.dataTable.ext.errMode = "none";
$.fn.dataTable.ext.classes.sPageButton = paginationClass;
if (dt.mini_pagination === true) {
$.fn.dataTable.ext.classes.sPageButton = `${paginationClass} mini-pandora-pagination`;
}
var settings_datatable = {
processing: true,
responsive: true,
serverSide,
paging,
pageLength,
searching,
dom,
lengthMenu,
ordering,
order,
columns: eval(datacolumns),
columnDefs,
language: {
url: dt.language,
processing,
zeroRecords,
emptyTable
},
buttons:
dt.csv == 1
? [
{
extend: "csv",
className: csvClassName,
text: dt.csvTextInfo,
titleAttr: dt.csvTextInfo,
title: dt.csvFileTitle,
fieldSeparator: csvFieldSeparator,
header: csvHeader,
action: function(e, dt, node, config) {
blockResubmit(node);
// Call the default csvHtml5 action method to create the CSV file
$.fn.dataTable.ext.buttons.csvHtml5.action.call(
this,
e,
dt,
node,
config
);
},
exportOptions: {
modifier: {
// DataTables core
order: "current",
page: "All",
search: "applied"
},
columns: csvExcludeLast
}
}
]
: [],
initComplete: function(settings, json) {
moveElementsToActionButtons();
checkPages();
$(`div#${dt.id}-spinner`).hide();
},
drawCallback: function(settings) {
if ($(`#${dt.id} tr td`).length == 1) {
$(`.datatable-msg-info-${dt.id}`)
.removeClass("invisible_important")
.show();
$(`table#${dt.id}`).hide();
$("div.pagination-child-div").hide();
$("div.dataTables_info").hide();
$(`#${dt.id}_wrapper`).hide();
$(`.action_buttons_right_content .pagination-child-div`).hide();
} else {
$(`.datatable-msg-info-${dt.id}`).hide();
$(`table#${dt.id}`).show();
$("div.pagination-child-div").show();
$("div.dataTables_info").show();
$(`#${dt.id}_wrapper`).show();
if (typeof dt.drawCallback !== "undefined") {
eval(dt.drawCallback);
}
}
$(`div#${dt.id}-spinner`).hide();
checkPages();
}
};
var ajaxOrData = {};
if (typeof dt.data_element == "undefined") {
ajaxOrData = {
ajax: {
url: dt.ajax_url_full,
type: "POST",
dataSrc: function(json) {
if ($(`#${dt.form_id}_search_bt`) != undefined) {
$(`#${dt.form_id}_loading`).remove();
}
if (json.error) {
console.error(json.error);
$(`#error-${dt.id}`).html(json.error);
$(`#error-${dt.id}`)
.dialog({
title: "Filter failed",
width: 630,
resizable: true,
draggable: true,
modal: false,
closeOnEscape: true,
buttons: {
Ok: function() {
$(this).dialog("close");
}
}
})
.parent()
.addClass("ui-state-error");
} else {
if (json.ajaxReturn !== "undefined") {
eval(`${ajaxReturnFunction}(${json.ajaxReturn})`);
}
if (typeof dt.ajax_postprocess !== "undefined") {
if (json.data) {
json.data.forEach(function(item) {
eval(dt.ajax_postprocess);
});
} else {
json.data = {};
}
}
return json.data;
}
},
data: function(data) {
$(`div#${dt.id}-spinner`).show();
if ($(`#button-${dt.form_id}_search_bt`) != undefined) {
var loading = `<img src="images/spinner.gif" id="${dt.form_id}_loading" class="loading-search-datatables-button" />`;
$(`#button-${dt.form_id}_search_bt`)
.parent()
.append(loading);
}
var inputs = $(`#${dt.form_id} :input`);
var values = {};
inputs.each(function() {
values[this.name] = $(this).val();
});
$.extend(data, ajaxData);
$.extend(data, {
filter: values,
page: dt.ajax_url
});
return data;
}
}
};
} else {
ajaxOrData = { data: dt.data_element };
}
$.extend(settings_datatable, ajaxOrData);
var dt_table = $(`#${dt.table_id}`).DataTable(settings_datatable);
$(`#button-${dt.form_id}_search_bt`).click(function() {
dt_table.draw().page(0);
});
if (typeof dt.caption !== "undefined" && dt.caption !== "") {
$(`#${dt.table_id}`).append(`<caption>${dt.caption}</caption>`);
$(".datatables_thead_tr").css("height", 0);
}
$(function() {
$(document).on("init.dt", function(ev, settings) {
if (dt.mini_search === true) {
$(`#${dt.id}_filter > label > input`).addClass("mini-search-input");
}
$("div.dataTables_length").show();
$("div.dataTables_filter").show();
$("div.dt-buttons").show();
if (dt_table.page.info().pages === 0) {
$(`.action_buttons_right_content .pagination-child-div`).hide();
}
if (dt_table.page.info().pages === 1) {
$(`div.pagination-child-div > #${dt.table_id}_paginate`).hide();
} else {
$(`div.pagination-child-div > #${dt.table_id}_paginate`).show();
}
});
});
});
$(function() {
$(document).on("preInit.dt", function(ev, settings) {
$(`#${dt.id}_wrapper div.dataTables_length`).hide();
$(`#${dt.id}_wrapper div.dataTables_filter`).hide();
$(`#${dt.id}_wrapper div.dt-buttons`).hide();
});
});

View File

@ -6,7 +6,6 @@
"infoThousands": ",",
"lengthMenu": "Show _MENU_ entries",
"loadingRecords": "Loading...",
"processing": "Processing...",
"search": "Search:",
"zeroRecords": "No matching records found",
"thousands": ",",

View File

@ -416,6 +416,10 @@ class Widget
$className .= '\OsQuickReportWidget';
break;
case 'netflow':
$className .= '\Netflow';
break;
case 'GroupedMeterGraphs':
case 'ColorModuleTabs':
case 'BlockHistogram':
@ -424,6 +428,7 @@ class Widget
case 'ModulesByStatus':
case 'AvgSumMaxMinModule':
case 'BasicChart':
case 'AgentHive':
$className .= '\\'.$name;
break;

View File

@ -0,0 +1,519 @@
<?php
/**
* Widget agent hive Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 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.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
use PandoraFMS\Enterprise\Metaconsole\Node;
global $config;
/**
* URL Widgets
*/
class AgentHive extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->decoders($this->getOptionsWidget());
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Agent hive');
// Name.
if (empty($this->name) === true) {
$this->name = 'AgentHive';
}
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['groups']) === true) {
$this->configurationRequired = true;
}
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['groups']) === true) {
$values['groups'] = $decoder['groups'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
$values = $this->values;
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Filters.
$inputs[] = [
'label' => __('Groups'),
'id' => 'li_groups',
'arguments' => [
'type' => 'select_groups',
'name' => 'groups[]',
'returnAllGroup' => false,
'privilege' => 'AR',
'selected' => explode(',', $values['groups'][0]),
'return' => true,
'multiple' => true,
'required' => true,
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost(): array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['groups'] = \get_parameter('groups', 0);
return $values;
}
/**
* Draw widget.
*
* @return string;
*/
public function load()
{
global $config;
$groups = $this->values['groups'];
$groups = explode(',', $groups[0]);
$user_groups = array_keys(
users_get_groups(
false,
'AR',
false,
false,
$groups
)
);
foreach ($groups as $key => $group) {
if (in_array($group, $user_groups) === false) {
unset($groups[$key]);
}
}
$table = 'tagente';
if (is_metaconsole()) {
$table = 'tmetaconsole_agent';
}
$sql = sprintf(
'SELECT * FROM %s WHERE id_grupo IN('.implode(',', $groups).')',
$table
);
$all_agents = db_get_all_rows_sql($sql);
$output = '';
$output .= '<div class="container-tabs">';
foreach ($all_agents as $agent) {
$output .= $this->drawSquare($agent);
}
$output .= '</div>';
$output .= '<script type="text/javascript">
$(document).ready (function () {
$(".widget-agent-hive-square").click(function(e) {
if (typeof e.target.id === "string" && /img_.*/i.test(e.target.id) === false) {
var url = $(this).children("input").first().val();
window.open(url);
}
});
$("div [id*=hiveImg_] svg path").css("fill", "#99A3BE");
});
</script>';
return $output;
}
/**
* Draw square agent.
*
* @param array $data Info agent.
*
* @return string Output.
*/
private function drawSquare(array $data): string
{
global $config;
$id = (is_metaconsole() === true)
? $data['id_tagente']
: $data['id_agente'];
$status = agents_get_status_from_counts($data);
switch ($status) {
case 1:
case 4:
case 100:
// Critical (BAD or ALERT).
$color = '#e63c52';
break;
case 0:
case 300:
// Normal (OK).
$color = '#82b92e';
break;
case 2:
case 200:
// Warning.
$color = '#f3b200';
break;
case 5:
// Not init.
$color = '#4a83f3';
break;
default:
// Default is Grey (Other).
$color = '#b2b2b2';
break;
}
$style_contact = 'flex-grow: 9; font-size: 8pt; display: flex;
justify-content: start;align-items: start; color: #9FA5B1; font-weight: 600;';
// Last contact.
$lastContactDate = ui_print_timestamp(
$data['ultimo_contacto'],
true,
['style' => $style_contact]
);
// Url.
$console_url = ui_get_full_url('/');
if (is_metaconsole()) {
$server = metaconsole_get_servers($data['id_tmetaconsole_setup']);
$console_url = $server['server_url'].'/';
}
$url_view = $console_url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id;
$url_manage = $console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id;
$output = '<div class="widget-agent-hive-square">';
$output .= '<input type="hidden" name="test" value="'.$url_view.'" />';
$output .= '<div class="widget-agent-hive-square-status"
style="background-color:'.$color.'"></div>';
$output .= '<div class="widget-agent-hive-square-info">';
// Last contact and img.
$output .= '<div class="widget-agent-hive-square-info-header">';
$output .= $lastContactDate;
$output .= '<a href="'.$url_manage.'" target="_blank">'.html_print_image(
'images/configuration@svg.svg',
true,
[
'title' => __('Operation view'),
'class' => 'main_menu_icon invert_filter',
'style' => 'flex-grow: 1',
'id' => 'img_'.$id,
]
).'</a>';
$output .= '</div>';
// OS and alias.
$output .= '<div class="widget-agent-hive-square-info-body">';
$icon = (string) db_get_value(
'icon_name',
'tconfig_os',
'id_os',
(int) $data['id_os']
);
$output .= '<div id="hiveImg_'.$id.'"
style="width:20px;height:20px;margin-right: 5px;">';
$output .= file_get_contents(
ui_get_full_url('images/'.$icon, false, false, false)
);
$output .= '</div>';
$output .= ui_print_truncate_text(
ucfirst(io_safe_output($data['alias'])),
12,
false,
true,
true,
'&hellip;',
'font-size: 11pt;color: #14524f;white-space: nowrap;
font-weight: 600;text-align: left;width: 80%;
overflow: hidden;',
);
$output .= '</div>';
// OS description.
$output .= html_print_div(
[
'content' => (empty($data['os_version']) === true)
? get_os_name((int) $data['id_os'])
: $data['os_version'],
'style' => 'font-size: 6pt; display:
flex;justify-content: start;align-items: start;
color: #9FA5B1; font-weight: 600;margin-bottom: 5px',
],
true
);
// Description.
$output .= html_print_div(
[
'content' => ui_print_truncate_text(
io_safe_output($data['comentarios']),
38,
false,
true,
true,
'&hellip;',
),
'style' => 'text-align: left;min-height: 42px;
font-size: 8pt;max-height: 42px; margin-bottom: 10px',
],
true
);
// IP.
$output .= html_print_div(
[
'content' => $data['direccion'],
'style' => 'font-size: 10pt;color: #14524f;
font-weight: 600; text-align: left',
],
true
);
$output .= '</div>';
$output .= '</div>';
return $output;
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('Agents hive');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'AgentHive';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => (is_metaconsole() === true) ? 700 : 600,
'height' => 610,
];
return $size;
}
}

View File

@ -297,6 +297,14 @@ class BasicChart extends Widget
$values['label'] = $decoder['label'];
}
if (isset($decoder['type_graph']) === true) {
$values['type_graph'] = $decoder['type_graph'];
}
if (isset($decoder['line_width']) === true) {
$values['line_width'] = $decoder['line_width'];
}
return $values;
}
@ -477,6 +485,22 @@ class BasicChart extends Widget
],
];
$types_graph = [
'area' => __('Area'),
'line' => __('Wire'),
];
$inputs['inputs']['row1'][] = [
'label' => __('Type graph'),
'arguments' => [
'type' => 'select',
'fields' => $types_graph,
'name' => 'type_graph',
'selected' => $values['type_graph'],
'return' => true,
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Show Value'),
'arguments' => [
@ -520,6 +544,18 @@ class BasicChart extends Widget
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Graph line size'),
'arguments' => [
'name' => 'line_width',
'type' => 'number',
'value' => (empty($values['line_width']) === true) ? 3 : $values['line_width'],
'return' => true,
'min' => 2,
'max' => 10,
],
];
return $inputs;
}
@ -546,6 +582,8 @@ class BasicChart extends Widget
$values['colorChart'] = \get_parameter('colorChart');
$values['formatData'] = \get_parameter_switch('formatData');
$values['label'] = \get_parameter('label');
$values['type_graph'] = \get_parameter('type_graph');
$values['line_width'] = \get_parameter('line_width');
return $values;
}
@ -606,6 +644,8 @@ class BasicChart extends Widget
'title' => $module_name,
'unit' => $units_name,
'only_image' => false,
'type_graph' => $this->values['type_graph'],
'line_width' => (empty($this->values['line_width']) === true) ? 3 : $this->values['line_width'],
'menu' => false,
'vconsole' => true,
'return_img_base_64' => false,

View File

@ -520,7 +520,7 @@ class DataMatrix extends Widget
[
'id' => $tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'include/ajax/module',

View File

@ -438,7 +438,7 @@ class ModulesByStatus extends Widget
[
'id' => $tableId,
'class' => 'info_table align-left-important',
'style' => 'width: 99%',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'include/ajax/module',

View File

@ -540,12 +540,6 @@ class ModuleIconWidget extends Widget
$output = '';
$id_group = \agents_get_agent_group($this->values['agentId']);
$modulesAgent = \modules_get_agentmodule_agent(
$this->values['moduleId']
);
$data_module = \modules_get_last_value(
$this->values['moduleId']
);
@ -574,33 +568,37 @@ class ModuleIconWidget extends Widget
// General div.
$output .= '<div class="'.$orientation.'" id="general-'.$uuid.'">';
$sql = 'SELECT min_warning,
max_warning,
min_critical,
max_critical,
str_warning,
str_critical
FROM tagente_modulo
WHERE id_agente_modulo = '.(int) $this->values['moduleId'];
$sql_data = db_get_row_sql($sql);
$status = \modules_get_agentmodule_status($this->values['moduleId']);
$last = modules_get_last_value($this->values['moduleId']);
switch ($status) {
case 1:
case 4:
// Critical or critical alert (BAD).
$color_icon .= '_bad.png';
break;
$color_icon = '_ok';
if (($last >= $sql_data['min_warning']) && ($last < $sql_data['max_warning'])) {
$color_icon = '_warning';
case 0:
// Normal (OK).
$color_icon .= '_ok.png';
break;
case 2:
case 10:
// Warning or warning alert.
$color_icon .= '_warning.png';
break;
case 3:
// Unknown.
default:
$color_icon .= '.png';
// Default is Grey (Other).
break;
}
if ($last >= $sql_data['max_warning']) {
$color_icon = '_bad';
}
// Div image.
$style_icon = 'flex: 0 1 '.$sizeIcon.'px;';
$output .= '<div class="pdd_l_15px pdd_r_15px '.$margin_bottom.'" style="flex: 0 1 '.$sizeIcon.'px; height: '.$sizeIcon.'px;">';
$output .= '<div class="pdd_l_15px pdd_r_15px mrgn_btn_25px" style="flex: 0 1 '.$sizeIcon.'px; height: '.$sizeIcon.'px;">';
$output .= html_print_image(
'images/console/icons/'.$icon.$color_icon.'.png',
'images/console/icons/'.$icon.$color_icon,
true,
['width' => $sizeIcon]
);

View File

@ -0,0 +1,465 @@
<?php
/**
* Widget Netflow Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget Netflow
* @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.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
/**
* Netflow.
*/
class Netflow extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
// Includes.
include_once $config['homedir'].'/include/functions_graph.php';
include_once $config['homedir'].'/include/class/NetworkMap.class.php';
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
// Positions.
$this->position = $this->getPositionWidget();
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Netflow');
// Name.
if (empty($this->name) === true) {
$this->name = 'netflow';
}
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
$values = $this->values;
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Default values.
if (isset($values['quantity']) === false) {
$values['quantity'] = 5;
}
// Default values.
if (isset($values['period']) === false) {
$values['period'] = SECONDS_1WEEK;
}
// Default values.
if (isset($values['max_values']) === false) {
$values['max_values'] = 10;
}
// Period.
$inputs[] = [
'label' => __('Interval'),
'arguments' => [
'name' => 'period',
'type' => 'interval',
'value' => $values['period'],
'nothing' => __('None'),
'nothing_value' => 0,
'style_icon' => 'flex-grow: 0',
],
];
$chart_types = netflow_get_chart_types();
$chart_types['usage_map'] = __('Usage map');
$inputs[] = [
'label' => __('Type graph'),
'arguments' => [
'name' => 'chart_type',
'type' => 'select',
'fields' => $chart_types,
'selected' => $values['chart_type'],
],
];
$aggregate_list = [
'srcip' => __('Src Ip Address'),
'dstip' => __('Dst Ip Address'),
'srcport' => __('Src Port'),
'dstport' => __('Dst Port'),
];
$inputs[] = [
'label' => __('Aggregated by'),
'id' => 'aggregated',
'arguments' => [
'name' => 'aggregate',
'type' => 'select',
'fields' => $aggregate_list,
'selected' => $values['aggregate'],
],
];
$inputs[] = [
'label' => __('Data to show'),
'id' => 'data_to_show',
'arguments' => [
'name' => 'action',
'type' => 'select',
'fields' => network_get_report_actions(),
'selected' => $values['action'],
],
];
$max_values = [
'2' => '2',
'5' => '5',
'10' => '10',
'15' => '15',
'20' => '20',
'25' => '25',
'50' => '50',
];
$inputs[] = [
'label' => __('Max values'),
'arguments' => [
'name' => 'max_values',
'type' => 'select',
'fields' => $max_values,
'selected' => $values['max_values'],
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost():array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['period'] = \get_parameter('period', 0);
$values['chart_type'] = \get_parameter('chart_type', '');
$values['aggregate'] = \get_parameter('aggregate');
$values['max_values'] = \get_parameter('max_values', 10);
$values['action'] = \get_parameter('action', 'srcip');
return $values;
}
/**
* Draw widget.
*
* @return string
*/
public function load()
{
ui_require_css_file('netflow_widget', 'include/styles/', true);
global $config;
$output = '';
$size = parent::getSize();
$start_date = (time() - $this->values['period']);
$end_date = time();
if ($this->values['chart_type'] === 'usage_map') {
$map_data = netflow_build_map_data(
$start_date,
$end_date,
$this->values['max_values'],
($this->values['action'] === 'talkers') ? 'srcip' : 'dstip'
);
$has_data = !empty($map_data['nodes']);
if ($has_data === true) {
$map_manager = new \NetworkMap($map_data);
$map_manager->printMap();
} else {
ui_print_info_message(__('No data to show'));
}
} else {
$netflowContainerClass = ($this->values['chart_type'] === 'netflow_data' || $this->values['chart_type'] === 'netflow_summary' || $this->values['chart_type'] === 'netflow_top_N') ? '' : 'white_box';
$filter = [
'aggregate' => $this->values['aggregate'],
'netflow_monitoring_interval' => 300,
];
$output .= html_print_input_hidden(
'selected_style_theme',
$config['style'],
true
);
$style = 'width:100%; height: 100%; border: none;';
if ($this->values['chart_type'] !== 'netflow_area') {
$style .= ' width: 95%;';
}
if ($size['width'] > $size['height']) {
$size['width'] = $size['height'];
}
// Draw the netflow chart.
$output .= html_print_div(
[
'class' => $netflowContainerClass,
'style' => $style,
'content' => netflow_draw_item(
$start_date,
$end_date,
12,
$this->values['chart_type'],
$filter,
$this->values['max_values'],
'',
'HTML',
0,
($size['width'] - 50),
($size['height'] - 20),
),
],
true
);
}
return $output;
}
/**
* Return aux javascript code for forms.
*
* @return string
*/
public function getFormJS()
{
return '
$(document).ready(function(){
//Limit 1 week
$("#period_select option").each(function(key, element){
if(element.value > 604800){
$(element).remove();
}
})
$("#period_manual option").each(function(key, element){
if(element.value > 604800){
$(element).remove();
}
});
$("#period_manual input").on("change", function(e){
if($("#hidden-period").val() > 604800) {
$(this).val(1);
$("#hidden-period").val(604800);
$("#period_manual select option").removeAttr("selected");
setTimeout(() => {
$("#period_default select option[value=\'604800\']").attr("selected", "selected");
$("#period_manual select option[value=\'604800\']").attr("selected", "selected");
$("#period_manual select").val(604800);
}, 500);
}
});
if($("#chart_type").val() === "usage_map") {
$("#data_to_show").show();
$("#aggregated").hide();
} else {
$("#data_to_show").hide();
$("#aggregated").show();
}
$("#chart_type").on("change", function(e){
if(this.value === "usage_map") {
$("#data_to_show").show();
$("#aggregated").hide();
} else {
$("#data_to_show").hide();
$("#aggregated").show();
}
});
});
';
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('Netflow');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'netflow';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 530,
];
return $size;
}
}

View File

@ -433,7 +433,14 @@ class ServiceMapWidget extends Widget
);
} else {
include_once $config['homedir'].'/include/graphs/functions_d3.php';
servicemap_print_sunburst($this->values['serviceId'], $size['width'], $size['height'], false);
$id_container = '#container_servicemap_'.$this->values['serviceId'].'_'.$this->cellId.' #sunburst';
servicemap_print_sunburst(
$this->values['serviceId'],
$size['width'],
$size['height'],
false,
$id_container
);
}
$output .= ob_get_clean();

Some files were not shown because too many files have changed in this diff Show More