Merge remote-tracking branch 'origin/develop' into ent-11471-integracion-pandora-integria

This commit is contained in:
daniel 2023-07-12 16:35:24 +02:00
commit a3eefacc80
43 changed files with 1962 additions and 1618 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.772-230711
Version: 7.0NG.772-230712
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -213,5 +213,5 @@ module_end
module_plugin grep_log /var/adm/syslog Syslog .
#Inventory plugin
#module_plugin /usr/share/pandora_agent/plugins/inventory_solaris.pl

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.772"
PI_BUILD="230711"
PI_BUILD="230712"
OS_NAME=`uname -s`
FORCE=0

View File

@ -0,0 +1,121 @@
#!/usr/bin/perl -w
#
use strict;
use Data::Dumper;
#print header
print "<inventory>\n";
#get pakahes
my @pkg_list = `/usr/bin/pkginfo -l 2> /dev/null`;
print " <inventory_module>\n";
print " <name><![CDATA[Software]]></name>\n";
print " <datalist>\n";
my $pkg;
foreach my $line (@pkg_list) {
chomp $line;
my $match = ( $line =~ /PKGINST:/ .. $line =~ /^$/ );
if ( $match && $match !~ /E0/ ) {
if ( $line =~ /^\s+([A-Z]+):\s+(.*)$/ ) {
my ($key, $val) = ($1, $2);
if ( $key eq 'FILES' ) {
if ( $val =~ /^(\d+) (.*)$/ ) {
$pkg->{FILES}->{$2} = $1;
}
}
else {
$pkg->{$1} = $2;
}
}
elsif ( $line =~ /^\s+([0-9]+) (.*)$/ ) {
$pkg->{FILES}->{$2} = $1;
}
else {
print "Unrecognized output: [$line]\n";
}
}
else {
#
# Blank line between packages
#
print "<data><![CDATA[";
print $pkg->{PKGINST} . ';';
print $pkg->{VERSION} . ';';
print $pkg->{NAME} . ';';
print "]]></data>\n";
}
}
print " </datalist>\n";
print " </inventory_module>\n";
#close software module
#CPU module
print " <inventory_module>\n";
print " <name><![CDATA[CPU]]></name>\n";
print " <datalist>\n";
my $cpu_model =`kstat cpu_info 2> /dev/null | grep brand | uniq | sed 's/.*brand//g' | tr -d ' '`;
my $cpu_clock = `kstat cpu_info 2> /dev/null | grep clock_MHz | uniq | awk '{print \$NF " Mhz"}'`;
my $cpu_brand = `kstat cpu_info 2> /dev/null | grep vendor_id | uniq | awk '{print \$NF}'`;
chomp $cpu_brand;
chomp $cpu_clock;
chomp $cpu_model;
print "<data><![CDATA[" . $cpu_model . ';' . $cpu_brand . ';' . $cpu_clock . "]]></data>\n";
print " </datalist>\n";
print " </inventory_module>\n";
#close cpu module
#RAM module
print " <inventory_module>\n";
print " <name><![CDATA[RAM]]></name>\n";
print " <datalist>\n";
my $memory_size =`prtconf 2> /dev/null | grep Memory | cut -d ':' -f 2`;
chomp $memory_size;
print "<data><![CDATA[System Memory;" . $memory_size . "]]></data>\n";
print " </datalist>\n";
print " </inventory_module>\n";
#close RAM module
#NIC module
print " <inventory_module>\n";
print " <name><![CDATA[NIC]]></name>\n";
print " <datalist>\n";
my @nic =`dladm show-link 2> /dev/null| grep -v STATE | awk '{print \$1}'`;
foreach my $nic (@nic){
chomp $nic;
my $nic_mac = `dladm show-linkprop $nic -p mac-address 2> /dev/null |grep -v LINK| awk '{print \$4}'`;
my $nic_speed = `dladm show-linkprop $nic -p speed 2> /dev/null |grep -v LINK| awk '{print \$4}'`;
chomp $nic_mac;
chomp $nic_speed;
print "<data><![CDATA[" . $nic . ';' . $nic_mac . ';'. $nic_speed . "]]></data>\n";
}
print " </datalist>\n";
print " </inventory_module>\n";
#close NIC module
#close inventory
print "</inventory>\n";

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{230711}
{230712}
ViewReadme
{Yes}

View File

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

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.772(Build 230711))"
VALUE "ProductVersion", "(7.0NG.772(Build 230712))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.772-230711
Version: 7.0NG.772-230712
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -10,7 +10,13 @@ ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`;
DELETE FROM tconfig WHERE token = 'refr';
ALTER TABLE `tusuario` ADD COLUMN `session_max_time_expire` INT NOT NULL DEFAULT 0 AFTER `auth_token_secret`;
INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (37,2,'CPU','CPU','','Brand;Clock;Model','',0,2);
INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (38,2,'RAM','RAM','','Size','',0,2);
INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (39,2,'NIC','NIC','','NIC;Mac;Speed','',0,2);
INSERT INTO `tmodule_inventory` (`id_module_inventory`, `id_os`, `name`, `description`, `interpreter`, `data_format`, `code`, `block_mode`,`script_mode`) VALUES (40,2,'Software','Software','','PKGINST;VERSION;NAME','',0,2);
ALTER TABLE `treport_content` ADD COLUMN `period_range` INT NULL DEFAULT 0 AFTER `period`;

File diff suppressed because it is too large Load Diff

View File

@ -508,11 +508,11 @@ switch ($action) {
$buttons = [
'list_reports' => [
'active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">'.html_print_image(
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'&action=list">'.html_print_image(
'images/logs@svg.svg',
true,
[
'title' => __('Reports list'),
'title' => __('Reports'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
@ -545,7 +545,7 @@ switch ($action) {
// Header.
ui_print_standard_header(
__('List of reports'),
__('Reports'),
'images/op_reporting.png',
false,
'',
@ -3678,7 +3678,7 @@ switch ($action) {
$buttons = [
'list_reports' => [
'active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">'.html_print_image('images/logs@svg.svg', true, ['title' => __('Reports list'), 'class' => 'invert_filter main_menu_icon']).'</a>',
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'&action=list">'.html_print_image('images/logs@svg.svg', true, ['title' => __('Reports'), 'class' => 'invert_filter main_menu_icon']).'</a>',
],
];
@ -3745,7 +3745,7 @@ $buttons = [
'images/report_list.png',
true,
[
'title' => __('Reports list'),
'title' => __('Reports'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',
@ -3793,12 +3793,13 @@ if ($idReport != 0) {
$buttons = [
'main' => [
'active' => true,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">'.html_print_image('images/report_list.png', true, ['title' => __('Reports list'), 'class' => 'main_menu_icon invert_filter']).'</a>',
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'&action=list">'.html_print_image('images/report_list.png', true, ['title' => __('Reports'), 'class' => 'main_menu_icon invert_filter']).'</a>',
],
];
$textReportName = __('Create Custom Report');
}
// here1
$tab_builder = ($activeTab === 'item_editor') ? 'reporting_item_editor_tab' : '';
if (is_metaconsole() === true || $action !== 'update') {

View File

@ -683,11 +683,12 @@ if ($update_user) {
$password_new = (string) get_parameter('password_new', '');
$password_confirm = (string) get_parameter('password_confirm', '');
$own_password_confirm = (string) get_parameter('own_password_confirm', '');
$id_user = (string) get_parameter('id_user', '');
if ($password_new != '') {
$correct_password = false;
$user_credentials_check = process_user_login($config['id_user'], $own_password_confirm, true);
$user_credentials_check = process_user_login($id_user, $own_password_confirm, true);
if ($user_credentials_check !== false) {
$correct_password = true;

View File

@ -302,25 +302,45 @@ $passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_e
true
);
if ($new_user === false) {
if ($new_user === false && users_is_admin() === false) {
$passwordManageTable->data['captions_currentpassword'][0] = __('Current password');
$passwordManageTable->rowclass['fields_currentpassword'] = 'w540px';
$passwordManageTable->data['fields_currentpassword'][0] = html_print_input_text_extended(
'own_password_confirm',
'',
'own_password_confirm',
'',
'20',
'150',
$view_mode,
'',
[
'class' => 'input w100p',
'placeholder' => __('Own password confirmation'),
],
true,
true
);
if ($user_info['id_user'] === $config['id_user']) {
$passwordManageTable->data['fields_currentpassword'][0] = html_print_input_text_extended(
'own_password_confirm',
'',
'own_password_confirm',
'',
'20',
'45',
$view_mode,
'',
[
'class' => 'input w100p',
'placeholder' => __('Own password confirmation'),
],
true,
true
);
} else {
$passwordManageTable->data['fields_currentpassword'][0] = html_print_input_text_extended(
'own_password_confirm',
'',
'own_password_confirm',
'',
'20',
'45',
$view_mode,
'',
[
'class' => 'input w100p',
'placeholder' => __('Third user password confirmation'),
],
true,
true
);
}
}
$userManagementTable->data['passwordManage_table'] = html_print_table($passwordManageTable, true);

View File

@ -679,20 +679,24 @@ class ConsoleSupervisor
*/
public function checkAccessStatisticsPerformance()
{
global $config;
$total_agents = db_get_value('count(*)', 'tagente');
if ($total_agents >= 200) {
db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']);
$this->notify(
[
'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE',
'title' => __('Access statistics performance'),
'message' => __(
'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty'
),
'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup&section=perf',
]
);
if ($config['agentaccess'] !== 0) {
db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']);
$this->notify(
[
'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE',
'title' => __('Access statistics performance'),
'message' => __(
'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty'
),
'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup&section=perf',
]
);
}
} else {
$this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE');
}
@ -2375,7 +2379,8 @@ class ConsoleSupervisor
'SELECT count(*) FROM tusuario
WHERE
id_user="admin"
AND password="1da7ee7d45b96d0e1f45ee4ee23da560"
AND (password="1da7ee7d45b96d0e1f45ee4ee23da560" OR
password="$2y$10$Wv/xoxjI2VAkthJhk/PzeeGIhBKYU/K.TMgUdmW7fEP2NQkdWlB9K")
AND is_admin=1
and disabled!=1'
);

View File

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

View File

@ -11546,6 +11546,11 @@ function api_get_events($node_id, $trash2, $other, $returnType)
}
}
// Add agent name to nodo.
if (is_metaconsole() === false && empty($row['id_agente']) === false) {
$row['agent_name'] = agents_get_name($row['id_agente']);
}
// FOR THE TEST THE API IN THE ANDROID.
$row['description_event'] = events_print_type_description($row['event_type'], true);
$row['img_description'] = events_print_type_img($row['event_type'], true, true);

View File

@ -1920,7 +1920,8 @@ function html_print_extended_select_for_unit(
$select_style=false,
$unique_name=true,
$disabled=false,
$no_change=0
$no_change=0,
$class='w100p'
) {
global $config;
@ -1952,7 +1953,7 @@ function html_print_extended_select_for_unit(
ob_start();
echo '<div id="'.$uniq_name.'_default" class="w100p inline_line">';
echo '<div id="'.$uniq_name.'_default" class="'.$class.' inline_line">';
html_print_select(
$fields,
$uniq_name.'_select',
@ -3923,6 +3924,14 @@ function html_print_table(&$table, $return=false)
}
}
if (isset($table->tdid)) {
foreach ($table->tdid as $keyrow => $tid) {
foreach ($tid as $key => $id) {
$tdid[$keyrow][$key] = $id;
}
}
}
if (isset($table->cellstyle)) {
foreach ($table->cellstyle as $keyrow => $cstyle) {
foreach ($cstyle as $key => $cst) {
@ -4106,6 +4115,10 @@ function html_print_table(&$table, $return=false)
$colspan[$keyrow][$key] = '';
}
if (!isset($tdid[$keyrow][$key])) {
$tdid[$keyrow][$key] = '';
}
if (!isset($rowspan[$keyrow][$key])) {
$rowspan[$keyrow][$key] = '';
}
@ -4126,10 +4139,16 @@ function html_print_table(&$table, $return=false)
$style[$key] = '';
}
if ($class === 'datos5' && $key === 1) {
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
if ($tdid[$keyrow][$key] !== '') {
$tid = $tdid[$keyrow][$key];
} else {
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].'" '.$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
$tid = $tableid.'-'.$keyrow.'-'.$key;
}
if ($class === 'datos5' && $key === 1) {
$output .= '<td id="'.$tid.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
} else {
$output .= '<td id="'.$tid.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].'" '.$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
}
}

View File

@ -4343,7 +4343,7 @@ function ui_print_datatable(array $parameters)
$(".action_buttons_right_content").html("<div class=\"pagination-child-div\"></div>");
$(".action_buttons_right_content").html("<div class=\"pagination-child-div\"></div>");
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").attr("style","margin-right: 10px;"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_length"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dt-buttons"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_filter"));

View File

@ -11662,8 +11662,8 @@ p.trademark-copyright {
}
.show-hide-pass {
position: absolute;
right: 12px;
position: relative;
right: 40px;
top: 4px;
border: 0;
outline: none;

View File

@ -131,7 +131,7 @@
<div style='padding-bottom: 50px'>
<?php
$version = '7.0NG.772';
$build = '230711';
$build = '230712';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -111,11 +111,11 @@ $options = [];
$options['list_reports'] = [
'active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">'.html_print_image(
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'&action=list">'.html_print_image(
'images/report_list.png',
true,
[
'title' => __('Report list'),
'title' => __('Reports'),
'class' => 'main_menu_icon invert_filter',
]
).'</a>',

View File

@ -16,163 +16,52 @@ global $config;
enterprise_include_once('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_users.php';
$searchAgents = check_acl($config['id_user'], 0, 'AR');
$selectNameUp = '';
$selectNameDown = '';
$selectDescriptionUp = '';
$selectDescriptionDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$selectGroupUp = '';
$selectGroupDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
switch ($sortField) {
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = [
'field' => 'nombre',
'order' => 'ASC',
];
break;
case 'down':
$selectNameDown = $selected;
$order = [
'field' => 'nombre',
'order' => 'DESC',
];
break;
}
break;
case 'comentarios':
switch ($sort) {
case 'up':
$selectDescriptionUp = $selected;
$order = [
'field' => 'comentarios',
'order' => 'ASC',
];
break;
case 'down':
$selectDescriptionDown = $selected;
$order = [
'field' => 'comentarios',
'order' => 'DESC',
];
break;
}
break;
case 'os':
switch ($sort) {
case 'up':
$selectOsUp = $selected;
$order = [
'field' => 'id_os',
'order' => 'ASC',
];
break;
case 'down':
$selectOsDown = $selected;
$order = [
'field' => 'id_os',
'order' => 'DESC',
];
break;
}
break;
case 'interval':
switch ($sort) {
case 'up':
$selectIntervalUp = $selected;
$order = [
'field' => 'intervalo',
'order' => 'ASC',
];
break;
case 'down':
$selectIntervalDown = $selected;
$order = [
'field' => 'intervalo',
'order' => 'DESC',
];
break;
}
break;
case 'group':
switch ($sort) {
case 'up':
$selectGroupUp = $selected;
$order = [
'field' => 'id_grupo',
'order' => 'ASC',
];
break;
case 'down':
$selectGroupDown = $selected;
$order = [
'field' => 'id_grupo',
'order' => 'DESC',
];
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = [
'field' => 'ultimo_contacto',
'order' => 'ASC',
];
break;
case 'down':
$selectLastContactDown = $selected;
$order = [
'field' => 'ultimo_contacto',
'order' => 'DESC',
];
break;
}
break;
default:
$selectNameUp = $selected;
$selectNameDown = '';
$selectDescriptionUp = '';
$selectDescriptionDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$selectGroupUp = '';
$selectGroupDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = [
'field' => 'nombre',
'order' => 'ASC',
];
break;
$searchAgents = get_parameter('search_agents', 0);
$stringSearchSQL = get_parameter('stringSearchSQL');
$order = get_datatable_order(true);
if (empty($order)) {
$order = [];
}
$totalAgents = 0;
switch ($order['field']) {
case 'comentarios':
$order['field'] = 't1.comentarios';
break;
case 'os':
$order['field'] = 't1.id_os';
break;
case 'interval':
$order['field'] = 't1.intervalo';
break;
case 'group_icon':
$order['field'] = 't1.id_grupo';
break;
case 'module':
$order['field'] = 'id_agente';
break;
case 'status':
$order['field'] = 'id_agente';
break;
case 'alert':
$order['field'] = 'id_agente';
break;
case 'last_contact':
$order['field'] = 't1.ultimo_contacto';
break;
case 'agent':
default:
$order['field'] = 't1.alias';
break;
}
$agents = false;
if ($searchAgents) {
@ -181,19 +70,20 @@ if ($searchAgents) {
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
$stringSearchSQL = str_replace('&amp;', '&', $stringSearchSQL);
$sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress
INNER JOIN taddress_agent ON
taddress.id_a = taddress_agent.id_a
WHERE taddress.ip LIKE '%$stringSearchSQL%'";
WHERE taddress.ip LIKE '$stringSearchSQL'";
$id = db_get_all_rows_sql($sql);
if ($id != '') {
$aux = $id[0]['id_agent'];
$search_sql = " t1.nombre LIKE '%%cd ".$stringSearchSQL."%%' OR
t2.nombre LIKE '%%".$stringSearchSQL."%%' OR
t1.alias LIKE '%%".$stringSearchSQL."%%' OR
t1.comentarios LIKE '%%".$stringSearchSQL."%%' OR
t1.id_agente = $aux";
$search_sql = " t1.nombre LIKE '".$stringSearchSQL."' OR
t2.nombre LIKE '".$stringSearchSQL."' OR
t1.alias LIKE '".$stringSearchSQL."' OR
t1.comentarios LIKE '".$stringSearchSQL."' OR
t1.id_agente =".$aux;
$idCount = count($id);
@ -204,16 +94,16 @@ if ($searchAgents) {
}
}
} else {
$search_sql = " t1.nombre LIKE '%%".$stringSearchSQL."%%' OR
t2.nombre LIKE '%%".$stringSearchSQL."%%' OR
t1.direccion LIKE '%%".$stringSearchSQL."%%' OR
t1.comentarios LIKE '%%".$stringSearchSQL."%%' OR
t1.alias LIKE '%%".$stringSearchSQL."%%'";
$search_sql = " t1.nombre LIKE '".$stringSearchSQL."' OR
t2.nombre LIKE '".$stringSearchSQL."' OR
t1.direccion LIKE '".$stringSearchSQL."' OR
t1.comentarios LIKE '".$stringSearchSQL."' OR
t1.alias LIKE '".$stringSearchSQL."'";
}
if ($has_secondary === true) {
$search_sql .= " OR (tasg.id_group IS NOT NULL AND
tasg.id_group IN (SELECT id_grupo FROM tgrupo WHERE nombre LIKE '%%".$stringSearchSQL."%%'))";
tasg.id_group IN (SELECT id_grupo FROM tgrupo WHERE nombre LIKE '".$stringSearchSQL."'))";
}
$sql = "
@ -247,10 +137,14 @@ if ($searchAgents) {
';
$select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.comentarios, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet';
if ($only_count) {
$limit = ' ORDER BY '.$order['field'].' '.$order['order'].' LIMIT '.$config['block_size'].' OFFSET 0';
} else {
$limit = ' ORDER BY '.$order['field'].' '.$order['order'].' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0);
if (is_array($order)) {
// Datatables offset, limit.
$start = get_parameter('start', 0);
$length = get_parameter(
'length',
$config['block_size']
);
$limit = ' ORDER BY '.$order['field'].' '.$order['direction'].' LIMIT '.$length.' OFFSET '.$start;
}
$query = $select.$sql;
@ -272,4 +166,45 @@ if ($searchAgents) {
'SELECT COUNT(DISTINCT id_agente) AS agent_count '.$sql
);
}
foreach ($agents as $key => $agent) {
if ($agent['disabled']) {
$agents[$key]['agent'] = '<em><a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'
title="'.$agent['id_agente'].'"><b><span style>'.ucfirst(strtolower($agent['alias'])).'</span></b></a>'.ui_print_help_tip(__('Disabled'), true).'</em>';
} else {
$agents[$key]['agent'] = '<a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'
title='.$agent['nombre'].'><b><span style>'.ucfirst(strtolower($agent['alias'])).'</span></b></a>';
}
$agents[$key]['os'] = ui_print_os_icon($agent['id_os'], false, true);
$agents[$key]['interval'] = human_time_description_raw($agent['intervalo'], false, 'tiny');
$agents[$key]['group_icon'] = ui_print_group_icon($agent['id_grupo'], true);
$agent_info = reporting_get_agent_module_info($agent['id_agente']);
$modulesCell = reporting_tiny_stats($agent_info, true);
$agents[$key]['module'] = $modulesCell;
$agents[$key]['status'] = $agent_info['status_img'];
$agents[$key]['alert'] = $agent_info['alert_img'];
$last_time = time_w_fixed_tz($agent['ultimo_contacto']);
$now = get_system_time();
$diferencia = ($now - $last_time);
$time = ui_print_timestamp($last_time, true);
$time_style = $time;
if ($diferencia > ($agent['intervalo'] * 2)) {
$time_style = '<b><span class="color_ff0">'.$time.'</span></b>';
}
$agents[$key]['last_contact'] = $time_style;
}
// RecordsTotal && recordsfiltered resultados totales.
echo json_encode(
[
'data' => ($agents ?? []),
'recordsTotal' => $totalAgents,
'recordsFiltered' => $totalAgents,
]
);
}

View File

@ -13,174 +13,63 @@
// GNU General Public License for more details.
global $config;
enterprise_include_once('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_users.php';
/*
enterprise_include_once('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_users.php';*/
if ($only_count) {
ob_start();
}
// Datatables list.
try {
$columns = [
'agent',
'comentarios',
'os',
'interval',
'group_icon',
'module',
'status',
'alert',
'last_contact',
];
// TODO: CLEAN extra_sql
$extra_sql = '';
$column_names = [
__('Agent'),
__('Description'),
__('OS'),
__('Interval'),
__('Group'),
__('Modules'),
__('Status'),
__('Alerts'),
__('Last contact'),
];
$searchAgents = check_acl($config['id_user'], 0, 'AR');
$tableId = 'agents_search';
$stringSearchSQL = $_SESSION['stringSearchSQL'];
if (!$agents || !$searchAgents) {
if (!$only_count) {
echo "<br><div class='nf'>".__('Zero results found')."</div>\n";
}
} else {
$table = new stdClass();
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = '98%';
$table->class = 'info_table';
$table->head = [];
if ($only_count) {
$table->head[0] = __('Agent');
$table->head[1] = __('Description');
$table->head[2] = __('OS');
$table->head[3] = __('Interval');
$table->head[4] = __('Group');
} else {
$table->head[0] = __('Agent').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=name&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectNameUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=name&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectNameDown]).'</a>';
$table->head[1] = __('Description').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=comentarios&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectDescriptionUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=comentarios&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectDescriptionDown]).'</a>';
$table->head[2] = __('OS').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=os&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectOsUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=os&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectOsDown]).'</a>';
$table->head[3] = __('Interval').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=interval&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=interval&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown]).'</a>';
$table->head[4] = __('Group').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=group&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectGroupUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=group&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectGroupDown]).'</a>';
}
$table->head[5] = __('Modules');
$table->head[6] = __('Status');
$table->head[7] = __('Alerts');
$table->head[8] = __('Last contact').' '.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=last_contact&sort=up">'.html_print_image('images/sort_up.png', true, ['style' => $selectLastContactUp]).'</a>'.'<a href="index.php?search_category=agents&keywords='.$config['search_keywords'].'&head_search_keywords=abc&offset='.$offset.'&sort_field=last_contact&sort=down">'.html_print_image('images/sort_down.png', true, ['style' => $selectLastContactDown]).'</a>';
$table->head[9] = '';
$table->headstyle = [];
$table->headstyle[0] = 'text-align: left';
$table->headstyle[1] = 'text-align: left';
$table->headstyle[2] = 'text-align: left';
$table->headstyle[3] = 'text-align: left';
$table->headstyle[4] = 'text-align: left';
$table->headstyle[5] = 'text-align: left';
$table->headstyle[6] = 'text-align: left';
$table->headstyle[7] = 'text-align: left';
$table->headstyle[8] = 'text-align: left';
$table->headstyle[9] = 'text-align: center';
$table->align = [];
$table->align[0] = 'left';
$table->align[1] = 'left';
$table->align[2] = 'left';
$table->align[3] = 'left';
$table->align[4] = 'left';
$table->align[5] = 'left';
$table->align[6] = 'left';
$table->align[7] = 'left';
$table->align[8] = 'left';
$table->align[9] = 'center';
$table->data = [];
foreach ($agents as $agent) {
$agent_info = reporting_get_agent_module_info($agent['id_agente']);
$modulesCell = reporting_tiny_stats($agent_info, true);
if ($agent['disabled']) {
$cellName = '<em>'.'<a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].' title='.$agent['nombre'].'><b>'.'<span style>'.$agent['alias'].'</span></b></a>'.ui_print_help_tip(__('Disabled'), true).'</em>';
} else {
$cellName = '<a style href=index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].' title='.$agent['nombre'].'><b>'.'<span style>'.$agent['alias'].'</span></b></a>';
}
if ($agent['quiet']) {
$cellName .= '&nbsp;';
$cellName .= html_print_image('images/dot_blue.png', true, ['border' => '0', 'title' => __('Quiet'), 'alt' => '']);
}
$in_planned_downtime = db_get_sql(
'SELECT executed FROM tplanned_downtime
INNER JOIN tplanned_downtime_agents
ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime
WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1'
);
if ($in_planned_downtime) {
$cellName .= '<em>'.ui_print_help_tip(__('Agent in scheduled downtime'), true, 'images/minireloj-16.png');
$cellName .= '</em>';
}
$last_time = time_w_fixed_tz($agent['ultimo_contacto']);
$now = get_system_time();
$diferencia = ($now - $last_time);
$time = ui_print_timestamp($last_time, true);
$time_style = $time;
if ($diferencia > ($agent['intervalo'] * 2)) {
$time_style = '<b><span class="color_ff0">'.$time.'</span></b>';
}
$manage_agent = '';
if (check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
$url_manage = 'index.php?sec=estado&sec2=godmode/agentes/configurar_agente&id_agente='.$agent['id_agente'];
$manage_agent = '<a href="'.$url_manage.'">'.html_print_image(
'images/cog.png',
true,
[
'title' => __('Manage'),
'alt' => __('Manage'),
'class' => 'invert_filter',
]
).'</a>';
}
$table->cellclass[][9] = 'table_action_buttons';
array_push(
$table->data,
[
$cellName,
ui_print_truncate_text($agent['comentarios'], 'comentarios', false, true, true, '[&hellip;]'),
ui_print_os_icon($agent['id_os'], false, true),
human_time_description_raw($agent['intervalo'], false, 'tiny'),
ui_print_group_icon($agent['id_grupo'], true),
$modulesCell,
$agent_info['status_img'],
$agent_info['alert_img'],
$time_style,
$manage_agent,
]
);
}
echo '<br />';
html_print_table($table);
unset($table);
if (!$only_count) {
$tablePagination = ui_pagination(
$totalAgents,
false,
0,
0,
true,
'offset',
false
);
}
html_print_action_buttons(
'',
unset($_SESSION['stringSearchSQL']);
// Load datatables user interface.
ui_print_datatable(
[
'type' => 'data_table',
'class' => 'fixed_action_buttons',
'right_content' => $tablePagination,
'id' => $tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'operation/search_agents.getdata',
'ajax_data' => [
'search_agents' => 1,
'stringSearchSQL' => $stringSearchSQL,
],
'order' => [
'field' => 'alias',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
]
);
}
if ($only_count) {
$list_agents = ob_get_clean();
html_print_action_buttons('');
} catch (Exception $e) {
echo $e->getMessage();
}

View File

@ -48,7 +48,79 @@ $table->style[13] = 'font-weight: bold; text-align: left;';
$table->style[14] = 'font-weight: bold; text-align: left;';
$table->style[15] = 'font-weight: bold; text-align: left;';
// Get total agents.
$userGroups = users_get_groups($config['id_user'], 'AR', false);
$id_userGroups = array_keys($userGroups);
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
$stringSearchSQL = str_replace('&amp;', '&', $stringSearchSQL);
$sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress
INNER JOIN taddress_agent ON
taddress.id_a = taddress_agent.id_a
WHERE taddress.ip LIKE '$stringSearchSQL'";
$id = db_get_all_rows_sql($sql);
if ($id != '') {
$aux = $id[0]['id_agent'];
$search_sql = " t1.nombre LIKE '".$stringSearchSQL."' OR
t2.nombre LIKE '".$stringSearchSQL."' OR
t1.alias LIKE '".$stringSearchSQL."' OR
t1.comentarios LIKE '".$stringSearchSQL."' OR
t1.id_agente =".$aux;
$idCount = count($id);
if ($idCount >= 2) {
for ($i = 1; $i < $idCount; $i++) {
$aux = $id[$i]['id_agent'];
$search_sql .= " OR t1.id_agente = $aux";
}
}
} else {
$search_sql = " t1.nombre LIKE '".$stringSearchSQL."' OR
t2.nombre LIKE '".$stringSearchSQL."' OR
t1.direccion LIKE '".$stringSearchSQL."' OR
t1.comentarios LIKE '".$stringSearchSQL."' OR
t1.alias LIKE '".$stringSearchSQL."'";
}
if ($has_secondary === true) {
$search_sql .= " OR (tasg.id_group IS NOT NULL AND
tasg.id_group IN (SELECT id_grupo FROM tgrupo WHERE nombre LIKE '".$stringSearchSQL."'))";
}
$sql = "
FROM tagente t1 LEFT JOIN tagent_secondary_group tasg
ON t1.id_agente = tasg.id_agent
INNER JOIN tgrupo t2
ON t2.id_grupo = t1.id_grupo
WHERE (
1 = (
SELECT is_admin
FROM tusuario
WHERE id_user = '".$config['id_user']."'
)
OR (
t1.id_grupo IN (".implode(',', $id_userGroups).')
OR tasg.id_group IN ('.implode(',', $id_userGroups).")
)
OR 0 IN (
SELECT id_grupo
FROM tusuario_perfil
WHERE id_usuario = '".$config['id_user']."'
AND id_perfil IN (
SELECT id_perfil
FROM tperfil WHERE agent_view = 1
)
)
)
AND (
".$search_sql.'
)
';
$totalAgents = db_get_value_sql(
'SELECT COUNT(DISTINCT id_agente) AS agent_count '.$sql
);
$table->data[0][0] = html_print_image('images/agent.png', true, ['title' => __('Agents found'), 'class' => 'invert_filter']);
@ -76,14 +148,10 @@ if (enterprise_installed()) {
html_print_table($table);
if ($searchAgents && $totalAgents > 0) {
if ($searchAgents) {
echo $list_agents;
echo "<a href='index.php?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".sprintf(
__('Show %s of %s. View all matches'),
$count_agents_main,
$totalAgents
).'</a>';
echo "<a href='index.php?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('View all matches').'</a>';
}

View File

@ -36,6 +36,7 @@ foreach ($arrayKeywords as $keyword) {
$stringSearchSQL = implode('&#x20;', $temp);
$stringSearchSQL = str_replace('_', '\_', $stringSearchSQL);
$_SESSION['stringSearchSQL'] = $stringSearchSQL;
if ($config['search_category'] == 'all') {
$searchTab = 'main';
} else {
@ -205,6 +206,7 @@ ui_print_standard_header(
);
$only_count = false;
switch ($searchTab) {
case 'main':
$only_count = true;

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.772-230711
Version: 7.0NG.772-230712
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.772";
my $pandora_build = "230711";
my $pandora_build = "230712";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
@ -2366,7 +2366,8 @@ sub snmp_data_switcher {
}
if ($data{type} eq "generic_data"){
($data{data} = $pure_data) =~ s/\D*//g;
$data{data} = $pure_data;
$data{data} =~ s/[^-\d]//g;
}
return \%data;

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.772
%define release 230711
%define release 230712
Summary: Pandora FMS Server
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_server
%define version 7.0NG.772
%define release 230711
%define release 230712
Summary: Pandora FMS Server
Name: %{name}

View File

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

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.772 Build 230711";
my $version = "7.0NG.772 Build 230712";
# Pandora server configuration
my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.772 Build 230711";
my $version = "7.0NG.772 Build 230712";
# save program name for logging
my $progname = basename($0);
@ -4453,16 +4453,9 @@ sub cli_create_event() {
exist_check($id_user,'user',$user_name);
}
my $id_group;
if (! $group_name || $group_name eq "All") {
$id_group = 0;
}
else {
$id_group = get_group_id($dbh,$group_name);
exist_check($id_group,'group',$group_name);
}
my $id_group = get_group_id($dbh,$group_name);
exist_check($id_group,'group',$group_name);
my $id_agent;
if (defined $use_alias and $use_alias eq 'use_alias') {
@ -4515,7 +4508,7 @@ sub cli_create_event() {
# exist_check($id_agent,'agent',$agent_name);
if($id_agent == -1){
if($force_create_agent == 1){
pandora_create_agent ($conf, '', $agent_name, '', '', '', '', 'Created by cli_create_event', '', $dbh);
pandora_create_agent ($conf, '', $agent_name, '', $id_group, '', '', 'Created by cli_create_event', '', $dbh);
print_log "[INFO] Adding agent '$agent_name' \n\n";
$id_agent = get_agent_id($dbh,$agent_name);
}
@ -5923,13 +5916,25 @@ sub cli_get_bad_conf_files() {
foreach my $file (@files) {
# Check important tokens
my $missings = 0;
my @tokens = ("server_ip","server_path","temporal","log_file");
my @tokens = ("server_ip","server_path","temporal","logfile");
if ($file !~ /.srv./) {
foreach my $token (@tokens) {
if(enterprise_hook('pandora_check_conf_token',[$conf->{incomingdir}.'/conf/'.$file, $token]) == 0) {
my $result = enterprise_hook('pandora_check_conf_token', [$conf->{incomingdir}.'/conf/'.$file, $token]);
if($result == 0) {
$missings++;
}
elsif ($result == -1) {
print_log "[WARN] File not exists /conf/".$file."\n\n";
$bad_files++;
last;
}
elsif(!defined $result) {
print_log "[WARN] Can't open file /conf/".$file."\n\n";
$bad_files++;
last;
}
}
# If any token of checked is missed we print the file path