mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Merge branch 'develop' into 'ent-7683-switch-en-consola-para-desactivar-la-actualizacion-automatica-de-la-ip-principal'
# Conflicts: # pandora_console/extras/mr/56.sql
This commit is contained in:
commit
33f9972293
pandora_agents
unix
DEBIAN
pandora_agentpandora_agent.redhat.specpandora_agent.specpandora_agent_installerpandora_agent_logrotatewin32
pandora_console
DEBIAN
extras/mr
general
godmode
include
ajax
class
config_process.phpfunctions.phpfunctions_agents.phpfunctions_alerts.phpfunctions_events.phpfunctions_html.phpfunctions_reporting.phpfunctions_ui.phpget_file.phplib
styles
mobile
operation
pandora_console.redhat.specpandora_console.rhel7.specpandora_console.specpandoradb.sqlpandoradb_data.sqlpandora_plugins/cisco_ironports
pandora_server
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.763-220715
|
||||
Version: 7.0NG.763-220729
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.763-220715"
|
||||
pandora_version="7.0NG.763-220729"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
@ -61,7 +61,7 @@ chmod 755 -R temp_package/DEBIAN
|
||||
#cp -aRf * temp_package/usr/share/pandora_agent/
|
||||
#but don't copy recursive the temp_package into temp_package
|
||||
|
||||
for item in `ls | grep -v NT4 | grep -v AIX | grep -v FreeBSD | grep -v HP-UX | grep -v SunOS | grep -v temp_package`
|
||||
for item in `ls | grep -v NT4 | grep -v AIX | grep -v FreeBSD | grep -v NetBSD | grep -v HP-UX | grep -v SunOS | grep -v Darwin | grep -v OpenWRT | grep -v pandorafms.agent_unix | grep -v temp_package`
|
||||
do
|
||||
#if [ \( $item != 'temp_package' \) -a \( $item != 'NT4' \) ]
|
||||
#then
|
||||
@ -133,9 +133,9 @@ echo "END"
|
||||
|
||||
echo "Make the package \"Pandorafms agent\"."
|
||||
if [ "$USE_DOCKER_APP" == "1" ]; then
|
||||
eval $DPKG_DEB --build temp_package
|
||||
eval $DPKG_DEB --root-owner-group --build temp_package
|
||||
else
|
||||
dpkg-deb --build temp_package
|
||||
dpkg-deb --root-owner-group --build temp_package
|
||||
fi
|
||||
mv temp_package.deb pandorafms.agent_unix_$pandora_version.deb
|
||||
|
||||
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.763';
|
||||
use constant AGENT_BUILD => '220715';
|
||||
use constant AGENT_BUILD => '220729';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -10,7 +10,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.763"
|
||||
PI_BUILD="220715"
|
||||
PI_BUILD="220729"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -7,4 +7,7 @@
|
||||
compress
|
||||
notifempty
|
||||
copytruncate
|
||||
postrotate
|
||||
/bin/systemctl restart pandora_agent_daemon
|
||||
endscript
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{220715}
|
||||
{220729}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.763 Build 220715")
|
||||
#define PANDORA_VERSION ("7.0NG.763 Build 220729")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -11,7 +11,7 @@ BEGIN
|
||||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.763(Build 220715))"
|
||||
VALUE "ProductVersion", "(7.0NG.763(Build 220729))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1 +0,0 @@
|
||||
/var/www/pandora_console/include/config.php
|
@ -1,10 +1,10 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.763-220715
|
||||
Version: 7.0NG.763-220729
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
Installed-Size: 42112
|
||||
Maintainer: Artica ST <deptec@artica.es>
|
||||
Homepage: http://pandorafms.org/
|
||||
Depends: php | php7.2, php7.2-snmp | php-snmp, php7.2-gd | php-gd, php7.2-mysqlnd | php-mysqlnd, php-db, php7.2-xmlrpc | php-xmlrpc, php-gettext, php7.2-curl | php-curl, graphviz, dbconfig-common, php7.2-ldap | php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc, php7.2-zip | php-zip
|
||||
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.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
#Pandora FMS- http:#pandorafms.com
|
||||
#Pandora FMS - https://pandorafms.com
|
||||
# ==================================================
|
||||
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
# Please see http:#pandorafms.org for full contribution list
|
||||
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.763-220715"
|
||||
pandora_version="7.0NG.763-220729"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
@ -94,17 +94,19 @@ echo "Make a \"temp_package\" temporary dir for job."
|
||||
mkdir -p temp_package
|
||||
if [ $package_pandora -eq 1 ]
|
||||
then
|
||||
mkdir -p temp_package/var/www/pandora_console
|
||||
mkdir -p temp_package/var/www/html/pandora_console
|
||||
mkdir -p temp_package/var/log/pandora
|
||||
mkdir -p temp_package/etc/logrotate.d
|
||||
mkdir -p temp_package/etc/init.d
|
||||
|
||||
echo "Make directory system tree for package."
|
||||
cp -R $(ls | grep -v temp_package | grep -v DEBIAN ) temp_package/var/www/pandora_console
|
||||
cp -R $(ls | grep -v temp_package | grep -v DEBIAN | grep -v pandorafms.console_$pandora_version.deb) temp_package/var/www/html/pandora_console
|
||||
cp -R DEBIAN temp_package
|
||||
cp -aRf pandora_console_logrotate_ubuntu temp_package/etc/logrotate.d/pandora_console
|
||||
find temp_package/var/www/pandora_console -name ".svn" | xargs rm -Rf
|
||||
rm -Rf temp_package/var/www/pandora_console/pandora_console.spec
|
||||
cp -aRf pandora_websocket_engine temp_package/etc/init.d/
|
||||
find temp_package/var/www/html/pandora_console -name ".svn" | xargs rm -Rf
|
||||
rm -Rf temp_package/var/www/html/pandora_console/pandora_console.spec
|
||||
chmod 755 -R temp_package/DEBIAN
|
||||
touch temp_package/var/www/pandora_console/include/config.php
|
||||
|
||||
|
||||
echo "Remove the SVN files and other temp files."
|
||||
@ -128,30 +130,31 @@ then
|
||||
echo "END"
|
||||
|
||||
echo "Calculate md5sum for md5sums package control file."
|
||||
for item in `find temp_package`
|
||||
FILES=`find temp_package`
|
||||
while read item
|
||||
do
|
||||
echo -n "."
|
||||
if [ ! -d $item ]
|
||||
if [ ! -d "$item" ]
|
||||
then
|
||||
echo $item | grep "DEBIAN" > /dev/null
|
||||
echo "$item" | grep "DEBIAN" > /dev/null
|
||||
#last command success
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
md5=`md5sum $item | cut -d" " -f1`
|
||||
md5=`md5sum "$item" | cut -d" " -f1`
|
||||
|
||||
#delete "temp_package" in the path
|
||||
final_path=${item#temp_package}
|
||||
echo $md5" "$final_path >> temp_package/DEBIAN/md5sums
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done < <(echo "$FILES")
|
||||
echo "END"
|
||||
|
||||
echo "Make the package \"Pandorafms console\"."
|
||||
if [ "$USE_DOCKER_APP" == "1" ]; then
|
||||
eval $DPKG_DEB --build temp_package
|
||||
eval $DPKG_DEB --root-owner-group --build temp_package
|
||||
else
|
||||
dpkg-deb --build temp_package
|
||||
dpkg-deb --root-owner-group --build temp_package
|
||||
fi
|
||||
mv temp_package.deb pandorafms.console_$pandora_version.deb
|
||||
fi
|
||||
|
@ -1,20 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo Change the user and group to /var/www/pandora_console.
|
||||
chmod -R u+rwX,g+rX,g-w,o-rwx /var/www/pandora_console
|
||||
chgrp www-data /var/www/pandora_console -R
|
||||
chown www-data /var/www/pandora_console -R
|
||||
if [ -d /var/www/html ]; then mv /var/www/pandora_console /var/www/html/; fi
|
||||
|
||||
echo Change the user and group to /var/www/html/pandora_console.
|
||||
chmod -R u+rwX,g+rX,g-w,o-rwx /var/www/html/pandora_console
|
||||
chgrp www-data /var/www/html/pandora_console -R
|
||||
chown www-data /var/www/html/pandora_console -R
|
||||
|
||||
if [ -f /etc/init.d/apache2 ]; then
|
||||
echo Restart the apache.
|
||||
/etc/init.d/apache2 restart
|
||||
fi
|
||||
|
||||
# Install pandora_websocket_engine service.
|
||||
cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/
|
||||
chmod +x /etc/init.d/pandora_websocket_engine
|
||||
|
||||
echo "You can now start the Pandora FMS Websocket service by executing"
|
||||
echo " /etc/init.d/pandora_websocket_engine start"
|
||||
|
||||
|
@ -41,4 +41,6 @@ ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`;
|
||||
|
||||
ALTER TABLE `tagente` ADD COLUMN `fixed_ip` TINYINT UNSIGNED NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `tevent_filter` ADD COLUMN `search_secondary_groups` INT NOT NULL DEFAULT 0;
|
||||
|
||||
COMMIT;
|
||||
|
@ -925,7 +925,9 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
|
||||
layout: '%M%nn%M:%S%nn%S',
|
||||
labels: ['', '', '', '', '', '', ''],
|
||||
onExpiry: function () {
|
||||
dt_events.draw(false);
|
||||
$("#table_events")
|
||||
.DataTable()
|
||||
.draw(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,98 +1,115 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<style>
|
||||
<link rel="stylesheet" href="<?php echo $config['homeurl']; ?>include/styles/pandora_minimal.css" type="text/css" />
|
||||
<link rel="stylesheet" href="<?php echo $config['homeurl']; ?>include/styles/js/jquery-ui.min.css" type="text/css" />
|
||||
<link rel="stylesheet" href="<?php echo $config['homeurl']; ?>include/styles/js/jquery-ui_custom.css" type="text/css" />
|
||||
<link rel="stylesheet" href="<?php echo $config['homeurl']; ?>include/styles/select2.min.css" type="text/css" />
|
||||
<link rel="stylesheet" href="<?php echo $config['homeurl']; ?>include/styles/pandora.css" type="text/css" />
|
||||
<script type='text/javascript' src='<?php echo $config['homeurl']; ?>include/javascript/jquery.current.js'></script>
|
||||
<script type='text/javascript' src='<?php echo $config['homeurl']; ?>include/javascript/jquery.pandora.js'></script>
|
||||
<script type='text/javascript' src='<?php echo $config['homeurl']; ?>include/javascript/jquery-ui.min.js'></script>
|
||||
<script type='text/javascript' src='<?php echo $config['homeurl']; ?>include/javascript/select2.min.js'></script>
|
||||
<script type='text/javascript' src='<?php echo $config['homeurl']; ?>include/javascript/pandora.js'></script>
|
||||
<script type='text/javascript' src='<?php echo $config['homeurl']; ?>include/javascript/pandora_ui.js'></script>
|
||||
|
||||
#alert_messages_na{
|
||||
z-index:2;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
width:650px;
|
||||
height: 400px;
|
||||
background:white;
|
||||
background-image:url('images/imagen-no-acceso.jpg');
|
||||
background-repeat:no-repeat;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow:4px 5px 10px 3px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
<style>
|
||||
#alert_messages_na {
|
||||
z-index: 2;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
width: 650px;
|
||||
height: 400px;
|
||||
background: white;
|
||||
background-repeat: no-repeat;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 4px 5px 10px 3px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.modalheade{
|
||||
text-align:center;
|
||||
width:100%;
|
||||
position:absolute;
|
||||
top:0;
|
||||
}
|
||||
.modalheadertex{
|
||||
color:#000;
|
||||
line-height: 40px;
|
||||
font-size: 23pt;
|
||||
margin-bottom:30px;
|
||||
}
|
||||
.modalclose{
|
||||
cursor:pointer;
|
||||
display:inline;
|
||||
float:right;
|
||||
margin-right:10px;
|
||||
margin-top:10px;
|
||||
}
|
||||
.modalconten{
|
||||
color:black;
|
||||
width:300px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
.modalcontenttex{
|
||||
text-align:left;
|
||||
color:black;
|
||||
font-size: 11pt;
|
||||
line-height:13pt;
|
||||
margin-bottom:30px;
|
||||
}
|
||||
.modalokbutto{
|
||||
cursor:pointer;
|
||||
text-align:center;
|
||||
display: inline-block;
|
||||
padding: 6px 45px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color:white;
|
||||
border: 1px solid #82b92e;
|
||||
}
|
||||
.modalokbuttontex{
|
||||
color:#82b92e;
|
||||
font-size:13pt;
|
||||
}
|
||||
.modalgobutto{
|
||||
cursor:pointer;
|
||||
text-align:center;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color:white;
|
||||
border: 1px solid #82b92e;
|
||||
}
|
||||
.modalgobuttontex{
|
||||
color:#82b92e;
|
||||
font-size:10pt;
|
||||
}
|
||||
.modalheade {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.modalheadertex {
|
||||
color: #000;
|
||||
line-height: 40px;
|
||||
font-size: 23pt;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.modalclose {
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.modalconten {
|
||||
color: black;
|
||||
width: 300px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.modalcontenttex {
|
||||
text-align: left;
|
||||
color: black;
|
||||
font-size: 11pt;
|
||||
line-height: 13pt;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.modalokbutto {
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
padding: 6px 45px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color: white;
|
||||
border: 1px solid #82b92e;
|
||||
}
|
||||
|
||||
.modalokbuttontex {
|
||||
color: #82b92e;
|
||||
font-size: 13pt;
|
||||
}
|
||||
|
||||
.modalgobutto {
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background-color: white;
|
||||
border: 1px solid #82b92e;
|
||||
}
|
||||
|
||||
.modalgobuttontex {
|
||||
color: #82b92e;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
|
||||
#opacidad{
|
||||
position:fixed;
|
||||
background:black;
|
||||
opacity:0.6;
|
||||
z-index:-1;
|
||||
left:0px;
|
||||
top:0px;
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
/*
|
||||
#opacidad {
|
||||
position: fixed;
|
||||
background: black;
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
/*
|
||||
.textodialog{
|
||||
margin-left: 0px;
|
||||
color:#333;
|
||||
@ -118,16 +135,16 @@ font-size:10pt;
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="alert_messages_na">
|
||||
|
||||
|
||||
<div id="alert_messages_na" style='background-image: url(<?php echo ui_get_full_url('images/imagen-no-acceso.jpg', false, false, false); ?>)'>
|
||||
|
||||
<div class='modalheade'>
|
||||
<img class='modalclose cerrar' src='<?php echo $config['homeurl']; ?>images/input_cross.png'>
|
||||
<img class='modalclose cerrar' src='<?php echo $config['homeurl']; ?>images/input_cross.png'>
|
||||
</div>
|
||||
|
||||
<div class='modalconten'>
|
||||
<div class='modalheadertex'>
|
||||
<?php echo __("You don't have access to this page"); ?>
|
||||
<div class='modalheadertex' style='font-size: 23pt'>
|
||||
<?php echo __('You do not have access to this page'); ?>
|
||||
</div>
|
||||
|
||||
<div class='modalcontenttex'>
|
||||
@ -141,7 +158,6 @@ font-size:10pt;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class='modalokbutto cerrar'>
|
||||
@ -149,18 +165,14 @@ font-size:10pt;
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="opacidad"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script>
|
||||
|
||||
$(".cerrar").click(function(){
|
||||
window.location=".";
|
||||
$(".cerrar").click(function() {
|
||||
window.location = "<?php echo $config['homeurl']; ?>";
|
||||
});
|
||||
|
||||
$('div#page').css('background-color','#d3d3d3');
|
||||
|
||||
</script>
|
||||
$('div#page').css('background-color', '#d3d3d3');
|
||||
</script>
|
||||
|
@ -89,6 +89,7 @@ if ($id) {
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = $filter['search_secondary_groups'];
|
||||
$custom_data = $filter['custom_data'];
|
||||
$custom_data_filter_type = $filter['custom_data_filter_type'];
|
||||
|
||||
@ -126,6 +127,7 @@ if ($id) {
|
||||
$tag_without_json = $tag_without_json_clean = json_encode([]);
|
||||
$tag_without_base64 = base64_encode($tag_without_json);
|
||||
$filter_only_alert = '';
|
||||
$search_secondary_groups = 0;
|
||||
}
|
||||
|
||||
if ($update || $create) {
|
||||
@ -167,6 +169,8 @@ if ($update || $create) {
|
||||
$tag_without_json = io_safe_input(base64_decode($tag_without_base64));
|
||||
|
||||
$filter_only_alert = get_parameter('filter_only_alert', '');
|
||||
$search_secondary_groups = get_parameter('search_secondary_groups', 0);
|
||||
|
||||
$custom_data = get_parameter('custom_data', '');
|
||||
$custom_data_filter_type = get_parameter('custom_data_filter_type', '');
|
||||
|
||||
@ -193,6 +197,7 @@ if ($update || $create) {
|
||||
'id_extra' => $id_extra,
|
||||
'user_comment' => $user_comment,
|
||||
'filter_only_alert' => $filter_only_alert,
|
||||
'search_secondary_groups' => $search_secondary_groups,
|
||||
'custom_data' => $custom_data,
|
||||
'custom_data_filter_type' => $custom_data_filter_type,
|
||||
];
|
||||
|
@ -662,7 +662,7 @@ class DiscoveryTaskList extends HTML
|
||||
$data[0] .= '\'';
|
||||
if ($task['type'] == DISCOVERY_HOSTDEVICES) {
|
||||
$title = __('Are you sure?');
|
||||
$message = 'This action will rescan the target networks.';
|
||||
$message = __('This action will rescan the target networks.');
|
||||
$data[0] .= ', {title: \''.$title.'\', message: \''.$message.'\'}';
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ $get_actions_module = (bool) get_parameter('get_actions_module');
|
||||
$show_update_action_menu = (bool) get_parameter('show_update_action_menu');
|
||||
$get_agent_alerts_agent_view = (bool) get_parameter('get_agent_alerts_agent_view');
|
||||
$resize_event_week = (bool) get_parameter('resize_event_week');
|
||||
$get_agent_alerts_datatable = (bool) get_parameter('get_agent_alerts_datatable', 0);
|
||||
$alert_validate = (bool) get_parameter('alert_validate', false);
|
||||
|
||||
if ($get_agent_alerts_simple) {
|
||||
$id_agent = (int) get_parameter('id_agent');
|
||||
@ -620,4 +622,325 @@ if ($resize_event_week === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($alert_validate === true) {
|
||||
include_once 'operation/agentes/alerts_status.functions.php';
|
||||
$all_groups = get_parameter('all_groups');
|
||||
$alert_ids = get_parameter('alert_ids', '');
|
||||
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
$result = validateAlert($alert_ids);
|
||||
} else {
|
||||
$result = ui_print_error_message(__('Insufficient permissions to validate alerts'), '', true);
|
||||
}
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_agent_alerts_datatable === true) {
|
||||
// Datatables offset, limit and order.
|
||||
$filter_alert = get_parameter('filter', []);
|
||||
unset($filter_alert[0]);
|
||||
$start = (int) get_parameter('start', 0);
|
||||
$length = (int) get_parameter('length', $config['block_size']);
|
||||
$order = get_datatable_order(true);
|
||||
$url = get_parameter('url', '#');
|
||||
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
$idGroup = $filter_alert['ag_group'];
|
||||
$tag_filter = $filter_alert['tag_filter'];
|
||||
$action_filter = $filter_alert['action'];
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
include_once $config['homedir'].'/include/functions_agents.php';
|
||||
include_once $config['homedir'].'/operation/agentes/alerts_status.functions.php';
|
||||
include_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
||||
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
||||
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||
|
||||
$all_groups = get_parameter('all_groups');
|
||||
$idAgent = (int) get_parameter('id_agent');
|
||||
|
||||
$sortField = $order['field'];
|
||||
$sort = $order['direction'];
|
||||
$selected = true;
|
||||
$selectModuleUp = false;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'module':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectModuleasc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectModuledesc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectTemplateasc = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectTemplatedesc = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'lastFired':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectLastFireddesc = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'agent':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectLastFireddesc = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
$order = [
|
||||
'field' => 'times_fired',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'desc':
|
||||
$selectLastFireddesc = $selected;
|
||||
$order = [
|
||||
'field' => 'times_fired',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$selectDisabledasc = '';
|
||||
$selectDisableddesc = '';
|
||||
$selectModuleasc = $selected;
|
||||
$selectModuledesc = false;
|
||||
$selectTemplateasc = false;
|
||||
$selectTemplatedesc = false;
|
||||
$selectLastFiredasc = false;
|
||||
$selectLastFireddesc = false;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($free_search_alert != '') {
|
||||
$whereAlertSimple = 'AND ('.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE "%'.$free_search_alert.'%") OR '.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search_alert.'%")) OR '.'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search_alert.'%")) OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%'.$free_search_alert.'%") OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE alias LIKE "%'.$free_search_alert.'%")'.')';
|
||||
} else {
|
||||
$whereAlertSimple = '';
|
||||
}
|
||||
|
||||
// Add checks for user ACL.
|
||||
$groups = users_get_groups($config['id_user'], $access);
|
||||
$id_groups = array_keys($groups);
|
||||
|
||||
if (empty($id_groups)) {
|
||||
$whereAlertSimple .= ' AND (1 = 0) ';
|
||||
} else {
|
||||
$whereAlertSimple .= sprintf(
|
||||
' AND id_agent_module IN (
|
||||
SELECT tam.id_agente_modulo
|
||||
FROM tagente_modulo tam
|
||||
WHERE tam.id_agente IN (SELECT ta.id_agente
|
||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
|
||||
ta.id_agente = tasg.id_agent
|
||||
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
|
||||
implode(',', $id_groups),
|
||||
implode(',', $id_groups)
|
||||
);
|
||||
}
|
||||
|
||||
$alerts = [];
|
||||
if ($agent_view_page === true) {
|
||||
$options_simple = ['order' => $order];
|
||||
} else {
|
||||
$options_simple = [
|
||||
'order' => $order,
|
||||
'limit' => $length,
|
||||
'offset' => $start,
|
||||
];
|
||||
}
|
||||
|
||||
if ($idAgent !== 0) {
|
||||
$filter_alert['disabled'] = 'all_enabled';
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
} else {
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
|
||||
|
||||
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], $access, false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($alerts['alerts_simple']) {
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$data[] = ui_format_alert_row($alert, true, $url, 'font-size: 7pt;');
|
||||
}
|
||||
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $row) {
|
||||
// Transforms array of arrays $data into an array
|
||||
// of objects, making a post-process of certain fields.
|
||||
$tmp = new stdClass();
|
||||
|
||||
// Standby.
|
||||
$tmp->policy = $row[0];
|
||||
$tmp->standby = $row[1];
|
||||
$tmp->force = $row[2];
|
||||
$tmp->agent = $row[3];
|
||||
$tmp->module = $row[4];
|
||||
$tmp->template = $row[5];
|
||||
$tmp->action = $row[6];
|
||||
$tmp->lastFired = $row[7];
|
||||
$tmp->status = $row[8];
|
||||
$tmp->validate = $row[9];
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $countAlertsSimple,
|
||||
'recordsFiltered' => $countAlertsSimple,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (\Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -97,29 +97,27 @@ if ($get_comments === true) {
|
||||
$eventsGrouped = [];
|
||||
// Consider if the event is grouped.
|
||||
$whereGrouped = '1=1';
|
||||
if (isset($event['event_rep']) === true && $event['event_rep'] > 0) {
|
||||
// Default grouped message filtering (evento and estado).
|
||||
$whereGrouped = sprintf(
|
||||
'`evento` = "%s" AND `estado` = "%s" AND `event_type` = "%s" ',
|
||||
$event['evento'],
|
||||
$event['estado'],
|
||||
$event['event_type']
|
||||
// Default grouped message filtering (evento and estado).
|
||||
$whereGrouped = sprintf(
|
||||
'`evento` = "%s" AND `estado` = "%s" AND `event_type` = "%s" ',
|
||||
$event['evento'],
|
||||
$event['estado'],
|
||||
$event['event_type']
|
||||
);
|
||||
|
||||
// If id_agente is reported, filter the messages by them as well.
|
||||
if ((int) $event['id_agente'] > 0) {
|
||||
$whereGrouped .= sprintf(
|
||||
' AND `id_agente` = %d',
|
||||
(int) $event['id_agente']
|
||||
);
|
||||
}
|
||||
|
||||
// If id_agente is reported, filter the messages by them as well.
|
||||
if ((int) $event['id_agente'] > 0) {
|
||||
$whereGrouped .= sprintf(
|
||||
' AND `id_agente` = %d',
|
||||
(int) $event['id_agente']
|
||||
);
|
||||
}
|
||||
|
||||
if ((int) $event['id_agentmodule'] > 0) {
|
||||
$whereGrouped .= sprintf(
|
||||
' AND `id_agentmodule` = %d',
|
||||
(int) $event['id_agentmodule']
|
||||
);
|
||||
}
|
||||
if ((int) $event['id_agentmodule'] > 0) {
|
||||
$whereGrouped .= sprintf(
|
||||
' AND `id_agentmodule` = %d',
|
||||
(int) $event['id_agentmodule']
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -358,6 +356,7 @@ if ($save_event_filter) {
|
||||
io_json_mb_encode([])
|
||||
);
|
||||
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
||||
$values['search_secondary_groups'] = get_parameter('search_secondary_groups');
|
||||
$values['id_group_filter'] = get_parameter('id_group_filter');
|
||||
$values['date_from'] = get_parameter('date_from');
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
@ -414,6 +413,7 @@ if ($update_event_filter) {
|
||||
io_json_mb_encode([])
|
||||
);
|
||||
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
||||
$values['search_secondary_groups'] = get_parameter('search_secondary_groups');
|
||||
$values['id_group_filter'] = get_parameter('id_group_filter');
|
||||
$values['date_from'] = get_parameter('date_from');
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
@ -459,31 +459,32 @@ if ($get_filter_values) {
|
||||
|
||||
if ($event_filter === false) {
|
||||
$event_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
'module_search' => '',
|
||||
'filter_only_alert' => '-1',
|
||||
'user_comment' => '',
|
||||
'id_extra' => '',
|
||||
'id_user_ack' => '',
|
||||
'date_from' => '',
|
||||
'time_from' => '',
|
||||
'date_to' => '',
|
||||
'time_to' => '',
|
||||
'severity' => '',
|
||||
'event_type' => '',
|
||||
'group_rep' => 0,
|
||||
'id_group' => 0,
|
||||
'id_group_filter' => 0,
|
||||
'group_name' => 'All',
|
||||
'text_agent' => '',
|
||||
'id_agent' => 0,
|
||||
'id_name' => 'None',
|
||||
'filter_id' => 0,
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
'module_search' => '',
|
||||
'filter_only_alert' => '-1',
|
||||
'search_secondary_groups' => 0,
|
||||
'user_comment' => '',
|
||||
'id_extra' => '',
|
||||
'id_user_ack' => '',
|
||||
'date_from' => '',
|
||||
'time_from' => '',
|
||||
'date_to' => '',
|
||||
'time_to' => '',
|
||||
'severity' => '',
|
||||
'event_type' => '',
|
||||
'group_rep' => 0,
|
||||
'id_group' => 0,
|
||||
'id_group_filter' => 0,
|
||||
'group_name' => 'All',
|
||||
'text_agent' => '',
|
||||
'id_agent' => 0,
|
||||
'id_name' => 'None',
|
||||
'filter_id' => 0,
|
||||
];
|
||||
} else {
|
||||
$event_filter['module_search'] = io_safe_output(
|
||||
@ -651,6 +652,8 @@ function load_form_filter() {
|
||||
$("#hidden-tag_without").val(val);
|
||||
if (i == 'filter_only_alert')
|
||||
$("#filter_only_alert").val(val);
|
||||
if (i == 'search_secondary_groups')
|
||||
$("#checkbox-search_secondary_groups").val(val);
|
||||
if (i == 'id_group_filter')
|
||||
$("#id_group_filter").val(val);
|
||||
if (i == 'source')
|
||||
@ -893,6 +896,7 @@ function save_new_filter() {
|
||||
"tag_with": Base64.decode($("#hidden-tag_with").val()),
|
||||
"tag_without": Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
|
||||
"id_group_filter": $("#id_group_filter").val(),
|
||||
"date_from": $("#text-date_from").val(),
|
||||
"time_from": $("#text-time_from").val(),
|
||||
@ -968,6 +972,7 @@ function save_update_filter() {
|
||||
"tag_with" : Base64.decode($("#hidden-tag_with").val()),
|
||||
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
|
||||
"id_group_filter": $("#id_group_filter").val(),
|
||||
"date_from": $("#text-date_from").val(),
|
||||
"time_from": $("#text-time_from").val(),
|
||||
@ -2469,6 +2474,7 @@ if ($get_events_fired) {
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'filter_only_alert' => -1,
|
||||
'search_secondary_groups' => 0,
|
||||
'source' => '',
|
||||
'id_extra' => '',
|
||||
'user_comment' => '',
|
||||
|
@ -2483,14 +2483,12 @@ class ConsoleSupervisor
|
||||
SERVER_TYPE_ENTERPRISE_SATELLITE
|
||||
)
|
||||
);
|
||||
|
||||
$missed = 0;
|
||||
|
||||
if (is_array($server_version_list) === true) {
|
||||
foreach ($server_version_list as $server) {
|
||||
if (strpos(
|
||||
$server['version'],
|
||||
(string) floor($config['current_package'])
|
||||
(string) floor((int) $config['current_package'])
|
||||
) === false
|
||||
) {
|
||||
$missed++;
|
||||
|
@ -252,6 +252,7 @@ class TreeService extends Tree
|
||||
protected function getProcessedServices()
|
||||
{
|
||||
$is_favourite = $this->getServiceFavouriteFilter();
|
||||
$service_search = $this->getServiceNameSearchFilter();
|
||||
|
||||
if (users_can_manage_group_all('AR')) {
|
||||
$groups_acl = '';
|
||||
@ -259,6 +260,16 @@ class TreeService extends Tree
|
||||
$groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')';
|
||||
}
|
||||
|
||||
$exclude_children = 'ts.id NOT IN (
|
||||
SELECT DISTINCT id_service_child
|
||||
FROM tservice_element
|
||||
WHERE id_server_meta = 0
|
||||
)';
|
||||
|
||||
if ($service_search !== '') {
|
||||
$exclude_children = '1=1';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT
|
||||
ts.id,
|
||||
@ -277,15 +288,14 @@ class TreeService extends Tree
|
||||
FROM tservice ts
|
||||
LEFT JOIN tservice_element tse
|
||||
ON tse.id_service = ts.id
|
||||
WHERE ts.id NOT IN (
|
||||
SELECT DISTINCT id_service_child
|
||||
FROM tservice_element
|
||||
WHERE id_server_meta = 0
|
||||
)
|
||||
WHERE %s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
GROUP BY ts.id',
|
||||
$exclude_children,
|
||||
$is_favourite,
|
||||
$service_search,
|
||||
$groups_acl
|
||||
);
|
||||
|
||||
@ -722,6 +732,23 @@ class TreeService extends Tree
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve SQL filter for current filter
|
||||
*
|
||||
* @return string SQL filter.
|
||||
*/
|
||||
protected function getServiceNameSearchFilter()
|
||||
{
|
||||
if (isset($this->filter['searchService']) === true
|
||||
&& empty($this->filter['searchService']) === false
|
||||
) {
|
||||
return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')";
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overwrites partial functionality of general Tree.class.
|
||||
*
|
||||
|
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC220715';
|
||||
$build_version = 'PC220729';
|
||||
$pandora_version = 'v7.0NG.763';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
@ -5996,6 +5996,18 @@ function send_test_email(
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Microtime float number.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
function microtime_float()
|
||||
{
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
return ((float) $usec + (float) $sec);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return array of ancestors of item, given array.
|
||||
*
|
||||
|
@ -369,7 +369,11 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
||||
}
|
||||
|
||||
// Filter by agents id.
|
||||
$id_agents_list = implode(',', $id_agent);
|
||||
if (is_array($id_agent) === true && empty($id_agent) === false) {
|
||||
$id_agents_list = implode(',', $id_agent);
|
||||
} else {
|
||||
$id_agents_list = $id_agent;
|
||||
}
|
||||
|
||||
if ($id_agents_list === '') {
|
||||
$id_agents_list = '0';
|
||||
|
@ -2109,7 +2109,7 @@ function get_group_alerts(
|
||||
|
||||
if (is_array($filter)) {
|
||||
$disabled = $filter['disabled'];
|
||||
if (isset($filter['standby'])) {
|
||||
if ((isset($filter['standby']) === true) && ($filter['standby'] !== '')) {
|
||||
$filter = $group_query.' AND talert_template_modules.standby = "'.$filter['standby'].'"';
|
||||
} else {
|
||||
$filter = $group_query;
|
||||
|
@ -626,6 +626,7 @@ function events_update_status($id_evento, $status, $filter=null)
|
||||
* 'tag_with'
|
||||
* 'tag_without'
|
||||
* 'filter_only_alert'
|
||||
* 'search_secondary_groups'
|
||||
* 'module_search'
|
||||
* 'group_rep'
|
||||
* 'server_id'
|
||||
@ -904,11 +905,18 @@ function events_get_all(
|
||||
$groups = [ $groups ];
|
||||
}
|
||||
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(',', $groups),
|
||||
join(',', $groups)
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(',', $groups),
|
||||
join(',', $groups)
|
||||
);
|
||||
} else {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo IN (%s)',
|
||||
join(',', $groups)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Skip system messages if user is not PM.
|
||||
@ -982,11 +990,18 @@ function events_get_all(
|
||||
$EW_groups = users_get_groups($config['id_user'], 'EW', true, true);
|
||||
|
||||
// Get groups where user have ER grants.
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
|
||||
join(', ', array_keys($ER_groups)),
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
|
||||
join(', ', array_keys($ER_groups)),
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
} else {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo IN ( %s )',
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare agent join sql filters.
|
||||
@ -1396,19 +1411,33 @@ function events_get_all(
|
||||
) {
|
||||
$tgrupo_join = 'INNER';
|
||||
if (is_array($groups) === true) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
|
||||
join(', ', $groups),
|
||||
join(', ', $groups)
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))',
|
||||
join(', ', $groups),
|
||||
join(', ', $groups)
|
||||
);
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))',
|
||||
join(', ', $groups)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group = %s)',
|
||||
$groups,
|
||||
$groups
|
||||
);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group = %s)',
|
||||
$groups,
|
||||
$groups
|
||||
);
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' (te.id_grupo = tg.id_grupo AND tg.id_grupo = %s)',
|
||||
$groups
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$tgrupo_join_filters[] = ' te.id_grupo = tg.id_grupo';
|
||||
@ -1418,7 +1447,9 @@ function events_get_all(
|
||||
$event_lj = '';
|
||||
if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) {
|
||||
db_process_sql('SET group_concat_max_len = 9999999');
|
||||
$event_lj = events_get_secondary_groups_left_join($table);
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$event_lj = events_get_secondary_groups_left_join($table);
|
||||
}
|
||||
}
|
||||
|
||||
$group_selects = '';
|
||||
@ -2199,9 +2230,9 @@ function events_create_event(
|
||||
'id_usuario' => $id_user,
|
||||
'id_grupo' => $id_group,
|
||||
'estado' => $status,
|
||||
'timestamp' => 'NOW()',
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
'evento' => $event,
|
||||
'utimestamp' => 'UNIX_TIMESTAMP(NOW())',
|
||||
'utimestamp' => time(),
|
||||
'event_type' => $event_type,
|
||||
'id_agentmodule' => $id_agent_module,
|
||||
'id_alert_am' => $id_aam,
|
||||
|
@ -1013,13 +1013,17 @@ function html_print_select(
|
||||
if(count_shift_'.$id.' == 2 ){
|
||||
if(shift_array_'.$id.'[0] <= shift_array_'.$id.'[1]) {
|
||||
for (var i = shift_array_'.$id.'[0]; i <= shift_array_'.$id.'[1]; i++) {
|
||||
var option_value = $("#'.$id.' option").eq(i).val();
|
||||
options_selecteds_'.$id.'.push(option_value);
|
||||
if ($("#'.$id.' option").eq(i).text().includes($(".select2-search__field").val()) == true) {
|
||||
var option_value = $("#'.$id.' option").eq(i).val();
|
||||
options_selecteds_'.$id.'.push(option_value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var i = shift_array_'.$id.'[0]; i >= shift_array_'.$id.'[1]; i--) {
|
||||
var option_value = $("#'.$id.' option").eq(i).val();
|
||||
options_selecteds_'.$id.'.push(option_value);
|
||||
if ($("#'.$id.' option").eq(i).text().includes($(".select2-search__field").val()) == true) {
|
||||
var option_value = $("#'.$id.' option").eq(i).val();
|
||||
options_selecteds_'.$id.'.push(option_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6134,3 +6138,36 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[])
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a simple 'Go Back' button.
|
||||
*
|
||||
* @param string $url Destination Url.
|
||||
* @param array $options Options.
|
||||
* `button_class`: Class for button. 'w100p' by default.
|
||||
* `title`: Title of the button. 'Go Back' by default.
|
||||
* `action_class`: Class of icon of button. 'cancel' by default.
|
||||
* @param boolean $return If true, return a formed HTML element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function html_print_go_back_button(string $url, array $options=[], bool $return=false)
|
||||
{
|
||||
$output = html_print_div(
|
||||
[
|
||||
'class' => ($options['button_class'] ?? 'w100p'),
|
||||
'content' => html_print_button(
|
||||
($options['title'] ?? __('Go back')),
|
||||
'go_back',
|
||||
false,
|
||||
'window.location.href = \''.$url.'\'',
|
||||
'class="sub '.($options['action_class'] ?? ' cancel').' right"',
|
||||
true
|
||||
),
|
||||
],
|
||||
$return
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -7079,6 +7079,10 @@ function reporting_sql($report, $content)
|
||||
$historical_db = db_get_value_sql(
|
||||
'SELECT historical_db from treport_content where id_rc ='.$content['id_rc']
|
||||
);
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$historical_db = $content['historical_db'];
|
||||
}
|
||||
} else {
|
||||
$historical_db = $content['historical_db'];
|
||||
}
|
||||
@ -11121,7 +11125,7 @@ function reporting_get_group_stats($id_group=0, $access='AR', $recursion=true)
|
||||
*
|
||||
* @return array Group statistics
|
||||
*/
|
||||
function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_permissions=false)
|
||||
function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_permissions=false, $recursive=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -11165,6 +11169,8 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
|
||||
$id_group = array_keys(
|
||||
users_get_groups($config['id_user'], $access, false)
|
||||
);
|
||||
} else if ($recursive === true) {
|
||||
$id_group = groups_get_children_ids($id_group);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
@ -11295,7 +11301,7 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
|
||||
$group_stat = db_get_all_rows_sql($sql);
|
||||
$data = [
|
||||
'monitor_checks' => (int) $group_stat[0]['modules'],
|
||||
'monitor_alerts' => (int) groups_monitor_alerts($group_array),
|
||||
'monitor_alerts' => (int) groups_monitor_alerts($group_stat[0]['id_group']),
|
||||
'monitor_alerts_fired' => (int) $group_stat[0]['alerts_fired'],
|
||||
'monitor_alerts_fire_count' => (int) $group_stat[0]['alerts_fired'],
|
||||
'monitor_ok' => (int) $group_stat[0]['normal'],
|
||||
@ -11309,10 +11315,33 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
|
||||
'agent_warning' => (int) $group_stat[0]['agents_warnings'],
|
||||
'agent_critical' => (int) $group_stat[0]['agents_critical'],
|
||||
'total_checks' => (int) $group_stat[0]['modules'],
|
||||
'total_alerts' => (int) groups_monitor_alerts($group_array),
|
||||
'total_alerts' => (int) groups_monitor_alerts($group_stat[0]['id_group']),
|
||||
'total_agents' => (int) $group_stat[0]['agents'],
|
||||
'utimestamp' => (int) $group_stat[0]['utimestamp'],
|
||||
];
|
||||
|
||||
if ($recursive === true) {
|
||||
unset($group_stat[0]);
|
||||
foreach ($group_stat as $value) {
|
||||
$data['monitor_checks'] = ($data['monitor_checks'] + $value['modules']);
|
||||
$data['monitor_alerts'] = ($data['monitor_alerts'] + groups_monitor_alerts($value['id_group']));
|
||||
$data['monitor_alerts_fired'] = ($data['monitor_alerts_fired'] + $value['alerts_fired']);
|
||||
$data['monitor_alerts_fire_count'] = ($data['monitor_alerts_fire_count'] + $value['alerts_fired']);
|
||||
$data['monitor_ok'] = ($data['monitor_ok'] + $value['normal']);
|
||||
$data['monitor_warning'] = ($data['monitor_warning'] + $value['warning']);
|
||||
$data['monitor_critical'] = ($data['monitor_critical'] + $value['critical']);
|
||||
$data['monitor_unknown'] = ($data['monitor_unknown'] + $value['unknown']);
|
||||
$data['monitor_not_init'] = ($data['monitor_not_init'] + $value['non-init']);
|
||||
$data['agent_not_init'] = ($data['agent_not_init'] + $value['agents_not_init']);
|
||||
$data['agent_unknown'] = ($data['agent_unknown'] + $value['agents_unknown']);
|
||||
$data['agent_ok'] = ($data['agent_ok'] + $value['agents_normal']);
|
||||
$data['agent_warning'] = ($data['agent_warning'] + $value['agents_warnings']);
|
||||
$data['agent_critical'] = ($data['agent_critical'] + $value['agents_critical']);
|
||||
$data['total_checks'] = ($data['total_checks'] + $value['modules']);
|
||||
$data['total_alerts'] = ($data['total_alerts'] + groups_monitor_alerts($value['id_group']));
|
||||
$data['total_agents'] = ($data['total_agents'] + $value['agents']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1178,8 +1178,14 @@ function ui_format_alert_row(
|
||||
$id_agent = modules_get_agentmodule_agent($alert['id_agent_module']);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true || !can_user_access_node()) {
|
||||
$data[$index['agent_name']] = ui_print_truncate_text($agent_name, 'agent_small', false, true, true, '[…]', '');
|
||||
if (is_metaconsole() === true) {
|
||||
// Do not show link if user cannot access node
|
||||
if ((bool) can_user_access_node() === true) {
|
||||
$url = $server['server_url'].'/index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$agente['id_agente'];
|
||||
$data[$index['agent_name']] .= '<a href="'.$url.'">'.'<b><span class="bolder" title="'.$agente['nombre'].'">'.$agente['alias'].'</span></b></a>';
|
||||
} else {
|
||||
$data[$index['agent_name']] .= '<b><span class="bolder" title="'.$agente['nombre'].'">'.$agente['alias'].'</span></b>';
|
||||
}
|
||||
} else {
|
||||
if ($agent_style !== false) {
|
||||
$data[$index['agent_name']] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'"> <span class="bolder" title ="'.$agente['nombre'].'">'.$agente['alias'].'</span></a>';
|
||||
@ -3173,6 +3179,7 @@ function ui_progress_extend(
|
||||
* 'class' => th class.
|
||||
* 'style' => th style.
|
||||
* 'text' => 'column1'.
|
||||
* 'title' => 'column title'.
|
||||
* ]
|
||||
* ],
|
||||
* 'columns' => [
|
||||
@ -3208,12 +3215,15 @@ function ui_progress_extend(
|
||||
* 'option2'
|
||||
* ...
|
||||
* ]
|
||||
* 'no_toggle' => Pint form withouth UI toggle.
|
||||
* ]
|
||||
* ],
|
||||
* '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.
|
||||
@ -3392,16 +3402,18 @@ function ui_print_datatable(array $parameters)
|
||||
$filter .= '</li>';
|
||||
|
||||
$filter .= '</ul><div id="both"></div></form>';
|
||||
$filter = ui_toggle(
|
||||
$filter,
|
||||
__('Filter'),
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
'white_box white_box_opened',
|
||||
'no-border'
|
||||
);
|
||||
if (isset($parameters['form']['no_toggle']) === false && ($parameters['form']['no_toggle'] !== true)) {
|
||||
$filter = ui_toggle(
|
||||
$filter,
|
||||
__('Filter'),
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
'white_box white_box_opened',
|
||||
'no-border'
|
||||
);
|
||||
}
|
||||
} else if (isset($parameters['form_html'])) {
|
||||
$filter = ui_toggle(
|
||||
$parameters['form_html'],
|
||||
@ -3416,7 +3428,20 @@ function ui_print_datatable(array $parameters)
|
||||
}
|
||||
|
||||
// Languages.
|
||||
$processing = __('Processing');
|
||||
$processing = '<div class=\'processing-datatables-inside\'>';
|
||||
$processing .= '<i>'.__('Processing').'</i> ';
|
||||
$processing .= str_replace(
|
||||
'"',
|
||||
"'",
|
||||
html_print_image(
|
||||
'images/spinner.gif',
|
||||
true
|
||||
)
|
||||
);
|
||||
$processing .= '</div>';
|
||||
|
||||
$zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found');
|
||||
$emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table');
|
||||
|
||||
// Extra html.
|
||||
$extra = '';
|
||||
@ -3441,6 +3466,7 @@ function ui_print_datatable(array $parameters)
|
||||
foreach ($names as $column) {
|
||||
if (is_array($column)) {
|
||||
$table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" ';
|
||||
$table .= 'title="'.__($column['title']).'" ';
|
||||
$table .= ' style="'.$column['style'].'">'.__($column['text']);
|
||||
$table .= $column['extra'];
|
||||
$table .= '</th>';
|
||||
@ -3500,7 +3526,9 @@ function ui_print_datatable(array $parameters)
|
||||
responsive: true,
|
||||
dom: "plfrtiBp",
|
||||
language: {
|
||||
processing:"'.$processing.'"
|
||||
processing:"'.$processing.'",
|
||||
zeroRecords:"'.$zeroRecords.'",
|
||||
emptyYable:"'.$emptyTable.'",
|
||||
},
|
||||
buttons: '.$parameters['csv'].'== 1 ? [
|
||||
{
|
||||
@ -3524,6 +3552,10 @@ function ui_print_datatable(array $parameters)
|
||||
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();
|
||||
}
|
||||
|
||||
if (json.error) {
|
||||
console.error(json.error);
|
||||
$("#error-'.$table_id.'").html(json.error);
|
||||
@ -3570,6 +3602,18 @@ function ui_print_datatable(array $parameters)
|
||||
}
|
||||
},
|
||||
data: function (data) {
|
||||
if($("#'.$form_id.'_search_bt") != undefined) {
|
||||
var loading = \''.html_print_image(
|
||||
'images/spinner.gif',
|
||||
true,
|
||||
[
|
||||
'id' => $form_id.'_loading',
|
||||
'class' => 'loading-search-datatables-button',
|
||||
]
|
||||
).'\';
|
||||
$("#'.$form_id.'_search_bt").parent().append(loading);
|
||||
}
|
||||
|
||||
inputs = $("#'.$form_id.' :input");
|
||||
|
||||
values = {};
|
||||
|
@ -46,6 +46,12 @@ $hash = get_parameter('hash');
|
||||
$file_raw = get_parameter('file');
|
||||
|
||||
$file = base64_decode(urldecode($file_raw));
|
||||
// Avoid possible inifite loop with referer.
|
||||
if (isset($_SERVER['HTTP_ORIGIN']) === false || (isset($_SERVER['HTTP_ORIGIN']) === true && $_SERVER['HTTP_REFERER'] === $_SERVER['HTTP_ORIGIN'].$_SERVER['REQUEST_URI'])) {
|
||||
$refererPath = ui_get_full_url('index.php');
|
||||
} else {
|
||||
$refererPath = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
if (empty($file) === true || empty($hash) === true || $hash !== md5($file_raw.$config['server_unique_identifier']) || isset($_SERVER['HTTP_REFERER']) === false) {
|
||||
$errorMessage = __('Security error. Please contact the administrator.');
|
||||
@ -84,12 +90,6 @@ if (empty($file) === true || empty($hash) === true || $hash !== md5($file_raw.$c
|
||||
|
||||
if (empty($downloadable_file) === true || file_exists($downloadable_file) === false) {
|
||||
$errorMessage = __('File is missing in disk storage. Please contact the administrator.');
|
||||
// Avoid possible inifite loop with referer.
|
||||
if (isset($_SERVER['HTTP_ORIGIN']) === true && $_SERVER['HTTP_REFERER'] === $_SERVER['HTTP_ORIGIN'].$_SERVER['REQUEST_URI']) {
|
||||
$refererPath = ui_get_full_url('index.php');
|
||||
} else {
|
||||
$refererPath = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
} else {
|
||||
// Everything went well.
|
||||
header('Content-type: aplication/octet-stream;');
|
||||
@ -106,11 +106,12 @@ if (empty($file) === true || empty($hash) === true || $hash !== md5($file_raw.$c
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var refererPath = '<?php echo $refererPath; ?>';
|
||||
var errorFileOutput = '<?php echo $errorMessage; ?>';
|
||||
|
||||
if(refererPath != ''){
|
||||
document.body.innerHTML = `<form action="` + refererPath + `" name="failedReturn" method="post" style="display:none;">
|
||||
<input type="hidden" name="errorFileOutput" value="` + errorFileOutput + `" />
|
||||
</form>`;
|
||||
|
||||
document.forms['failedReturn'].submit();
|
||||
}
|
||||
}, false);
|
||||
</script>
|
||||
|
@ -64,39 +64,55 @@ final class Config
|
||||
|| $config['history_db_connection'] === false
|
||||
) {
|
||||
ob_start();
|
||||
$config['history_db_connection'] = db_connect(
|
||||
$config['history_db_host'],
|
||||
$config['history_db_name'],
|
||||
|
||||
$link = mysqli_init();
|
||||
$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2);
|
||||
$rc = mysqli_real_connect(
|
||||
$link,
|
||||
$$config['history_db_host'],
|
||||
$config['history_db_user'],
|
||||
io_output_password($config['history_db_pass']),
|
||||
$config['history_db_port'],
|
||||
false
|
||||
$config['history_db_name'],
|
||||
$config['history_db_port']
|
||||
);
|
||||
|
||||
if ($rc === false) {
|
||||
$config['history_db_connection'] = false;
|
||||
} else {
|
||||
$config['history_db_connection'] = db_connect(
|
||||
$config['history_db_host'],
|
||||
$config['history_db_name'],
|
||||
$config['history_db_user'],
|
||||
io_output_password($config['history_db_pass']),
|
||||
$config['history_db_port'],
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
ob_get_clean();
|
||||
}
|
||||
|
||||
if ($config['history_db_connection'] !== false) {
|
||||
$data = \db_get_all_rows_sql(
|
||||
'SELECT * FROM `tconfig`',
|
||||
false,
|
||||
false,
|
||||
$config['history_db_connection']
|
||||
if ($config['history_db_connection'] !== false) {
|
||||
$data = \db_get_all_rows_sql(
|
||||
'SELECT * FROM `tconfig`',
|
||||
false,
|
||||
false,
|
||||
$config['history_db_connection']
|
||||
);
|
||||
}
|
||||
|
||||
if (is_array($data) !== true) {
|
||||
return [];
|
||||
}
|
||||
|
||||
self::$settings = array_reduce(
|
||||
$data,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['token']] = $item['value'];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
if (is_array($data) !== true) {
|
||||
return [];
|
||||
}
|
||||
|
||||
self::$settings = array_reduce(
|
||||
$data,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['token']] = $item['value'];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +156,10 @@ final class DBMaintainer
|
||||
return true;
|
||||
}
|
||||
|
||||
$dbc = new \mysqli(
|
||||
$link = mysqli_init();
|
||||
$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2);
|
||||
$rc = mysqli_real_connect(
|
||||
$link,
|
||||
$this->host,
|
||||
$this->user,
|
||||
$this->pass,
|
||||
@ -164,25 +167,39 @@ final class DBMaintainer
|
||||
$this->port
|
||||
);
|
||||
|
||||
if ((bool) $dbc->connect_error === true) {
|
||||
if ($rc === false) {
|
||||
$this->dbh = null;
|
||||
$this->connected = false;
|
||||
$this->lastError = $dbc->connect_errno.': '.$dbc->connect_error;
|
||||
$this->lastError = __('Connection problems');
|
||||
} else {
|
||||
$this->dbh = $dbc;
|
||||
if (empty($this->charset) === false) {
|
||||
$dbc->set_charset($this->charset);
|
||||
}
|
||||
$dbc = new \mysqli(
|
||||
$this->host,
|
||||
$this->user,
|
||||
$this->pass,
|
||||
null,
|
||||
$this->port
|
||||
);
|
||||
|
||||
if ($this->dbh->select_db($this->name) === false) {
|
||||
$this->lastError = $this->dbh->errno.': '.$this->dbh->error;
|
||||
$this->ready = false;
|
||||
if ((bool) $dbc->connect_error === true) {
|
||||
$this->dbh = null;
|
||||
$this->connected = false;
|
||||
$this->lastError = $dbc->connect_errno.': '.$dbc->connect_error;
|
||||
} else {
|
||||
$this->lastError = null;
|
||||
$this->ready = true;
|
||||
}
|
||||
$this->dbh = $dbc;
|
||||
if (empty($this->charset) === false) {
|
||||
$dbc->set_charset($this->charset);
|
||||
}
|
||||
|
||||
$this->connected = true;
|
||||
if ($this->dbh->select_db($this->name) === false) {
|
||||
$this->lastError = $this->dbh->errno.': '.$this->dbh->error;
|
||||
$this->ready = false;
|
||||
} else {
|
||||
$this->lastError = null;
|
||||
$this->ready = true;
|
||||
}
|
||||
|
||||
$this->connected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,6 +193,10 @@ class GroupsStatusWidget extends Widget
|
||||
$values['groupId'] = $decoder['groupId'];
|
||||
}
|
||||
|
||||
if (isset($decoder['groupRecursion']) === true) {
|
||||
$values['groupRecursion'] = $decoder['groupRecursion'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
@ -224,6 +228,16 @@ class GroupsStatusWidget extends Widget
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Group recursion'),
|
||||
'arguments' => [
|
||||
'name' => 'groupRecursion',
|
||||
'id' => 'groupRecursion',
|
||||
'type' => 'switch',
|
||||
'value' => $values['groupRecursion'],
|
||||
],
|
||||
];
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
@ -239,6 +253,7 @@ class GroupsStatusWidget extends Widget
|
||||
$values = parent::getPost();
|
||||
|
||||
$values['groupId'] = \get_parameter('groupId', 0);
|
||||
$values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0);
|
||||
|
||||
return $values;
|
||||
}
|
||||
@ -260,9 +275,12 @@ class GroupsStatusWidget extends Widget
|
||||
|
||||
$output = '';
|
||||
|
||||
$user_groups = \users_get_groups(false, 'AR', false);
|
||||
|
||||
$stats = \reporting_get_group_stats_resume($this->values['groupId'], 'AR', true);
|
||||
$stats = \reporting_get_group_stats_resume(
|
||||
$this->values['groupId'],
|
||||
'AR',
|
||||
true,
|
||||
(bool) $this->values['groupRecursion']
|
||||
);
|
||||
|
||||
$data = '<div class="widget-groups-status"><span>';
|
||||
$data .= ui_print_group_icon(
|
||||
@ -393,7 +411,7 @@ class GroupsStatusWidget extends Widget
|
||||
$table->data[0][0] .= '</span>';
|
||||
$table->data[0][1] = '<span>';
|
||||
$table->data[0][1] .= '<b>';
|
||||
$table->data[0][1] .= $stats['monitor_total'];
|
||||
$table->data[0][1] .= $stats['total_checks'];
|
||||
$table->data[0][1] .= '</b>';
|
||||
$table->data[0][1] .= '</span>';
|
||||
|
||||
|
@ -39,7 +39,7 @@ form.flex-row ul {
|
||||
margin: 0.5em 3em 0.5em 0;
|
||||
}
|
||||
|
||||
div.filter_input_little {
|
||||
form div.filter_input_little {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@ -132,6 +132,14 @@ table.dataTable tbody td {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
form.flex-row div.filter_input.filter_input_switch {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
form.flex-row div.filter_input.filter_input_switch .p-slider {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
@ -1705,6 +1705,17 @@ div#agent_wizard_subtabs {
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.databox.no-border {
|
||||
margin-bottom: 5px;
|
||||
margin-top: 0px;
|
||||
margin-left: 0px;
|
||||
border: none;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.databox_color {
|
||||
padding-top: 5px;
|
||||
background-color: #fafafa;
|
||||
@ -9078,3 +9089,33 @@ div#err_msg_centralised {
|
||||
margin-bottom: 4px !important;
|
||||
padding: 2px 5px !important;
|
||||
}
|
||||
|
||||
.dataTables_wrapper {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_processing {
|
||||
margin-top: -37px !important;
|
||||
top: 50px !important;
|
||||
padding-top: 0px !important;
|
||||
height: 0px !important;
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_processing .processing-datatables-inside {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_processing .processing-datatables-inside img {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.loading-search-datatables-button {
|
||||
float: right;
|
||||
margin-right: -110px;
|
||||
margin-top: 13px;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@
|
||||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.763';
|
||||
$build = '220715';
|
||||
$build = '220729';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
@ -182,24 +182,47 @@ class User
|
||||
$password = $system->getRequest('password', null);
|
||||
}
|
||||
|
||||
if (!empty($user) && !empty($password)) {
|
||||
$user_in_db = process_user_login($user, $password);
|
||||
if ($user_in_db !== false) {
|
||||
$this->logged = true;
|
||||
$this->user = $user_in_db;
|
||||
$this->loginTime = time();
|
||||
$this->errorLogin = false;
|
||||
if (empty($user) === false
|
||||
&& empty($password) === false
|
||||
) {
|
||||
$user_in_db = db_get_row_filter(
|
||||
'tusuario',
|
||||
['id_user' => $user],
|
||||
'*'
|
||||
);
|
||||
|
||||
// The user login was successful, but the second step is not completed
|
||||
if ($this->isDobleAuthRequired()) {
|
||||
$this->needDoubleAuth = true;
|
||||
}
|
||||
} else {
|
||||
$this->logged = false;
|
||||
$this->logged = false;
|
||||
$this->loginTime = false;
|
||||
$this->errorLogin = true;
|
||||
$this->needDoubleAuth = false;
|
||||
$this->errorDoubleAuth = false;
|
||||
|
||||
if ($user_in_db !== false) {
|
||||
if (((bool) $user_in_db['is_admin'] === false)
|
||||
&& ((bool) $user_in_db['not_login'] === true
|
||||
|| (is_metaconsole() === false
|
||||
&& has_metaconsole() === true
|
||||
&& is_management_allowed() === false
|
||||
&& (bool) $user_in_db['metaconsole_access_node'] === false))
|
||||
) {
|
||||
$this->logged = false;
|
||||
$this->loginTime = false;
|
||||
$this->errorLogin = true;
|
||||
$this->needDoubleAuth = false;
|
||||
$this->errorDoubleAuth = false;
|
||||
} else {
|
||||
$user_proccess_login = process_user_login($user, $password);
|
||||
if ($user_proccess_login !== false) {
|
||||
$this->logged = true;
|
||||
$this->user = $user_proccess_login;
|
||||
$this->loginTime = time();
|
||||
$this->errorLogin = false;
|
||||
// The user login was successful, but the second step is not completed.
|
||||
if ($this->isDobleAuthRequired()) {
|
||||
$this->needDoubleAuth = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,12 +363,6 @@ class Agent
|
||||
$events = new Events();
|
||||
$events->addJavascriptDialog();
|
||||
|
||||
$options = $events->get_event_dialog_options();
|
||||
$ui->addDialog($options);
|
||||
|
||||
$options = $events->get_event_dialog_error_options($options);
|
||||
$ui->addDialog($options);
|
||||
|
||||
$ui->contentAddHtml("<a id='detail_event_dialog_hook' href='#detail_event_dialog' class='invisible'>detail_event_hook</a>");
|
||||
$ui->contentAddHtml("<a id='detail_event_dialog_error_hook' href='#detail_event_dialog_error' class='invisible'>detail_event_dialog_error_hook</a>");
|
||||
|
||||
|
@ -1101,7 +1101,7 @@ class Events
|
||||
if (is_metaconsole() === false) {
|
||||
$count = events_get_all(
|
||||
'count',
|
||||
$filters,
|
||||
$filters
|
||||
);
|
||||
|
||||
if ($count !== false) {
|
||||
|
@ -37,19 +37,21 @@ function forceExecution($id_group)
|
||||
}
|
||||
|
||||
|
||||
function validateAlert()
|
||||
function validateAlert($ids)
|
||||
{
|
||||
$ids = (array) get_parameter_post('validate', []);
|
||||
|
||||
if (!empty($ids)) {
|
||||
include_once 'include/functions_alerts.php';
|
||||
$result = alerts_validate_alert_agent_module($ids);
|
||||
|
||||
ui_print_result_message(
|
||||
return ui_print_result_message(
|
||||
$result,
|
||||
__('Alert(s) validated'),
|
||||
__('Error processing alert(s)')
|
||||
__('Error processing alert(s)'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
} else {
|
||||
return ui_print_error_message(__('No alert selected'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,11 +63,11 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->class = 'databox filters no-border';
|
||||
$table->cellpadding = '0';
|
||||
$table->cellspacing = '0';
|
||||
if (defined('METACONSOLE')) {
|
||||
$table->class = 'databox filters';
|
||||
$table->class = 'databox filters no-border';
|
||||
$table->width = '100%';
|
||||
$table->cellpadding = '0';
|
||||
$table->cellspacing = '0';
|
||||
@ -97,12 +99,11 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
||||
$alert_status_filter['disabled'] = __('Disabled');
|
||||
|
||||
$alert_standby = [];
|
||||
$alert_standby['all'] = __('All');
|
||||
$alert_standby['standby_on'] = __('Standby on');
|
||||
$alert_standby['standby_off'] = __('Standby off');
|
||||
$alert_standby['1'] = __('Standby on');
|
||||
$alert_standby['0'] = __('Standby off');
|
||||
|
||||
$table->data[0][2] = __('Status');
|
||||
$table->data[0][3] = html_print_select($alert_status_filter, 'filter', $filter, '', '', '', true);
|
||||
$table->data[0][3] = html_print_select($alert_status_filter, 'disabled', $filter, '', '', '', true);
|
||||
|
||||
$table->data[0][4] = __('Tags').ui_print_help_tip(__('Only it is show tags in use.'), true);
|
||||
|
||||
@ -111,7 +112,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
||||
if (empty($tags)) {
|
||||
$table->data[0][5] .= html_print_input_text('tags', __('No tags'), '', 20, 40, true, true);
|
||||
} else {
|
||||
$table->data[0][5] .= html_print_select($tags, 'tag_filter', $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
|
||||
$table->data[0][5] .= html_print_select($tags, 'tag', $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;');
|
||||
}
|
||||
|
||||
$table->data[1][0] = __('Free text for search').ui_print_help_tip(
|
||||
@ -121,32 +122,14 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
||||
$table->data[1][1] = html_print_input_text('free_search', $free_search, '', 20, 40, true);
|
||||
|
||||
$table->data[1][2] = __('Standby');
|
||||
$table->data[1][3] = html_print_select($alert_standby, 'filter_standby', $filter_standby, '', '', '', true);
|
||||
$table->data[1][3] = html_print_select($alert_standby, 'standby', $filter_standby, '', __('All'), '', true);
|
||||
|
||||
$table->data[1][4] = __('Action');
|
||||
$alert_action = alerts_get_alert_actions_filter();
|
||||
if (empty($alert_action)) {
|
||||
$table->data[1][5] .= html_print_input_text('action', __('No actions'), '', 20, 40, true, true);
|
||||
} else {
|
||||
$table->data[1][5] = html_print_select($alert_action, 'action_filter', $action_filter, '', __('All'), '', true);
|
||||
}
|
||||
|
||||
$table->data[1][5] = html_print_select($alert_action, 'action_filter', $action_filter, '', __('All'), '', true);
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$table->data[0][7] = html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true);
|
||||
$table->rowspan[0][7] = 2;
|
||||
$data = '<form class="bg_ec" method="post" action="'.$url.'">';
|
||||
} else {
|
||||
$data = '<form method="post" action="'.$url.'">';
|
||||
}
|
||||
$table->data[1][5] = html_print_select($alert_action, 'action', $action_filter, '', __('All'), '', true);
|
||||
|
||||
$data .= html_print_table($table, true);
|
||||
if (!defined('METACONSOLE')) {
|
||||
$data .= "<div class='height_100p right'>".html_print_submit_button(__('Filter'), 'filter_button', false, 'class="sub filter"', true).'</div>';
|
||||
}
|
||||
|
||||
$data .= '</form>';
|
||||
|
||||
if ($return) {
|
||||
return $data;
|
||||
@ -156,7 +139,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st
|
||||
}
|
||||
|
||||
|
||||
function printFormFilterAlertAgent($agent_view_page, $free_search, $id_agent)
|
||||
function printFormFilterAlertAgent($agent_view_page, $free_search, $id_agent, $return=false)
|
||||
{
|
||||
$table_filter = new stdClass();
|
||||
$table_filter->width = '100%';
|
||||
@ -188,41 +171,11 @@ function printFormFilterAlertAgent($agent_view_page, $free_search, $id_agent)
|
||||
true
|
||||
).'</span>';
|
||||
|
||||
$table_filter->data[0][1] = '<div class="action-buttons">';
|
||||
if ($agent_view_page === true) {
|
||||
$table_filter->data[0][1] .= html_print_button(
|
||||
__('Search'),
|
||||
'',
|
||||
false,
|
||||
'filter_agent_alerts('.$id_agent.');',
|
||||
'class="sub search"',
|
||||
true
|
||||
);
|
||||
$form = html_print_table($table_filter, true);
|
||||
|
||||
if ($return === true) {
|
||||
return $form;
|
||||
} else {
|
||||
$table_filter->data[0][1] .= html_print_submit_button(
|
||||
__('Search'),
|
||||
'',
|
||||
false,
|
||||
'class="sub search"',
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$table_filter->data[0][1] .= '</div>';
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
echo html_print_table($table_filter);
|
||||
} else {
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$order = '';
|
||||
|
||||
if ($sortField != '' && $sort != '') {
|
||||
$order = '&sort_field='.$sortField.'&sort='.$sort;
|
||||
}
|
||||
|
||||
echo '<form method="post" action="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'&tab=alert'.$order.'">';
|
||||
echo html_print_table($table_filter);
|
||||
echo '</form>';
|
||||
echo $form;
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,8 @@ $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
|
||||
|
||||
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
|
||||
$filter = get_parameter('filter', 'all_enabled');
|
||||
$filter_standby = get_parameter('filter_standby', 'all');
|
||||
$offset_simple = (int) get_parameter_get('offset_simple', 0);
|
||||
$filter = get_parameter('disabled', 'all_enabled');
|
||||
$filter_standby = get_parameter('standby', 'all');
|
||||
$id_group = (int) get_parameter('ag_group', 0);
|
||||
// 0 is the All group (selects all groups)
|
||||
$free_search = get_parameter('free_search', '');
|
||||
@ -99,7 +98,7 @@ if ($tag_filter) {
|
||||
}
|
||||
}
|
||||
|
||||
$action_filter = get_parameter('action_filter', 0);
|
||||
$action_filter = get_parameter('action', 0);
|
||||
|
||||
$sec2 = get_parameter_get('sec2');
|
||||
$sec2 = safe_url_extraclean($sec2);
|
||||
@ -210,249 +209,11 @@ if ($idAgent != 0) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($alert_validate) {
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
validateAlert();
|
||||
} else {
|
||||
ui_print_error_message(__('Insufficient permissions to validate alerts'));
|
||||
}
|
||||
}
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
if ($free_search != '') {
|
||||
$whereAlertSimple = 'AND ('.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE name LIKE "%'.$free_search.'%") OR '.'id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search.'%")) OR '.'talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$free_search.'%")) OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%'.$free_search.'%") OR '.'id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%'.$free_search.'%")
|
||||
OR alias LIKE "%'.$free_search.'%")'.')';
|
||||
} else {
|
||||
$whereAlertSimple = '';
|
||||
}
|
||||
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$selected = true;
|
||||
$selectAgentUp = false;
|
||||
$selectAgentDown = false;
|
||||
$selectModuleUp = false;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'agent':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectAgentUp = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectAgentDown = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectModuleUp = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectModuleDown = $selected;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectTemplateUp = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectTemplateDown = $selected;
|
||||
$order = [
|
||||
'field' => 'template_name',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'last_fired':
|
||||
switch ($sort) {
|
||||
case 'up':
|
||||
$selectLastFiredUp = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
$selectLastFiredDown = $selected;
|
||||
$order = [
|
||||
'field' => 'last_fired',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($print_agent) {
|
||||
$selectDisabledUp = '';
|
||||
$selectDisabledDown = '';
|
||||
$selectAgentUp = false;
|
||||
$selectAgentDown = false;
|
||||
$selectModuleUp = $selected;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
} else {
|
||||
$selectDisabledUp = '';
|
||||
$selectDisabledDown = '';
|
||||
$selectAgentUp = false;
|
||||
$selectAgentDown = false;
|
||||
$selectModuleUp = $selected;
|
||||
$selectModuleDown = false;
|
||||
$selectTemplateUp = false;
|
||||
$selectTemplateDown = false;
|
||||
$selectLastFiredUp = false;
|
||||
$selectLastFiredDown = false;
|
||||
$order = [
|
||||
'field' => 'agent_module_name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Add checks for user ACL
|
||||
$groups = users_get_groups($config['id_user'], $access);
|
||||
$id_groups = array_keys($groups);
|
||||
|
||||
if (empty($id_groups)) {
|
||||
$whereAlertSimple .= ' AND (1 = 0) ';
|
||||
} else {
|
||||
$whereAlertSimple .= sprintf(
|
||||
' AND id_agent_module IN (
|
||||
SELECT tam.id_agente_modulo
|
||||
FROM tagente_modulo tam
|
||||
WHERE tam.id_agente IN (SELECT ta.id_agente
|
||||
FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
|
||||
ta.id_agente = tasg.id_agent
|
||||
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
|
||||
implode(',', $id_groups),
|
||||
implode(',', $id_groups)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$alerts = [];
|
||||
if ($agent_view_page === true) {
|
||||
$options_simple = ['order' => $order];
|
||||
} else {
|
||||
$options_simple = [
|
||||
'offset' => $offset_simple,
|
||||
'limit' => $config['block_size'],
|
||||
'order' => $order,
|
||||
];
|
||||
}
|
||||
|
||||
$filter_alert = [];
|
||||
if ($filter_standby == 'standby_on') {
|
||||
$filter_alert['disabled'] = $filter;
|
||||
$filter_alert['standby'] = '1';
|
||||
} else if ($filter_standby == 'standby_off') {
|
||||
$filter_alert['disabled'] = $filter;
|
||||
$filter_alert['standby'] = '0';
|
||||
} else {
|
||||
$filter_alert['disabled'] = $filter;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
} else {
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
|
||||
|
||||
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
|
||||
} else {
|
||||
$id_groups = array_keys(
|
||||
users_get_groups($config['id_user'], $access, false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
}
|
||||
|
||||
if ($tab != null) {
|
||||
$url = $url.'&tab='.$tab;
|
||||
@ -466,313 +227,248 @@ if ($free_search != '') {
|
||||
$url .= '&free_search='.$free_search;
|
||||
}
|
||||
|
||||
// Filter form
|
||||
if ($print_agent) {
|
||||
if (is_metaconsole()) {
|
||||
ui_toggle(
|
||||
printFormFilterAlert(
|
||||
$id_group,
|
||||
$filter,
|
||||
$free_search,
|
||||
$url,
|
||||
$filter_standby,
|
||||
$tag_filter,
|
||||
|
||||
|
||||
$columns = ['standby'];
|
||||
|
||||
$column_names = [
|
||||
[
|
||||
'title' => 'Standby',
|
||||
'text' => 'S.',
|
||||
],
|
||||
];
|
||||
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Policy',
|
||||
'text' => 'P.',
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
['policy'],
|
||||
$columns
|
||||
);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
array_unshift(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Validate',
|
||||
'text' => html_print_checkbox('all_validate', 0, false, true, false),
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
['validate'],
|
||||
$columns,
|
||||
);
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
array_push(
|
||||
$column_names,
|
||||
[
|
||||
'title' => 'Force execution',
|
||||
'text' => 'F.',
|
||||
],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['force']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($print_agent === true) {
|
||||
array_push(
|
||||
$column_names,
|
||||
['text' => 'Agent'],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['agent'],
|
||||
);
|
||||
}
|
||||
|
||||
array_push(
|
||||
$column_names,
|
||||
['text' => 'Module'],
|
||||
['text' => 'Template'],
|
||||
['text' => 'Action'],
|
||||
['text' => 'Last fired'],
|
||||
['text' => 'Status'],
|
||||
);
|
||||
|
||||
$columns = array_merge(
|
||||
$columns,
|
||||
['module'],
|
||||
['template'],
|
||||
['action'],
|
||||
['lastFired'],
|
||||
['status'],
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$no_sortable_columns = [
|
||||
0,
|
||||
1,
|
||||
5,
|
||||
];
|
||||
} else {
|
||||
$no_sortable_columns = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
7,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$alert_action = empty(alerts_get_alert_actions_filter()) === false ? alerts_get_alert_actions_filter() : ['' => __('No actions')];
|
||||
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => 'alerts_status_datatable',
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'no_sortable_columns' => $no_sortable_columns,
|
||||
'ajax_url' => 'include/ajax/alert_list.ajax',
|
||||
'ajax_data' => [
|
||||
'get_agent_alerts_datatable' => 1,
|
||||
'id_agent' => $id_agent,
|
||||
'url' => $url,
|
||||
'agent_view_page' => true,
|
||||
'all_groups' => $all_groups,
|
||||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
'order' => [
|
||||
'field' => 'module',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'zeroRecords' => __('No alerts found'),
|
||||
'emptyTable' => __('No alerts found'),
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Free text for search (*):').ui_print_help_tip(
|
||||
__('Filter by module name, template name or action name'),
|
||||
true
|
||||
),
|
||||
'type' => 'text',
|
||||
'name' => 'free_search_alert',
|
||||
'value' => $free_search,
|
||||
'size' => 20,
|
||||
'maxlength' => 100,
|
||||
],
|
||||
],
|
||||
'no_toggle' => true,
|
||||
],
|
||||
],
|
||||
);
|
||||
} else {
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => 'alerts_status_datatable',
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'no_sortable_columns' => $no_sortable_columns,
|
||||
'ajax_url' => 'include/ajax/alert_list.ajax',
|
||||
'ajax_data' => [
|
||||
'get_agent_alerts_datatable' => 1,
|
||||
'id_agent' => $id_agent,
|
||||
'url' => $url,
|
||||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
'order' => [
|
||||
'field' => 'module',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'zeroRecords' => __('No alerts found'),
|
||||
'emptyTable' => __('No alerts found'),
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'html' => printFormFilterAlert(
|
||||
$id_group,
|
||||
$filter,
|
||||
$free_search,
|
||||
$url,
|
||||
$filter_standby,
|
||||
$tag_filter,
|
||||
true,
|
||||
true,
|
||||
$strict_user
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.';">';
|
||||
html_print_submit_button(__('Validate'), 'alert_validate', false, 'class="sub ok"', false);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$html_content = ob_get_clean();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
// Create controlled toggle content.
|
||||
ui_toggle(
|
||||
$html_content,
|
||||
__('Full list of alerts'),
|
||||
'status_monitor_agent',
|
||||
!$alerts_defined,
|
||||
false,
|
||||
true,
|
||||
$strict_user
|
||||
),
|
||||
__('Show Options')
|
||||
);
|
||||
;
|
||||
} else {
|
||||
ui_toggle(
|
||||
printFormFilterAlert(
|
||||
$id_group,
|
||||
$filter,
|
||||
$free_search,
|
||||
$url,
|
||||
$filter_standby,
|
||||
$tag_filter,
|
||||
$action_filter,
|
||||
true,
|
||||
$strict_user
|
||||
),
|
||||
__('Alert control filter'),
|
||||
__('Toggle filter(s)'),
|
||||
$access
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Urls to sort the table.
|
||||
$url_up_agente = $url.'&sort_field=agent&sort=up';
|
||||
$url_down_agente = $url.'&sort_field=agent&sort=down';
|
||||
$url_up_module = $url.'&sort_field=module&sort=up';
|
||||
$url_down_module = $url.'&sort_field=module&sort=down';
|
||||
$url_up_template = $url.'&sort_field=template&sort=up';
|
||||
$url_down_template = $url.'&sort_field=template&sort=down';
|
||||
$url_up_lastfired = $url.'&sort_field=last_fired&sort=up';
|
||||
$url_down_lastfired = $url.'&sort_field=last_fired&sort=down';
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'info_table';
|
||||
$table->cellpadding = '0';
|
||||
$table->cellspacing = '0';
|
||||
$table->size = [];
|
||||
$table->head = [];
|
||||
$table->align = [];
|
||||
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
||||
if ($print_agent) {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[8] = '4%';
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[9] = html_print_checkbox('all_validate', 0, false, true, false);
|
||||
$table->align[9] = 'left';
|
||||
$table->size[9] = '5%';
|
||||
}
|
||||
'',
|
||||
'white_table_graph_content no-padding-imp',
|
||||
'white_table_graph_content'
|
||||
);
|
||||
} else {
|
||||
// Dump entire content.
|
||||
echo $html_content;
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Policy')."'>".__('P.').'</span>';
|
||||
// strict user hidden
|
||||
echo '<div id="strict_hidden" class="invisible">';
|
||||
html_print_input_text('strict_user_hidden', $strict_user);
|
||||
|
||||
$table->head[1] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
html_print_input_text('is_meta_hidden', (int) is_metaconsole());
|
||||
echo '</div>';
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[2] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[3] = __('Agent');
|
||||
$table->head[4] = __('Module');
|
||||
$table->head[5] = __('Template');
|
||||
$table->head[6] = __('Action');
|
||||
$table->head[7] = __('Last fired');
|
||||
$table->head[8] = __('Status');
|
||||
|
||||
$table->align[8] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown);
|
||||
$table->head[4] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[5] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[7] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
} else {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[7] = '5%';
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
$table->head[8] = __('Validate');
|
||||
$table->align[8] = 'left';
|
||||
$table->size[8] = '5%';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Policy')."'>".__('P.').'</span>';
|
||||
|
||||
$table->head[1] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || check_acl_one_of_groups($config['id_user'], $all_groups, 'LM')) {
|
||||
$table->head[2] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[3] = __('Module');
|
||||
$table->head[4] = __('Template');
|
||||
$table->head[5] = __('Action');
|
||||
$table->head[6] = __('Last fired');
|
||||
$table->head[7] = __('Status');
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
|
||||
$table->align[7] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[4] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[6] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($print_agent) {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[7] = '5%';
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[8] = __('Validate');
|
||||
$table->align[8] = 'left';
|
||||
$table->size[8] = '5%';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[1] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[2] = __('Agent');
|
||||
$table->head[3] = __('Module');
|
||||
$table->head[4] = __('Template');
|
||||
$table->head[5] = __('Action');
|
||||
$table->head[6] = __('Last fired');
|
||||
$table->head[7] = __('Status');
|
||||
|
||||
$table->align[7] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown);
|
||||
$table->head[4] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[5] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[6] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
} else {
|
||||
if (!is_metaconsole()) {
|
||||
$table->size[6] = '5%';
|
||||
if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[7] = __('Validate');
|
||||
$table->align[7] = 'left';
|
||||
$table->size[7] = '5%';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[0] = "<span title='".__('Standby')."'>".__('S.').'</span>';
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
$table->head[1] = "<span title='".__('Force execution')."'>".__('F.').'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$table->head[2] = __('Module');
|
||||
$table->head[3] = __('Template');
|
||||
$table->head[4] = __('Action');
|
||||
$table->head[5] = __('Last fired');
|
||||
$table->head[6] = __('Status');
|
||||
|
||||
$table->align[6] = 'center';
|
||||
|
||||
// Sort buttons are only for normal console
|
||||
if (!is_metaconsole()) {
|
||||
$table->head[2] .= ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown);
|
||||
$table->head[3] .= ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown);
|
||||
$table->head[5] .= ui_get_sorting_arrows($url_up_lastfired, $url_down_lastfired, $selectLastFiredUp, $selectLastFiredDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($sortField) {
|
||||
$url .= '&sort_field='.$sortField;
|
||||
$url .= '&sort='.$sort;
|
||||
}
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$rowPair = true;
|
||||
$iterator = 0;
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$row = ui_format_alert_row($alert, $print_agent, $url, 'font-size: 7pt;');
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
if (!empty($table->data)) {
|
||||
$class = '';
|
||||
if ($agent_view_page === true) {
|
||||
$class = 'w100p no-padding-imp';
|
||||
printFormFilterAlertAgent($agent_view_page, $free_search, $idAgent);
|
||||
}
|
||||
|
||||
echo '<form class="'.$class.'" method="post" action="'.$url.'">';
|
||||
|
||||
if ($agent_view_page !== true) {
|
||||
ui_pagination(
|
||||
$countAlertsSimple,
|
||||
$url,
|
||||
$offset_simple,
|
||||
0,
|
||||
false,
|
||||
'offset_simple'
|
||||
);
|
||||
}
|
||||
|
||||
echo '<div id="alerts_list" class="w100p">';
|
||||
html_print_table($table);
|
||||
echo '</div>';
|
||||
|
||||
if ($agent_view_page !== true) {
|
||||
ui_pagination(
|
||||
$countAlertsSimple,
|
||||
$url,
|
||||
$offset_simple,
|
||||
0,
|
||||
false,
|
||||
'offset_simple',
|
||||
true,
|
||||
'pagination-bottom'
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) {
|
||||
if (count($alerts['alerts_simple']) > 0) {
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.';">';
|
||||
html_print_submit_button(__('Validate'), 'alert_validate', false, 'class="sub ok"', false);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
$alerts_defined = true;
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]);
|
||||
$alerts_defined = false;
|
||||
}
|
||||
|
||||
$html_content = ob_get_clean();
|
||||
|
||||
if ($agent_view_page === true) {
|
||||
// Create controlled toggle content.
|
||||
ui_toggle(
|
||||
$html_content,
|
||||
__('Full list of alerts'),
|
||||
'status_monitor_agent',
|
||||
!$alerts_defined,
|
||||
false,
|
||||
'',
|
||||
'white_table_graph_content no-padding-imp'
|
||||
);
|
||||
} else {
|
||||
if (!$print_agent) {
|
||||
printFormFilterAlertAgent($agent_view_page, $free_search, $idAgent);
|
||||
}
|
||||
|
||||
// Dump entire content.
|
||||
echo $html_content;
|
||||
}
|
||||
|
||||
|
||||
// strict user hidden
|
||||
echo '<div id="strict_hidden" class="invisible">';
|
||||
html_print_input_text('strict_user_hidden', $strict_user);
|
||||
|
||||
html_print_input_text('is_meta_hidden', (int) is_metaconsole());
|
||||
echo '</div>';
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
|
||||
ui_require_css_file('cluetip', 'include/styles/js/');
|
||||
ui_require_jquery_file('cluetip');
|
||||
?>
|
||||
ui_require_css_file('cluetip', 'include/styles/js/');
|
||||
ui_require_jquery_file('cluetip');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function alerts_table_controls() {
|
||||
|
||||
$(document).ready (function () {
|
||||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
@ -782,19 +478,9 @@ ui_require_jquery_file('cluetip');
|
||||
});
|
||||
|
||||
|
||||
$('[id^=checkbox-validate]').change(function(){
|
||||
if($(this).parent().parent().hasClass('checkselected')){
|
||||
$(this).parent().parent().removeClass('checkselected');
|
||||
}
|
||||
else{
|
||||
$(this).parent().parent().addClass('checkselected');
|
||||
}
|
||||
});
|
||||
|
||||
$('[id^=checkbox-all_validate]').change(function(){
|
||||
if ($("#checkbox-all_validate").prop("checked")) {
|
||||
$('[id^=checkbox-validate]').parent().parent().addClass('checkselected');
|
||||
$('[name^=validate]').prop("checked", true);
|
||||
$("input[id^=checkbox-validate]").prop('checked', true);
|
||||
}
|
||||
else{
|
||||
$('[id^=checkbox-validate]').parent().parent().removeClass('checkselected');
|
||||
@ -802,6 +488,13 @@ ui_require_jquery_file('cluetip');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready ( function () {
|
||||
alerts_table_controls();
|
||||
$('#submit-alert_validate').on('click', function () {
|
||||
validateAlerts();
|
||||
});
|
||||
});
|
||||
|
||||
$('table.alert-status-filter #ag_group').change (function () {
|
||||
@ -825,27 +518,42 @@ ui_require_jquery_file('cluetip');
|
||||
}
|
||||
}).change();
|
||||
|
||||
function filter_agent_alerts(){
|
||||
var free_search_alert = $("input[name='free_search_alert']").val();
|
||||
$("#alerts_list").empty();
|
||||
|
||||
jQuery.ajax ({
|
||||
data: {
|
||||
get_agent_alerts_agent_view: 1,
|
||||
id_agent: '<?php echo $idAgent; ?>',
|
||||
free_search_alert: free_search_alert,
|
||||
all_groups: '<?php echo json_encode($all_groups); ?>',
|
||||
sort_field: '<?php echo $sortField; ?>',
|
||||
sort: '<?php echo $sort; ?>',
|
||||
page: 'include/ajax/alert_list.ajax'
|
||||
},
|
||||
type: 'POST',
|
||||
url: "ajax.php",
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
$("#alerts_list").empty();
|
||||
$("#alerts_list").html(data);
|
||||
}
|
||||
|
||||
function validateAlerts() {
|
||||
var alert_ids = [];
|
||||
|
||||
$('[id^=checkbox-validate]:checked').each(function() {
|
||||
alert_ids.push($(this).val());
|
||||
});
|
||||
|
||||
if (alert_ids.length === 0) {
|
||||
confirmDialog({
|
||||
title: "<?php echo __('No alert selected'); ?>",
|
||||
message: "<?php echo __('You must select at least one alert.'); ?>",
|
||||
hideCancelButton: true
|
||||
});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
data: {
|
||||
alert_ids: alert_ids,
|
||||
page: "include/ajax/alert_list.ajax",
|
||||
alert_validate: 1,
|
||||
all_groups: <?php echo json_encode($all_groups); ?>,
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
$("#menu_tab_frame_view").after(data);
|
||||
var table = $('#alerts_status_datatable').DataTable({
|
||||
ajax: "data.json"
|
||||
});
|
||||
|
||||
table.ajax.reload();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
@ -169,6 +169,10 @@ $filter_only_alert = get_parameter(
|
||||
'filter[filter_only_alert]',
|
||||
($filter['filter_only_alert'] ?? '')
|
||||
);
|
||||
$search_secondary_groups = get_parameter(
|
||||
'filter[search_secondary_groups]',
|
||||
0
|
||||
);
|
||||
$id_group_filter = get_parameter(
|
||||
'filter[id_group_filter]',
|
||||
($filter['id_group_filter'] ?? '')
|
||||
@ -482,21 +486,23 @@ if (is_ajax() === true) {
|
||||
$tmp->b64 = base64_encode(json_encode($tmp));
|
||||
|
||||
// Show comments events.
|
||||
$tmp->user_comment = $tmp->comments;
|
||||
if ($tmp->comments !== 'undefined' && strlen($tmp->comments) > 80) {
|
||||
$tmp->user_comment .= ' ';
|
||||
$tmp->user_comment .= '<a id="show_comments" href="javascript:" onclick="show_event_dialog(\'';
|
||||
$tmp->user_comment .= $tmp->b64;
|
||||
$tmp->user_comment .= '\',\'comments\')>;';
|
||||
$tmp->user_comment .= html_print_image(
|
||||
'images/operation.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Show more'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
);
|
||||
$tmp->user_comment .= '</a>';
|
||||
if (empty($tmp->comments) === false) {
|
||||
$tmp->user_comment = $tmp->comments;
|
||||
if ($tmp->comments !== 'undefined' && strlen($tmp->comments) > 80) {
|
||||
$tmp->user_comment .= ' ';
|
||||
$tmp->user_comment .= '<a id="show_comments" href="javascript:" onclick="show_event_dialog(\'';
|
||||
$tmp->user_comment .= $tmp->b64;
|
||||
$tmp->user_comment .= '\',\'comments\')>;';
|
||||
$tmp->user_comment .= html_print_image(
|
||||
'images/operation.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Show more'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
);
|
||||
$tmp->user_comment .= '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// Grouped events.
|
||||
@ -939,7 +945,7 @@ if (is_ajax() === true) {
|
||||
$custom_data_str = '';
|
||||
if (isset($custom_data) === true && empty($custom_data) === false) {
|
||||
foreach ($custom_data as $key => $value) {
|
||||
$custom_data_str .= $value['attr_name'].' = '.$value['val'].'<br>';
|
||||
$custom_data_str .= $key.' = '.$value.'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1049,6 +1055,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false
|
||||
$tag_without_base64 = base64_encode(json_encode($tag_without));
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = ($filter['search_secondary_groups'] ?? 0);
|
||||
$id_group_filter = $filter['id_group_filter'];
|
||||
$date_from = $filter['date_from'];
|
||||
$time_from = $filter['time_from'];
|
||||
@ -1667,6 +1674,24 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
||||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// Search secondary groups.
|
||||
$data = html_print_checkbox_switch(
|
||||
'search_secondary_groups',
|
||||
$search_secondary_groups,
|
||||
$search_secondary_groups,
|
||||
true,
|
||||
false,
|
||||
'search_in_secondary_groups(this);',
|
||||
true
|
||||
);
|
||||
|
||||
$in = '<div class="filter_input filter_input_switch"><label>'.__('Search in secondary groups').'</label>';
|
||||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// Trick view in table.
|
||||
$inputs[] = '<div style="min-width:32%;"></div>';
|
||||
|
||||
$buttons = [];
|
||||
|
||||
$buttons[] = [
|
||||
@ -2931,7 +2956,14 @@ $(document).ready( function() {
|
||||
|
||||
});
|
||||
|
||||
|
||||
function search_in_secondary_groups(element) {
|
||||
var value = $("#checkbox-"+element.name).val();
|
||||
if (value == 0) {
|
||||
$("#checkbox-"+element.name).val(1);
|
||||
} else {
|
||||
$("#checkbox-"+element.name).val(0);
|
||||
}
|
||||
}
|
||||
|
||||
function datetime_picker_callback() {
|
||||
$("#text-time_from, #text-time_to").timepicker({
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
@ -1244,6 +1244,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
|
||||
`tag_with` TEXT,
|
||||
`tag_without` TEXT,
|
||||
`filter_only_alert` INT NOT NULL DEFAULT -1,
|
||||
`search_secondary_groups` INT NOT NULL DEFAULT 0,
|
||||
`date_from` date DEFAULT NULL,
|
||||
`date_to` date DEFAULT NULL,
|
||||
`source` TINYTEXT,
|
||||
|
@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
||||
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
|
||||
('custom_report_front_header', ''),
|
||||
('custom_report_front_footer', ''),
|
||||
('MR', 55),
|
||||
('MR', 56),
|
||||
('identification_reminder', 1),
|
||||
('identification_reminder_timestamp', 0),
|
||||
('current_package', 763),
|
||||
('current_package', 764),
|
||||
('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.00097656250000":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'),
|
||||
('custom_docs_logo', 'default_docs.png'),
|
||||
('custom_support_logo', 'default_support.png'),
|
||||
|
410
pandora_plugins/cisco_ironports/pandora_ironports.py
Normal file
410
pandora_plugins/cisco_ironports/pandora_ironports.py
Normal file
@ -0,0 +1,410 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse,sys,requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from ast import List
|
||||
import xml.etree.ElementTree as ET
|
||||
import os
|
||||
from subprocess import *
|
||||
from datetime import datetime
|
||||
from xml.etree import ElementTree
|
||||
|
||||
__author__ = "Alejandro Sánchez Carrion"
|
||||
__copyright__ = "Copyright 2021, PandoraFMS"
|
||||
__maintainer__ = "Projects department"
|
||||
__status__ = "Production"
|
||||
__version__ = "180722"
|
||||
|
||||
description= f"""
|
||||
Pandora_ironports tool ver {__version__}
|
||||
|
||||
python3 pandora_ironports.py --url <url> -u <user> -p <password> [ --agent_name <agent_name> ] [ --as_agent_plugin <as_agent_plugin> ] [ --tentacle_port <tentacle_port> ] [ --tentacle_address <tentacle_address> ] [ -g <group> ] [ --data_dir <data dir> ]
|
||||
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(description= description, formatter_class=argparse.RawTextHelpFormatter)
|
||||
parser.add_argument('--url', help='', required=True)
|
||||
parser.add_argument('-u', '--user', help='username', required=True)
|
||||
parser.add_argument('-p', '--password', help='password',required=True )
|
||||
parser.add_argument('--tentacle_port', help='tentacle port', default=41121)
|
||||
parser.add_argument('--tentacle_address', help='tentacle adress', default=None)
|
||||
parser.add_argument('--agent_name', help='Name of the agent', default= "Cisco_ironport")
|
||||
parser.add_argument('-g', '--group', help='PandoraFMS destination group (default cisco)', default='Cisco')
|
||||
parser.add_argument('--data_dir', help='PandoraFMS data dir (default: /var/spool/pandora/data_in/)', default='/var/spool/pandora/data_in/')
|
||||
parser.add_argument('--as_agent_plugin', help='mode plugin', default=0,type=int)
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
### Pandora Tools ###-------------------------------------------------------------------------------------------------------
|
||||
modules = []
|
||||
|
||||
config = {
|
||||
"data_in": args.data_dir,
|
||||
"group" : args.group
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
# print_agent
|
||||
#########################################################################################
|
||||
def print_agent(agent, modules, data_dir="/var/spool/pandora/data_in/", log_modules= None, print_flag = None):
|
||||
"""Prints agent XML. Requires agent conf (dict) and modules (list) as arguments.
|
||||
- Use print_flag to show modules' XML in STDOUT.
|
||||
- Returns a tuple (xml, data_file).
|
||||
"""
|
||||
data_file=None
|
||||
|
||||
header = "<?xml version='1.0' encoding='UTF-8'?>\n"
|
||||
header += "<agent_data"
|
||||
for dato in agent:
|
||||
header += " " + str(dato) + "='" + str(agent[dato]) + "'"
|
||||
header += ">\n"
|
||||
xml = header
|
||||
if modules :
|
||||
for module in modules:
|
||||
modules_xml = print_module(module)
|
||||
xml += str(modules_xml)
|
||||
if log_modules :
|
||||
for log_module in log_modules:
|
||||
modules_xml = print_log_module(log_module)
|
||||
xml += str(modules_xml)
|
||||
xml += "</agent_data>"
|
||||
if not print_flag:
|
||||
data_file = write_xml(xml, agent["agent_name"], data_dir)
|
||||
else:
|
||||
print(xml)
|
||||
|
||||
return (xml,data_file)
|
||||
|
||||
#########################################################################################
|
||||
# print_module
|
||||
#########################################################################################
|
||||
def print_module(module, print_flag=None):
|
||||
"""Returns module in XML format. Accepts only {dict}.\n
|
||||
- Only works with one module at a time: otherwise iteration is needed.
|
||||
- Module "value" field accepts str type or [list] for datalists.
|
||||
- Use print_flag to show modules' XML in STDOUT.
|
||||
"""
|
||||
data = dict(module)
|
||||
module_xml = ("<module>\n"
|
||||
"\t<name><![CDATA[" + str(data["name"]) + "]]></name>\n"
|
||||
"\t<type>" + str(data["type"]) + "</type>\n"
|
||||
)
|
||||
|
||||
if type(data["type"]) is not str and "string" not in data["type"]: #### Strip spaces if module not generic_data_string
|
||||
data["value"] = data["value"].strip()
|
||||
if isinstance(data["value"], list): # Checks if value is a list
|
||||
module_xml += "\t<datalist>\n"
|
||||
for value in data["value"]:
|
||||
if type(value) is dict and "value" in value:
|
||||
module_xml += "\t<data>\n"
|
||||
module_xml += "\t\t<value><![CDATA[" + str(value["value"]) + "]]></value>\n"
|
||||
if "timestamp" in value:
|
||||
module_xml += "\t\t<timestamp><![CDATA[" + str(value["timestamp"]) + "]]></timestamp>\n"
|
||||
module_xml += "\t</data>\n"
|
||||
module_xml += "\t</datalist>\n"
|
||||
else:
|
||||
module_xml += "\t<data><![CDATA[" + str(data["value"]) + "]]></data>\n"
|
||||
if "desc" in data:
|
||||
module_xml += "\t<description><![CDATA[" + str(data["desc"]) + "]]></description>\n"
|
||||
if "unit" in data:
|
||||
module_xml += "\t<unit><![CDATA[" + str(data["unit"]) + "]]></unit>\n"
|
||||
if "interval" in data:
|
||||
module_xml += "\t<module_interval><![CDATA[" + str(data["interval"]) + "]]></module_interval>\n"
|
||||
if "tags" in data:
|
||||
module_xml += "\t<tags>" + str(data["tags"]) + "</tags>\n"
|
||||
if "module_group" in data:
|
||||
module_xml += "\t<module_group>" + str(data["module_group"]) + "</module_group>\n"
|
||||
if "module_parent" in data:
|
||||
module_xml += "\t<module_parent>" + str(data["module_parent"]) + "</module_parent>\n"
|
||||
if "min_warning" in data:
|
||||
module_xml += "\t<min_warning><![CDATA[" + str(data["min_warning"]) + "]]></min_warning>\n"
|
||||
if "min_warning_forced" in data:
|
||||
module_xml += "\t<min_warning_forced><![CDATA[" + str(data["min_warning_forced"]) + "]]></min_warning_forced>\n"
|
||||
if "max_warning" in data:
|
||||
module_xml += "\t<max_warning><![CDATA[" + str(data["max_warning"]) + "]]></max_warning>\n"
|
||||
if "max_warning_forced" in data:
|
||||
module_xml += "\t<max_warning_forced><![CDATA[" + str(data["max_warning_forced"]) + "]]></max_warning_forced>\n"
|
||||
if "min_critical" in data:
|
||||
module_xml += "\t<min_critical><![CDATA[" + str(data["min_critical"]) + "]]></min_critical>\n"
|
||||
if "min_critical_forced" in data:
|
||||
module_xml += "\t<min_critical_forced><![CDATA[" + str(data["min_critical_forced"]) + "]]></min_critical_forced>\n"
|
||||
if "max_critical" in data:
|
||||
module_xml += "\t<max_critical><![CDATA[" + str(data["max_critical"]) + "]]></max_critical>\n"
|
||||
if "max_critical_forced" in data:
|
||||
module_xml += "\t<max_critical_forced><![CDATA[" + str(data["max_critical_forced"]) + "]]></max_critical_forced>\n"
|
||||
if "str_warning" in data:
|
||||
module_xml += "\t<str_warning><![CDATA[" + str(data["str_warning"]) + "]]></str_warning>\n"
|
||||
if "str_warning_forced" in data:
|
||||
module_xml += "\t<str_warning_forced><![CDATA[" + str(data["str_warning_forced"]) + "]]></str_warning_forced>\n"
|
||||
if "str_critical" in data:
|
||||
module_xml += "\t<str_critical><![CDATA[" + str(data["str_critical"]) + "]]></str_critical>\n"
|
||||
if "str_critical_forced" in data:
|
||||
module_xml += "\t<str_critical_forced><![CDATA[" + str(data["str_critical_forced"]) + "]]></str_critical_forced>\n"
|
||||
if "critical_inverse" in data:
|
||||
module_xml += "\t<critical_inverse><![CDATA[" + str(data["critical_inverse"]) + "]]></critical_inverse>\n"
|
||||
if "warning_inverse" in data:
|
||||
module_xml += "\t<warning_inverse><![CDATA[" + str(data["warning_inverse"]) + "]]></warning_inverse>\n"
|
||||
if "max" in data:
|
||||
module_xml += "\t<max><![CDATA[" + str(data["max"]) + "]]></max>\n"
|
||||
if "min" in data:
|
||||
module_xml += "\t<min><![CDATA[" + str(data["min"]) + "]]></min>\n"
|
||||
if "post_process" in data:
|
||||
module_xml += "\t<post_process><![CDATA[" + str(data["post_process"]) + "]]></post_process>\n"
|
||||
if "disabled" in data:
|
||||
module_xml += "\t<disabled><![CDATA[" + str(data["disabled"]) + "]]></disabled>\n"
|
||||
if "min_ff_event" in data:
|
||||
module_xml += "\t<min_ff_event><![CDATA[" + str(data["min_ff_event"]) + "]]></min_ff_event>\n"
|
||||
if "status" in data:
|
||||
module_xml += "\t<status><![CDATA[" + str(data["status"]) + "]]></status>\n"
|
||||
if "timestamp" in data:
|
||||
module_xml += "\t<timestamp><![CDATA[" + str(data["timestamp"]) + "]]></timestamp>\n"
|
||||
if "custom_id" in data:
|
||||
module_xml += "\t<custom_id><![CDATA[" + str(data["custom_id"]) + "]]></custom_id>\n"
|
||||
if "critical_instructions" in data:
|
||||
module_xml += "\t<critical_instructions><![CDATA[" + str(data["critical_instructions"]) + "]]></critical_instructions>\n"
|
||||
if "warning_instructions" in data:
|
||||
module_xml += "\t<warning_instructions><![CDATA[" + str(data["warning_instructions"]) + "]]></warning_instructions>\n"
|
||||
if "unknown_instructions" in data:
|
||||
module_xml += "\t<unknown_instructions><![CDATA[" + str(data["unknown_instructions"]) + "]]></unknown_instructions>\n"
|
||||
if "quiet" in data:
|
||||
module_xml += "\t<quiet><![CDATA[" + str(data["quiet"]) + "]]></quiet>\n"
|
||||
if "module_ff_interval" in data:
|
||||
module_xml += "\t<module_ff_interval><![CDATA[" + str(data["module_ff_interval"]) + "]]></module_ff_interval>\n"
|
||||
if "crontab" in data:
|
||||
module_xml += "\t<crontab><![CDATA[" + str(data["crontab"]) + "]]></crontab>\n"
|
||||
if "min_ff_event_normal" in data:
|
||||
module_xml += "\t<min_ff_event_normal><![CDATA[" + str(data["min_ff_event_normal"]) + "]]></min_ff_event_normal>\n"
|
||||
if "min_ff_event_warning" in data:
|
||||
module_xml += "\t<min_ff_event_warning><![CDATA[" + str(data["min_ff_event_warning"]) + "]]></min_ff_event_warning>\n"
|
||||
if "min_ff_event_critical" in data:
|
||||
module_xml += "\t<min_ff_event_critical><![CDATA[" + str(data["min_ff_event_critical"]) + "]]></min_ff_event_critical>\n"
|
||||
if "ff_type" in data:
|
||||
module_xml += "\t<ff_type><![CDATA[" + str(data["ff_type"]) + "]]></ff_type>\n"
|
||||
if "ff_timeout" in data:
|
||||
module_xml += "\t<ff_timeout><![CDATA[" + str(data["ff_timeout"]) + "]]></ff_timeout>\n"
|
||||
if "each_ff" in data:
|
||||
module_xml += "\t<each_ff><![CDATA[" + str(data["each_ff"]) + "]]></each_ff>\n"
|
||||
if "module_parent_unlink" in data:
|
||||
module_xml += "\t<module_parent_unlink><![CDATA[" + str(data["parent_unlink"]) + "]]></module_parent_unlink>\n"
|
||||
if "global_alerts" in data:
|
||||
for alert in data["alert"]:
|
||||
module_xml += "\t<alert_template><![CDATA[" + alert + "]]></alert_template>\n"
|
||||
module_xml += "</module>\n"
|
||||
|
||||
if print_flag:
|
||||
print (module_xml)
|
||||
|
||||
return (module_xml)
|
||||
|
||||
#########################################################################################
|
||||
# write_xml
|
||||
#########################################################################################
|
||||
|
||||
def write_xml(xml, agent_name, data_dir="/var/spool/pandora/data_in/"):
|
||||
"""Creates a agent .data file in the specified data_dir folder\n
|
||||
Args:
|
||||
- xml (str): XML string to be written in the file.
|
||||
- agent_name (str): agent name for the xml and file name.
|
||||
- data_dir (str): folder in which the file will be created."""
|
||||
Utime = datetime.now().strftime('%s')
|
||||
data_file = "%s/%s.%s.data" %(str(data_dir),agent_name,str(Utime))
|
||||
try:
|
||||
with open(data_file, 'x') as data:
|
||||
data.write(xml)
|
||||
except OSError as o:
|
||||
sys.exit(f"ERROR - Could not write file: {o}, please check directory permissions")
|
||||
except Exception as e:
|
||||
sys.exit(f"{type(e).__name__}: {e}")
|
||||
return (data_file)
|
||||
|
||||
# # default agent
|
||||
def clean_agent() :
|
||||
global agent
|
||||
agent = {
|
||||
"agent_name" : "",
|
||||
"agent_alias" : "",
|
||||
"parent_agent_name" : "",
|
||||
"description" : "",
|
||||
"version" : "",
|
||||
"os_name" : "",
|
||||
"os_version" : "",
|
||||
"timestamp" : datetime.today().strftime('%Y/%m/%d %H:%M:%S'),
|
||||
#"utimestamp" : int(datetime.timestamp(datetime.today())),
|
||||
"address" : "",
|
||||
"group" : config["group"],
|
||||
"interval" : "",
|
||||
"agent_mode" : "1",
|
||||
}
|
||||
return agent
|
||||
|
||||
# default module
|
||||
def clean_module() :
|
||||
global modulo
|
||||
modulo = {
|
||||
"name" : "",
|
||||
"type" : "generic_data_string",
|
||||
"desc" : "",
|
||||
"value" : "",
|
||||
}
|
||||
return modulo
|
||||
|
||||
#########################################################################################
|
||||
# tentacle_xml
|
||||
#########################################################################################
|
||||
def tentacle_xml(file, tentacle_ops,tentacle_path='', debug=0):
|
||||
"""Sends file using tentacle protocol\n
|
||||
- Only works with one file at time.
|
||||
- file variable needs full file path.
|
||||
- tentacle_opts should be a dict with tentacle options (address [password] [port]).
|
||||
- tentacle_path allows to define a custom path for tentacle client in case is not in sys path).
|
||||
- if debug is enabled, the data file will not be removed after being sent.
|
||||
|
||||
Returns 0 for OK and 1 for errors.
|
||||
"""
|
||||
|
||||
if file is None :
|
||||
sys.stderr.write("Tentacle error: file path is required.")
|
||||
else :
|
||||
data_file = file
|
||||
|
||||
if tentacle_ops['address'] is None :
|
||||
sys.stderr.write("Tentacle error: No address defined")
|
||||
return 1
|
||||
|
||||
try :
|
||||
with open(data_file, 'r') as data:
|
||||
data.read()
|
||||
data.close()
|
||||
except Exception as e :
|
||||
sys.stderr.write(f"Tentacle error: {type(e).__name__} {e}")
|
||||
return 1
|
||||
|
||||
tentacle_cmd = f"{tentacle_path}tentacle_client -v -a {tentacle_ops['address']} "
|
||||
if "port" in tentacle_ops:
|
||||
tentacle_cmd += f"-p {tentacle_ops['port']} "
|
||||
if "password" in tentacle_ops:
|
||||
tentacle_cmd += f"-x {tentacle_ops['password']} "
|
||||
tentacle_cmd += f"{data_file} "
|
||||
|
||||
tentacle_exe=Popen(tentacle_cmd, stdout=PIPE, shell=True)
|
||||
rc=tentacle_exe.wait()
|
||||
|
||||
if rc != 0 :
|
||||
sys.stderr.write("Tentacle error")
|
||||
return 1
|
||||
elif debug == 0 :
|
||||
os.remove(file)
|
||||
|
||||
return 0
|
||||
|
||||
## funcion agent
|
||||
def agentplugin(modules,agent,plugin_type="server",data_dir="/var/spool/pandora/data_in/",tentacle=False,tentacle_conf=None) :
|
||||
if plugin_type == "server":
|
||||
for modulo in modules:
|
||||
print_module(modulo,1)
|
||||
|
||||
elif tentacle == True and tentacle_conf is not None:
|
||||
agent_file=print_agent(agent, modules,data_dir)
|
||||
if agent_file[1] is not None:
|
||||
tentacle_xml(agent_file[1],tentacle_conf)
|
||||
print ("1")
|
||||
else:
|
||||
print_agent(agent, modules,data_dir)
|
||||
print ("1")
|
||||
|
||||
# Create agent
|
||||
clean_agent()
|
||||
agent.update(
|
||||
agent_name = args.agent_name ,
|
||||
agent_alias =args.agent_name ,
|
||||
description =""
|
||||
)
|
||||
|
||||
headers = {
|
||||
'Accept':'application/xml',
|
||||
'Content-Type': 'application/xml',
|
||||
}
|
||||
|
||||
req = {
|
||||
"urlxml": args.url
|
||||
}
|
||||
try:
|
||||
result = requests.get(req["urlxml"], verify=False, headers=headers, auth=HTTPBasicAuth(args.u, args.p))
|
||||
tree = ElementTree.fromstring(result.content)
|
||||
|
||||
except Exception as e :
|
||||
print('0')
|
||||
sys.exit("\nError requesting %s, please check conectivity" %(req["urlxml"],))
|
||||
|
||||
|
||||
|
||||
dicc_gauge= {}
|
||||
dicc_feature={}
|
||||
dicc_counter={}
|
||||
dicc_rate={}
|
||||
|
||||
for element in tree:
|
||||
for atributo in element:
|
||||
if atributo.tag=='gauge':
|
||||
dicc_gauge[atributo.tag+"_"+atributo.attrib['name']] = atributo.attrib['current']
|
||||
elif atributo.tag=='feature':
|
||||
dicc_feature[atributo.tag+"_"+atributo.attrib['name']] = atributo.attrib['time_remaining']
|
||||
elif atributo.tag=='counter':
|
||||
dicc_counter[atributo.tag+"_"+atributo.attrib['name']+"_reset"] = atributo.attrib['reset']
|
||||
dicc_counter[atributo.tag+"_"+atributo.attrib['name']+"_uptime"] = atributo.attrib['uptime']
|
||||
dicc_counter[atributo.tag+"_"+atributo.attrib['name']+"_lifetime"] = atributo.attrib['lifetime']
|
||||
elif atributo.tag=='rate':
|
||||
dicc_rate[atributo.tag+"_"+atributo.attrib['name']+"_last_1_min"] = atributo.attrib['last_1_min']
|
||||
dicc_rate[atributo.tag+"_"+atributo.attrib['name']+"_last_5_min"] = atributo.attrib['last_5_min']
|
||||
dicc_rate[atributo.tag+"_"+atributo.attrib['name']+"_last_15_min"] = atributo.attrib['last_15_min']
|
||||
|
||||
|
||||
for key,value in dicc_gauge.items():
|
||||
clean_module()
|
||||
modulo.update(
|
||||
name = key,
|
||||
type = "generic_data",
|
||||
desc = "",
|
||||
value = value
|
||||
)
|
||||
modules.append(modulo)
|
||||
|
||||
for key,value in dicc_feature.items():
|
||||
clean_module()
|
||||
modulo.update(
|
||||
name = key,
|
||||
type = "generic_data",
|
||||
desc = "",
|
||||
value = value
|
||||
)
|
||||
modules.append(modulo)
|
||||
|
||||
for key,value in dicc_counter.items():
|
||||
clean_module()
|
||||
modulo.update(
|
||||
name = key,
|
||||
type = "generic_data",
|
||||
desc = "",
|
||||
value = value
|
||||
)
|
||||
modules.append(modulo)
|
||||
|
||||
for key,value in dicc_rate.items():
|
||||
clean_module()
|
||||
modulo.update(
|
||||
name = key,
|
||||
type = "generic_data",
|
||||
desc = "",
|
||||
value = value
|
||||
)
|
||||
modules.append(modulo)
|
||||
|
||||
if args.tentacle_address is not None:
|
||||
tentacle_conf={"address":args.tentacle_address,"port":args.tentacle_port}
|
||||
agentplugin(modules,agent,"agent",config["data_in"],True,tentacle_conf)
|
||||
elif args.as_agent_plugin!=1:
|
||||
agentplugin(modules,agent,"agent",config["data_in"])
|
||||
else:
|
||||
agentplugin(modules,agent)
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-server
|
||||
Version: 7.0NG.763-220715
|
||||
Version: 7.0NG.763-220729
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.763-220715"
|
||||
pandora_version="7.0NG.763-220729"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.763";
|
||||
my $pandora_build = "220715";
|
||||
my $pandora_build = "220729";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -573,7 +573,7 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
|
||||
if ($timeBlock->{'start'} eq $timeBlock->{'end'}) {
|
||||
# All day.
|
||||
$inSlot = 1;
|
||||
} elsif ($timeBlock->{'start'} le $time && $timeBlock->{'end'} ge $time) {
|
||||
} elsif ($timeBlock->{'start'} le $time && (($timeBlock->{'end'} eq '00:00:00') || ($timeBlock->{'end'} ge $time))) {
|
||||
# In range.
|
||||
$inSlot = 1;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
||||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.763";
|
||||
my $pandora_build = "220715";
|
||||
my $pandora_build = "220729";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.763
|
||||
%define release 220715
|
||||
%define release 220729
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -9,7 +9,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.763"
|
||||
PI_BUILD="220715"
|
||||
PI_BUILD="220729"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
||||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.763 Build 220715";
|
||||
my $version = "7.0NG.763 Build 220729";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
||||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.763 Build 220715";
|
||||
my $version = "7.0NG.763 Build 220729";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user