Merge branch 'develop' into '393-Feature-para-mostrar-los-timesticks-en-Dias-Horas-Minutos-Seg-dev'

# Conflicts:
#   pandora_console/include/functions_graph.php
This commit is contained in:
Daniel Maya 2017-09-25 15:34:39 +02:00
commit 237755a84c
53 changed files with 2575 additions and 1270 deletions

View File

@ -58,6 +58,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# Server password (Tentacle or FTP). Leave empty for no password (default). # Server password (Tentacle or FTP). Leave empty for no password (default).
# server_pwd mypassword # server_pwd mypassword

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.712-170914 Version: 7.0NG.712-170925
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -88,6 +88,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# Server password (Tentacle or FTP). Leave empty for no password (default). # Server password (Tentacle or FTP). Leave empty for no password (default).
#server_pwd mypassword #server_pwd mypassword

View File

@ -98,6 +98,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# timeout in seconds for file transfer programs execution (30 by default) # timeout in seconds for file transfer programs execution (30 by default)
#transfer_timeout 30 #transfer_timeout 30

View File

@ -60,6 +60,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# Server password (Tentacle or FTP). Leave empty for no password (default). # Server password (Tentacle or FTP). Leave empty for no password (default).
# server_pwd mypassword # server_pwd mypassword

View File

@ -104,6 +104,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# timeout in seconds for file transfer programs execution (30 by default) # timeout in seconds for file transfer programs execution (30 by default)
#transfer_timeout 30 #transfer_timeout 30

View File

@ -66,6 +66,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# timeout in seconds for file transfer programs execution (30 by default) # timeout in seconds for file transfer programs execution (30 by default)
#transfer_timeout 30 #transfer_timeout 30

View File

@ -60,6 +60,9 @@ server_port 41121
# Transfer mode: tentacle, ftp, ssh or local # Transfer mode: tentacle, ftp, ssh or local
transfer_mode tentacle transfer_mode tentacle
# Transfer mode user: Owner of files copied on local transfer mode (default apache)
#transfer_mode_user apache
# timeout in seconds for file transfer programs execution (30 by default) # timeout in seconds for file transfer programs execution (30 by default)
#transfer_timeout 30 #transfer_timeout 30

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.712'; use constant AGENT_VERSION => '7.0NG.712';
use constant AGENT_BUILD => '170914'; use constant AGENT_BUILD => '170925';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -128,6 +128,9 @@ my @BrokerPid;
my %DefaultConf = ( my %DefaultConf = (
'server_ip' => 'localhost', 'server_ip' => 'localhost',
'server_path' => '/var/spool/pandora/data_in', 'server_path' => '/var/spool/pandora/data_in',
'server_path_md5' => 'md5', #undocumented
'server_path_conf' => 'conf', #undocumented
'server_path_zip' => 'collections', #undocumented
'logfile' =>'/var/log/pandora/pandora_agent.log', 'logfile' =>'/var/log/pandora/pandora_agent.log',
'logsize' => DEFAULT_MAX_LOG_SIZE, 'logsize' => DEFAULT_MAX_LOG_SIZE,
'logrotate' => DEFAULT_LOG_ROTATE, 'logrotate' => DEFAULT_LOG_ROTATE,
@ -146,6 +149,7 @@ my %DefaultConf = (
'encoding' => 'UTF-8', 'encoding' => 'UTF-8',
'server_port' => 41121, 'server_port' => 41121,
'transfer_mode' => 'tentacle', 'transfer_mode' => 'tentacle',
'transfer_mode_user' => 'apache',
'transfer_timeout' => 30, 'transfer_timeout' => 30,
'server_user' => 'pandora', 'server_user' => 'pandora',
'server_pwd' => '', 'server_pwd' => '',
@ -906,13 +910,17 @@ sub fix_directory ($) {
################################################################################ ################################################################################
# Sends a file to the server. # Sends a file to the server.
################################################################################ ################################################################################
#sub send_file ($;$$$) {
sub send_file { sub send_file {
my ($file, $secondary, $rc_primary, $flag_always) = @_; my ($file, $secondary, $rc_primary, $flag_always, $relative) = @_;
my $output; my $output;
my $pid = fork(); my $pid = fork();
return 1 unless defined $pid; return 1 unless defined $pid;
# Fix remote dir to some transfer mode
my $remote_dir = $Conf{'server_path'} . "/";
$remote_dir .= fix_directory($relative) . '/' if defined($relative);
if ($pid == 0) { if ($pid == 0) {
# execute the transfer program by child process. # execute the transfer program by child process.
eval { eval {
@ -935,7 +943,7 @@ sub send_file {
quit quit
FEOF1` FEOF1`
} elsif ($Conf{'transfer_mode'} eq 'local') { } elsif ($Conf{'transfer_mode'} eq 'local') {
$output = `cp "$file" "$Conf{'server_path'}/" 2>&1 >$DevNull`; $output = `cp -p "$file" "$remote_dir" 2>&1 >$DevNull`;
} }
alarm (0); alarm (0);
}; };
@ -966,7 +974,7 @@ sub send_file {
$rc_primary = 1; $rc_primary = 1;
} }
swap_servers (); swap_servers ();
$rc = send_file ($file, undef, $rc_primary); $rc = send_file ($file, undef, $rc_primary, undef, $relative);
swap_servers (); swap_servers ();
return $rc; return $rc;
@ -1024,7 +1032,7 @@ sub send_file {
return $rc unless ($Conf{'secondary_mode'} eq 'always' || ($Conf{'secondary_mode'} eq 'on_error' && $rc != 0)); return $rc unless ($Conf{'secondary_mode'} eq 'always' || ($Conf{'secondary_mode'} eq 'on_error' && $rc != 0));
swap_servers (); swap_servers ();
$rc = send_file ($file); $rc = send_file ($file, undef, undef, undef, $relative);
swap_servers (); swap_servers ();
return $rc; return $rc;
} }
@ -1075,12 +1083,16 @@ sub swap_servers () {
################################################################################ ################################################################################
# Receive a file from the server. # Receive a file from the server.
################################################################################ ################################################################################
sub recv_file ($) { sub recv_file {
my $file = shift; my ($file, $relative) = @_;
my $output; my $output;
my $pid = fork(); my $pid = fork();
return 1 unless defined $pid; return 1 unless defined $pid;
# Fix remote dir to some transfer mode
my $remote_dir = $Conf{'server_path'};
$remote_dir .= "/" . fix_directory($relative) if defined($relative);
if ($pid == 0) { if ($pid == 0) {
# execute the transfer program by child process. # execute the transfer program by child process.
@ -1104,7 +1116,7 @@ sub recv_file ($) {
quit quit
FEOF1` FEOF1`
} elsif ($Conf{'transfer_mode'} eq 'local') { } elsif ($Conf{'transfer_mode'} eq 'local') {
$output = `cp $Conf{'server_path'}/$file $Conf{'temporal'} 2>&1 >$DevNull`; $output = `cp "$remote_dir/$file" $Conf{'temporal'} 2>&1 >$DevNull`;
} }
alarm (0); alarm (0);
}; };
@ -1148,14 +1160,19 @@ sub check_remote_config () {
} }
# Get the remote MD5 file # Get the remote MD5 file
if (recv_file ($RemoteMD5File) != 0) { if (recv_file ($RemoteMD5File, $Conf{'server_path_md5'}) != 0) {
log_message ('remote config', 'Uploading configuration for the first time.');
open (MD5_FILE, "> $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!."); open (MD5_FILE, "> $Conf{'temporal'}/$RemoteMD5File") || error ("Could not open file '$ConfDir/$RemoteMD5File' for writing: $!.");
print MD5_FILE $conf_md5; print MD5_FILE $conf_md5;
close (MD5_FILE); close (MD5_FILE);
copy ("$ConfDir/$ConfFile", "$Conf{'temporal'}/$RemoteConfFile"); copy ("$ConfDir/$ConfFile", "$Conf{'temporal'}/$RemoteConfFile");
send_file ("$Conf{'temporal'}/$RemoteConfFile"); if ($Conf{'transfer_mode'} eq 'local') {
send_file ("$Conf{'temporal'}/$RemoteMD5File"); my (undef, undef, $uid, $gid) = getpwnam($Conf{'transfer_mode_user'});
log_message ('remote config', 'Uploading configuration for the first time.'); chown ($uid, $gid, "$Conf{'temporal'}/$RemoteMD5File");
chown ($uid, $gid, "$Conf{'temporal'}/$RemoteConfFile");
}
send_file ("$Conf{'temporal'}/$RemoteConfFile", undef, undef, undef, $Conf{'server_path_conf'});
send_file ("$Conf{'temporal'}/$RemoteMD5File", undef, undef, undef, $Conf{'server_path_md5'});
unlink ("$Conf{'temporal'}/$RemoteConfFile"); unlink ("$Conf{'temporal'}/$RemoteConfFile");
unlink ("$Conf{'temporal'}/$RemoteMD5File"); unlink ("$Conf{'temporal'}/$RemoteMD5File");
return; return;
@ -1169,7 +1186,7 @@ sub check_remote_config () {
return if ($remote_conf_md5 eq $conf_md5); return if ($remote_conf_md5 eq $conf_md5);
# Get the new configuration file # Get the new configuration file
return if (recv_file ($RemoteConfFile) != 0); return if (recv_file ($RemoteConfFile, $Conf{'server_path_conf'}) != 0);
log_message ('remote config', 'Configuration has changed!'); log_message ('remote config', 'Configuration has changed!');
# Save the new configuration # Save the new configuration
@ -1255,7 +1272,7 @@ sub check_collections () {
# Get remote md5 # Get remote md5
error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file")); error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file"));
next unless (recv_file ($collection_md5_file) == 0); next unless (recv_file ($collection_md5_file, $Conf{'server_path_md5'}) == 0);
open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!."); open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!.");
my $remote_collection_md5 = <MD5_FILE>; my $remote_collection_md5 = <MD5_FILE>;
close (MD5_FILE); close (MD5_FILE);
@ -1273,7 +1290,7 @@ sub check_collections () {
next if ($local_collection_md5 eq $remote_collection_md5); next if ($local_collection_md5 eq $remote_collection_md5);
# Download and unzip # Download and unzip
next unless (recv_file ($collection_file) == 0); next unless (recv_file ($collection_file, $Conf{'server_path_zip'}) == 0);
rmrf ("$ConfDir/collections/$collection"); rmrf ("$ConfDir/collections/$collection");
`unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`; `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`;
unlink ("$Conf{'temporal'}/$collection_file"); unlink ("$Conf{'temporal'}/$collection_file");

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.712" PI_VERSION="7.0NG.712"
PI_BUILD="170914" PI_BUILD="170925"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{170914} {170925}
ViewReadme ViewReadme
{Yes} {Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.712-170914 Version: 7.0NG.712-170925
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -793,7 +793,7 @@ if ($update_agent) { // if modified some agent paramenter
WHERE id_group = ".$group_old); WHERE id_group = ".$group_old);
$result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agente)); $result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agente));
if ($result === false) { if ($result == false) {
ui_print_error_message( ui_print_error_message(
__('There was a problem updating the agent')); __('There was a problem updating the agent'));
} }

View File

@ -35,6 +35,7 @@ if (is_ajax ()) {
$get_group_json = (bool) get_parameter ('get_group_json'); $get_group_json = (bool) get_parameter ('get_group_json');
$get_group_agents = (bool) get_parameter ('get_group_agents'); $get_group_agents = (bool) get_parameter ('get_group_agents');
$get_is_disabled = (bool) get_parameter ('get_is_disabled');
if ($get_group_json) { if ($get_group_json) {
$id_group = (int) get_parameter ('id_group'); $id_group = (int) get_parameter ('id_group');
@ -70,6 +71,7 @@ if (is_ajax ()) {
$search = (string) get_parameter ('search', ''); $search = (string) get_parameter ('search', '');
$recursion = (int) get_parameter ('recursion', 0); $recursion = (int) get_parameter ('recursion', 0);
$privilege = (string) get_parameter ('privilege', ''); $privilege = (string) get_parameter ('privilege', '');
$all_agents = (int) get_parameter ('all_agents', 0);
// Is is possible add keys prefix to avoid auto sorting in js object conversion // Is is possible add keys prefix to avoid auto sorting in js object conversion
$keys_prefix = (string) get_parameter ('keys_prefix', ''); $keys_prefix = (string) get_parameter ('keys_prefix', '');
// This attr is for the operation "bulk alert accions add", it controls the query that take the agents // This attr is for the operation "bulk alert accions add", it controls the query that take the agents
@ -96,7 +98,12 @@ if (is_ajax ()) {
$filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true); $filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true);
} }
$filter['disabled'] = $disabled; if ($all_agents) {
$filter['all_agents'] = true;
}
else {
$filter['disabled'] = $disabled;
}
if ($search != '') { if ($search != '') {
$filter['string'] = $search; $filter['string'] = $search;
@ -126,17 +133,42 @@ if (is_ajax ()) {
false, $recursion, false, '|', $add_alert_bulk_op); false, $recursion, false, '|', $add_alert_bulk_op);
} }
$agents_disabled = array();
// Add keys prefix // Add keys prefix
if ($keys_prefix !== "") { if ($keys_prefix !== "") {
foreach($agents as $k => $v) { foreach($agents as $k => $v) {
$agents[$keys_prefix . $k] = $v; $agents[$keys_prefix . $k] = $v;
unset($agents[$k]); unset($agents[$k]);
if ($all_agents) {
$agent_disabled = db_get_value_filter('disabled', 'tagente', array('id_agente' => $k));
$agents_disabled[$keys_prefix . $k] = $agent_disabled;
}
} }
} }
if ($all_agents) {
$all_agents_array = array();
$all_agents_array['agents'] = $agents;
$all_agents_array['agents_disabled'] = $agents_disabled;
$agents = $all_agents_array;
}
echo json_encode ($agents); echo json_encode ($agents);
return; return;
} }
if ($get_is_disabled) {
$index = get_parameter('id_agent');
$agent_disabled = db_get_value_filter('disabled', 'tagente', array('id_agente' => $index));
$return['disabled'] = $agent_disabled;
$return['id_agent'] = $index;
echo json_encode($return);
return;
}
return; return;
} }

View File

@ -212,7 +212,7 @@ You can of course remove the warnings, that's why we include the source and do n
*/ */
ui_print_page_header( ui_print_page_header(
__('Massive operations') . ' &raquo; '. $options[$option], __('Bulk operations') . ' &raquo; '. $options[$option],
"images/gm_massive_operations.png", false, "", true, $onheader,true, "massivemodal"); "images/gm_massive_operations.png", false, "", true, $onheader,true, "massivemodal");
// Checks if the PHP configuration is correctly // Checks if the PHP configuration is correctly

View File

@ -196,7 +196,7 @@ if (!empty($sub)) {
} }
if (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0, "PM")) { if (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, "RR")) {
// Servers // Servers
$menu_godmode["gservers"]["text"] = __('Servers'); $menu_godmode["gservers"]["text"] = __('Servers');
$menu_godmode["gservers"]["sec2"] = "godmode/servers/modificar_server"; $menu_godmode["gservers"]["sec2"] = "godmode/servers/modificar_server";

View File

@ -94,6 +94,7 @@ $inventory_modules = array();
$date = null; $date = null;
// Only avg is selected by default for the simple graphs // Only avg is selected by default for the simple graphs
$only_avg = true; $only_avg = true;
$fullscale = false;
$percentil = false; $percentil = false;
$time_compare_overlapped = false; $time_compare_overlapped = false;
@ -212,6 +213,7 @@ switch ($action) {
break; break;
case 'simple_graph': case 'simple_graph':
$only_avg = isset($style['only_avg']) ? (bool) $style['only_avg'] : true; $only_avg = isset($style['only_avg']) ? (bool) $style['only_avg'] : true;
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$percentil = isset($style['percentil']) ? $config['percentil'] : 0; $percentil = isset($style['percentil']) ? $config['percentil'] : 0;
// The break hasn't be forgotten. // The break hasn't be forgotten.
case 'simple_baseline_graph': case 'simple_baseline_graph':
@ -480,6 +482,7 @@ switch ($action) {
$description = $item['description']; $description = $item['description'];
$group = $item['id_group']; $group = $item['id_group'];
$period = $item['period']; $period = $item['period'];
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
break; break;
case 'top_n': case 'top_n':
$description = $item['description']; $description = $item['description'];
@ -1353,6 +1356,11 @@ You can of course remove the warnings, that's why we include the source and do n
<td style="font-weight:bold;"><?php echo __('Only average');?></td> <td style="font-weight:bold;"><?php echo __('Only average');?></td>
<td><?php html_print_checkbox('only_avg', 1, $only_avg);?></td> <td><?php html_print_checkbox('only_avg', 1, $only_avg);?></td>
</tr> </tr>
<tr id="row_fullscale" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Full resolution graph (TIP)').
ui_print_help_tip(__('This option may cause performance issues.'), true);?></td>
<td><?php html_print_checkbox('fullscale', 1, $fullscale);?></td>
</tr>
<tr id="row_percentil" style="" class="datos"> <tr id="row_percentil" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Percentil');?></td> <td style="font-weight:bold;"><?php echo __('Percentil');?></td>
<td><?php html_print_checkbox('percentil', 1, $percentil);?></td> <td><?php html_print_checkbox('percentil', 1, $percentil);?></td>
@ -2643,6 +2651,7 @@ function chooseType() {
$("#row_show_graph").hide(); $("#row_show_graph").hide();
$("#row_max_min_avg").hide(); $("#row_max_min_avg").hide();
$("#row_only_avg").hide(); $("#row_only_avg").hide();
$("#row_fullscale").hide();
$("#row_time_compare_overlapped").hide(); $("#row_time_compare_overlapped").hide();
$("#row_quantity").hide(); $("#row_quantity").hide();
$("#row_exception_condition_value").hide(); $("#row_exception_condition_value").hide();
@ -2725,6 +2734,7 @@ function chooseType() {
case 'simple_graph': case 'simple_graph':
$("#row_time_compare_overlapped").show(); $("#row_time_compare_overlapped").show();
$("#row_only_avg").show(); $("#row_only_avg").show();
$("#row_fullscale").show();
if ($("#checkbox-percentil").prop("checked")) if ($("#checkbox-percentil").prop("checked"))
$("#row_percentil").show(); $("#row_percentil").show();
// The break hasn't be forgotten, this element // The break hasn't be forgotten, this element
@ -3122,6 +3132,7 @@ function chooseType() {
$("#row_description").show(); $("#row_description").show();
$("#row_period").show(); $("#row_period").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
$("#row_fullscale").show();
break; break;
case 'top_n': case 'top_n':

View File

@ -1172,13 +1172,17 @@ switch ($action) {
case 'simple_graph': case 'simple_graph':
// Warning. We are using this column to hold this value to avoid // Warning. We are using this column to hold this value to avoid
// the modification of the database for compatibility reasons. // the modification of the database for compatibility reasons.
$style['only_avg'] = (int) get_parameter('only_avg'); $style['only_avg'] = (int) get_parameter('only_avg');
$style['percentil'] = (int) get_parameter('percentil'); $style['percentil'] = (int) get_parameter('percentil');
$style['fullscale'] = (int) get_parameter('fullscale');
if ($label != '') if ($label != '')
$style['label'] = $label; $style['label'] = $label;
else else
$style['label'] = ''; $style['label'] = '';
break; break;
case 'network_interfaces_report':
$style['fullscale'] = (int) get_parameter('fullscale');
break;
case 'module_histogram_graph': case 'module_histogram_graph':
case 'agent_configuration': case 'agent_configuration':
case 'alert_report_agent': case 'alert_report_agent':
@ -1516,13 +1520,17 @@ switch ($action) {
case 'simple_graph': case 'simple_graph':
// Warning. We are using this column to hold this value to avoid // Warning. We are using this column to hold this value to avoid
// the modification of the database for compatibility reasons. // the modification of the database for compatibility reasons.
$style['only_avg'] = (int) get_parameter('only_avg'); $style['only_avg'] = (int) get_parameter('only_avg');
$style['percentil'] = (int) get_parameter('percentil'); $style['percentil'] = (int) get_parameter('percentil');
$style['fullscale'] = (int) get_parameter('fullscale');
if ($label != '') if ($label != '')
$style['label'] = $label; $style['label'] = $label;
else else
$style['label'] = ''; $style['label'] = '';
break; break;
case 'network_interfaces_report':
$style['fullscale'] = (int) get_parameter('fullscale');
break;
case 'module_histogram_graph': case 'module_histogram_graph':
case 'agent_configuration': case 'agent_configuration':
case 'alert_report_agent': case 'alert_report_agent':

View File

@ -313,9 +313,9 @@ function update_button_palette_callback() {
if ((values['width'] == 0) || (values['height'] == 0)) { if ((values['width'] == 0) || (values['height'] == 0)) {
$("#image_" + idItem).removeAttr('width'); $("#image_" + idItem).removeAttr('width');
$("#image_" + idItem).removeAttr('height'); $("#image_" + idItem).removeAttr('height');
$("#image_" + idItem).attr('width', 450); $("#image_" + idItem).attr('width', 520);
$("#image_" + idItem).attr('height', 80); $("#image_" + idItem).attr('height', 80);
$("#image_" + idItem).css('width', '450px'); $("#image_" + idItem).css('width', '520px');
$("#image_" + idItem).css('height', '80px'); $("#image_" + idItem).css('height', '80px');
$("#image_" + idItem).attr('src', 'images/console/signes/group_status.png'); $("#image_" + idItem).attr('src', 'images/console/signes/group_status.png');
@ -1742,7 +1742,7 @@ function set_image(type, idElement, image) {
$(item).attr('src', data); $(item).attr('src', data);
if(image == 'show_statistics_bad.png' || image == 'show_statistics_ok.png' || image == 'show_statistics_warning.png' || image == 'show_statistics.png'){ if(image == 'show_statistics_bad.png' || image == 'show_statistics_ok.png' || image == 'show_statistics_warning.png' || image == 'show_statistics.png'){
$(item).attr('width', 450); $(item).attr('width', 520);
$(item).attr('height', 80); $(item).attr('height', 80);
} }

View File

@ -209,7 +209,7 @@ $table->data[34][0] = __('Allow create planned downtimes in the past') .
$table->data[34][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('past_planned_downtimes', 1, '', $config["past_planned_downtimes"], true).'&nbsp;&nbsp;'; $table->data[34][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('past_planned_downtimes', 1, '', $config["past_planned_downtimes"], true).'&nbsp;&nbsp;';
$table->data[34][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('past_planned_downtimes', 0, '', $config["past_planned_downtimes"], true); $table->data[34][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('past_planned_downtimes', 0, '', $config["past_planned_downtimes"], true);
$table->data[35][0] = __('Limit parameters massive') . $table->data[35][0] = __('Limit parameters bulk') .
ui_print_help_tip(__('Your PHP environment is setted with %d max_input_vars. Maybe you must not set this value with upper values.', ini_get("max_input_vars")), true); ui_print_help_tip(__('Your PHP environment is setted with %d max_input_vars. Maybe you must not set this value with upper values.', ini_get("max_input_vars")), true);
$table->data[35][1] = html_print_input_text('limit_parameters_massive', $table->data[35][1] = html_print_input_text('limit_parameters_massive',
$config['limit_parameters_massive'], '', 10, 10, true); $config['limit_parameters_massive'], '', 10, 10, true);

View File

@ -645,15 +645,27 @@ function ldap_process_user_login ($login, $password) {
} }
} }
$ldap_login_attr = isset($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) . "=" : ''; $ldap_login_attr = !empty($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) . "=" : '';
$ldap_base_dn = isset($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : '';
$ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : '';
if (strlen($password) == 0 ||
!@ldap_bind($ds, io_safe_output($login), $password) ) { if(!empty($ldap_base_dn)){
$config["auth_error"] = 'User not found in database or incorrect password'; if (strlen($password) == 0 ||
@ldap_close ($ds); !@ldap_bind($ds, $ldap_login_attr.io_safe_output($login).$ldap_base_dn, $password) ) {
$config["auth_error"] = 'User not found in database or incorrect password';
return false; @ldap_close ($ds);
return false;
}
} else {
if (strlen($password) == 0 ||
!@ldap_bind($ds, io_safe_output($login), $password) ) {
$config["auth_error"] = 'User not found in database or incorrect password';
@ldap_close ($ds);
return false;
}
} }
@ldap_close ($ds); @ldap_close ($ds);

View File

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

View File

@ -1806,7 +1806,20 @@ function check_acl($id_user, $id_group, $access, $onlyOneGroup = false) {
else { else {
$id_group = (int) $id_group; $id_group = (int) $id_group;
} }
$three_eyes_crow_groups = db_get_all_rows_sql("SELECT tperfil.*, tusuario_perfil.id_perfil FROM tperfil, tusuario_perfil WHERE tusuario_perfil.id_usuario = '" .
$id_user . "' AND tusuario_perfil.id_grupo = 0 AND tusuario_perfil.id_perfil = tperfil.id_perfil");
if ($three_eyes_crow_groups && !empty($three_eyes_crow_groups)) {
$acl_column = get_acl_column($access);
foreach ($three_eyes_crow_groups as $three_eyes_crow_group) {
if (isset($three_eyes_crow_group[$acl_column]) && $three_eyes_crow_group[$acl_column] == 1) {
return 1;
}
}
}
$parents_id = array($id_group); $parents_id = array($id_group);
if ($id_group != 0 && $onlyOneGroup !== true) { if ($id_group != 0 && $onlyOneGroup !== true) {
$group = db_get_row_filter('tgrupo', array('id_grupo' => $id_group)); $group = db_get_row_filter('tgrupo', array('id_grupo' => $id_group));

View File

@ -201,7 +201,7 @@ function config_update_config () {
if (!config_update_value ('past_planned_downtimes', get_parameter('past_planned_downtimes'))) if (!config_update_value ('past_planned_downtimes', get_parameter('past_planned_downtimes')))
$error_update[] = __('Allow create planned downtimes in the past'); $error_update[] = __('Allow create planned downtimes in the past');
if (!config_update_value ('limit_parameters_massive', get_parameter('limit_parameters_massive'))) if (!config_update_value ('limit_parameters_massive', get_parameter('limit_parameters_massive')))
$error_update[] = __('Limit parameters massive'); $error_update[] = __('Limit parameters bulk');
if (!config_update_value ('identification_reminder', get_parameter('identification_reminder'))) if (!config_update_value ('identification_reminder', get_parameter('identification_reminder')))
$error_update[] = __('Identification_reminder'); $error_update[] = __('Identification_reminder');
if (!config_update_value ('include_agents', (bool)get_parameter('include_agents'))) if (!config_update_value ('include_agents', (bool)get_parameter('include_agents')))

View File

@ -164,7 +164,7 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$background_color = 'white', $modules_param = array(), $homeurl = '', $background_color = 'white', $modules_param = array(), $homeurl = '',
$name_list = array(), $unit_list = array(), $show_last = true, $name_list = array(), $unit_list = array(), $show_last = true,
$show_max = true, $show_min = true, $show_avg = true, $ttl = 1, $show_max = true, $show_min = true, $show_avg = true, $ttl = 1,
$dashboard = false, $vconsole = false, $percentil = null, $from_interface = false,$id_widget_dashboard=false) { $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false,$id_widget_dashboard=false, $fullscale = false) {
global $config; global $config;
@ -261,7 +261,8 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$vconsole, $vconsole,
$percentil, $percentil,
$from_interface, $from_interface,
$id_widget_dashboard); $id_widget_dashboard,
$fullscale);
if ($return) if ($return)
return $output; return $output;

File diff suppressed because it is too large Load Diff

View File

@ -98,10 +98,13 @@ function reporting_get_name($id_report) {
function reporting_make_reporting_data($report = null, $id_report, function reporting_make_reporting_data($report = null, $id_report,
$date, $time, $period = null, $type = 'dinamic', $date, $time, $period = null, $type = 'dinamic',
$force_width_chart = null, $force_height_chart = null, $pdf= false) { $force_width_chart = null, $force_height_chart = null, $pdf= false,
$from_template = false) {
global $config; global $config;
enterprise_include_once('include/functions_metaconsole.php');
$return = array(); $return = array();
if (!empty($report)) { if (!empty($report)) {
@ -122,21 +125,69 @@ function reporting_make_reporting_data($report = null, $id_report,
if (empty($contents)) { if (empty($contents)) {
return reporting_check_structure_report($report); return reporting_check_structure_report($report);
} }
$metaconsole_on = is_metaconsole();
foreach ($contents as $content) { foreach ($contents as $content) {
$server_name = $content['server_name'];
if (!empty($period)) { if (!empty($period)) {
$content['period'] = $period; $content['period'] = $period;
} }
$content['style'] = json_decode(io_safe_output($content['style']), true); $content['style'] = json_decode(io_safe_output($content['style']), true);
$graphs_to_macro = db_get_all_rows_field_filter ("tgraph_source",
"id_graph", $content['id_gs']);
if ($graphs_to_macro === false)
$graphs_to_macro = array();
$modules_to_macro = 0;
$agents_to_macro = array();
foreach ($graphs_to_macro as $graph_item) {
$modules_to_macro++;
if (in_array('label', $content['style'])) {
if ($content['id_agent'] == 0) {
//Metaconsole connection
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
//ui_print_error_message ("Error connecting to ".$server_name);
continue;
}
}
array_push ($agents_to_macro, modules_get_agentmodule_agent($graph_item['id_agent_module']));
if ($metaconsole_on) {
//Restore db connection
metaconsole_restore_db();
}
}
}
}
$agents_to_macro_aux = array();
foreach ($agents_to_macro as $ag) {
if (!in_array($ag, $agents_to_macro_aux)) {
$agents_to_macro_aux[$ag] = $ag;
}
}
$agents_to_macro = $agents_to_macro_aux;
if (!empty($report) && $from_template) {
$agents_to_macro = $content['id_agent'];
}
if(isset($content['style']['name_label'])){ if(isset($content['style']['name_label'])){
//Add macros name //Add macros name
$items_label = array(); $items_label = array();
$items_label['type'] = $content['type']; $items_label['type'] = $content['type'];
$items_label['id_agent'] = $content['id_agent']; $items_label['id_agent'] = $content['id_agent'];
$items_label['id_agent_module'] = $content['id_agent_module']; $items_label['id_agent_module'] = $content['id_agent_module'];
$metaconsole_on = is_metaconsole(); $items_label['modules'] = $modules_to_macro;
$server_name = $content['server_name']; $items_label['agents'] = $agents_to_macro;
//Metaconsole connection //Metaconsole connection
if ($metaconsole_on && $server_name != '') { if ($metaconsole_on && $server_name != '') {
@ -147,7 +198,6 @@ function reporting_make_reporting_data($report = null, $id_report,
} }
} }
if(sizeof($content['id_agent']) != 1){ if(sizeof($content['id_agent']) != 1){
$content['style']['name_label'] = str_replace("_agent_",sizeof($content['id_agent']).__(' agents'),$content['style']['name_label']); $content['style']['name_label'] = str_replace("_agent_",sizeof($content['id_agent']).__(' agents'),$content['style']['name_label']);
} }
@ -2624,6 +2674,10 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
if (empty($content['name'])) { if (empty($content['name'])) {
$content['name'] = __('Network interfaces report'); $content['name'] = __('Network interfaces report');
} }
if (isset($content['style']['fullscale'])) {
$fullscale = (bool) $content['style']['fullscale'];
}
$group_name = groups_get_name($content['id_group']); $group_name = groups_get_name($content['id_group']);
@ -2695,7 +2749,13 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
true, true,
true, true,
true, true,
1); 1,
false,
false,
null,
false,
false,
$fullscale);
} }
break; break;
case 'data': case 'data':
@ -2718,7 +2778,13 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
true, true,
true, true,
true, true,
2); 2,
false,
false,
null,
false,
false,
$fullscale);
} }
break; break;
} }
@ -5800,12 +5866,6 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
require_once ($config["homedir"] . '/include/functions_graph.php'); require_once ($config["homedir"] . '/include/functions_graph.php');
if ($config['metaconsole'] && $type_report != 'automatic_graph') {
$id_meta = metaconsole_get_id_server($content["server_name"]);
$server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server);
}
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']); $graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
$return = array(); $return = array();
$return['type'] = 'custom_graph'; $return['type'] = 'custom_graph';
@ -5844,23 +5904,42 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
array_push ($modules, $graph_item['id_agent_module']); array_push ($modules, $graph_item['id_agent_module']);
} }
array_push ($weights, $graph_item["weight"]);
if (in_array('label',$content['style'])) { if (in_array('label',$content['style'])) {
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$server_name = $content['server_name'];
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
//ui_print_error_message ("Error connecting to ".$server_name);
continue;
}
$item = array('type' => 'custom_graph', $item = array('type' => 'custom_graph',
'id_agent' =>$content['id_agent'], 'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']),
'id_agent_module'=>$graph_item['id_agent_module']); 'id_agent_module'=>$graph_item['id_agent_module']);
} }
else { else {
$item = array('type' => 'custom_graph', $item = array('type' => 'custom_graph',
'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']), 'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']),
'id_agent_module'=>$graph_item['id_agent_module']); 'id_agent_module'=>$graph_item['id_agent_module']);
} }
$label = reporting_label_macro($item, $content['style']['label']);
$labels[$graph_item['id_agent_module']] = $label; $labels[$graph_item['id_agent_module']] = $label;
if (defined('METACONSOLE')) {
//Restore db connection
metaconsole_restore_db();
}
} }
array_push ($weights, $graph_item["weight"]);
} }
if ($config['metaconsole'] && $type_report != 'automatic_graph') {
$id_meta = metaconsole_get_id_server($content["server_name"]);
$server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server);
}
$return['chart'] = ''; $return['chart'] = '';
// Get chart // Get chart
reporting_set_conf_charts($width, $height, $only_image, $type, reporting_set_conf_charts($width, $height, $only_image, $type,
@ -5971,13 +6050,15 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
if (isset($content['style']['only_avg'])) { if (isset($content['style']['only_avg'])) {
$only_avg = (bool) $content['style']['only_avg']; $only_avg = (bool) $content['style']['only_avg'];
} }
if (isset($content['style']['fullscale'])) {
$fullscale = (bool) $content['style']['fullscale'];
}
$moduletype_name = modules_get_moduletype_name( $moduletype_name = modules_get_moduletype_name(
modules_get_agentmodule_type( modules_get_agentmodule_type(
$content['id_agent_module'])); $content['id_agent_module']));
$return['chart'] = ''; $return['chart'] = '';
// Get chart // Get chart
reporting_set_conf_charts($width, $height, $only_image, $type, reporting_set_conf_charts($width, $height, $only_image, $type,
@ -6051,7 +6132,8 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
($content['style']['percentil'] == 1) ? $config['percentil'] : null, ($content['style']['percentil'] == 1) ? $config['percentil'] : null,
false, false,
false, false,
$config['type_module_charts']); $config['type_module_charts'],
$fullscale);
} }
break; break;
case 'data': case 'data':
@ -10266,7 +10348,6 @@ function reporting_get_agentmodule_sla_working_timestamp ($period, $date_end, $w
} }
function reporting_label_macro ($item, $label) { function reporting_label_macro ($item, $label) {
switch ($item['type']) { switch ($item['type']) {
case 'event_report_agent': case 'event_report_agent':
case 'alert_report_agent': case 'alert_report_agent':
@ -10313,32 +10394,65 @@ function reporting_label_macro ($item, $label) {
case 'MTTR': case 'MTTR':
case 'automatic_graph': case 'automatic_graph':
if (preg_match("/_agent_/", $label)) { if (preg_match("/_agent_/", $label)) {
$agent_name = agents_get_alias($item['id_agent']); if (count($item['agents']) > 1) {
$agent_name = count($item['agents']) . __(' agents');
}
else {
$agent_name = agents_get_alias($item['id_agent']);
}
$label = str_replace("_agent_", $agent_name, $label); $label = str_replace("_agent_", $agent_name, $label);
} }
if (preg_match("/_agentdescription_/", $label)) { if (preg_match("/_agentdescription_/", $label)) {
$agent_name = agents_get_description($item['id_agent']); if (count($item['agents']) > 1) {
$agent_name = "";
}
else {
$agent_name = agents_get_description($item['id_agent']);
}
$label = str_replace("_agentdescription_", $agent_name, $label); $label = str_replace("_agentdescription_", $agent_name, $label);
} }
if (preg_match("/_agentgroup_/", $label)) { if (preg_match("/_agentgroup_/", $label)) {
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']),true); if (count($item['agents']) > 1) {
$agent_name = "";
}
else {
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']),true);
}
$label = str_replace("_agentgroup_", $agent_name, $label); $label = str_replace("_agentgroup_", $agent_name, $label);
} }
if (preg_match("/_address_/", $label)) { if (preg_match("/_address_/", $label)) {
$agent_name = agents_get_address($item['id_agent']); if (count($item['agents']) > 1) {
$agent_name = "";
}
else {
$agent_name = agents_get_address($item['id_agent']);
}
$label = str_replace("_address_", $agent_name, $label); $label = str_replace("_address_", $agent_name, $label);
} }
if (preg_match("/_module_/", $label)) { if (preg_match("/_module_/", $label)) {
$module_name = modules_get_agentmodule_name($item['id_agent_module']); if ($item['modules'] > 1) {
$module_name = $item['modules'] . __(' modules');
}
else {
$module_name = modules_get_agentmodule_name($item['id_agent_module']);
}
$label = str_replace("_module_", $module_name, $label); $label = str_replace("_module_", $module_name, $label);
} }
if (preg_match("/_moduledescription_/", $label)) { if (preg_match("/_moduledescription_/", $label)) {
$module_description = modules_get_agentmodule_descripcion($item['id_agent_module']); if ($item['modules'] > 1) {
$module_description = "";
}
else {
$module_description = modules_get_agentmodule_descripcion($item['id_agent_module']);
}
$label = str_replace("_moduledescription_", $module_description, $label); $label = str_replace("_moduledescription_", $module_description, $label);
} }
break; break;

View File

@ -3886,15 +3886,16 @@ function reporting_get_event_histogram_meta ($width) {
$user_groups_ids = array_keys($user_groups); $user_groups_ids = array_keys($user_groups);
if (empty($user_groups)) { if (empty($user_groups)) {
$groups_condition = ' 1 = 0 '; $groups_condition = ' AND 1 = 0 ';
} }
else { else {
$groups_condition = ' id_grupo IN (' . implode(',', $user_groups_ids) . ') '; $groups_condition = ' AND id_grupo IN (' . implode(',', $user_groups_ids) . ') ';
} }
if (!check_acl ($config['id_user'], 0, "PM")) { if (!check_acl ($config['id_user'], 0, "PM")) {
$groups_condition .= " AND id_grupo != 0"; $groups_condition .= " AND id_grupo != 0";
} }
$status_condition = " AND estado = 0 ";
$cont = 0; $cont = 0;
for ($i = 0; $i < $interval; $i++) { for ($i = 0; $i < $interval; $i++) {
@ -3923,49 +3924,45 @@ function reporting_get_event_histogram_meta ($width) {
$full_legend[$cont] = $name; $full_legend[$cont] = $name;
$top = $datelimit + ($periodtime * ($i + 1)); $top = $datelimit + ($periodtime * ($i + 1));
$event = db_get_row_filter ('tmetaconsole_event',
array (
'utimestamp > '.$bottom,
'utimestamp < '.$top,
$groups_condition),
'criticity, utimestamp');
if (!empty($event['utimestamp'])) { $time_condition = 'utimestamp > '.$bottom . ' AND utimestamp < '.$top;
$data[$cont]['utimestamp'] = $periodtime; $sql = sprintf('SELECT criticity,utimestamp
switch ($event['criticity']) { FROM tmetaconsole_event
case 0: WHERE %s %s %s
$data[$cont]['data'] = EVENT_CRIT_MAINTENANCE; ORDER BY criticity DESC',
break; $time_condition, $groups_condition, $status_condition);
case 1:
$data[$cont]['data'] = EVENT_CRIT_INFORMATIONAL; $events = db_get_all_rows_sql($sql);
break;
case 2: $events_criticity = array();
$data[$cont]['data'] = EVENT_CRIT_NORMAL; foreach ($events as $key => $value) {
break; array_push($events_criticity,$value['criticity']);
case 3:
$data[$cont]['data'] = EVENT_CRIT_WARNING;
break;
case 4:
$data[$cont]['data'] = EVENT_CRIT_CRITICAL;
break;
case 5:
$data[$cont]['data'] = EVENT_CRIT_MINOR;
break;
case 6:
$data[$cont]['data'] = EVENT_CRIT_MAJOR;
break;
case 20:
$data[$cont]['data'] = EVENT_CRIT_NOT_NORMAL;
break;
case 34:
$data[$cont]['data'] = EVENT_CRIT_WARNING_OR_CRITICAL;
break;
default:
$data[$cont]['data'] = 1;
break;
}
} }
else {
if (!empty($events)) {
if(array_search('4',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_CRITICAL;
}else if (array_search('3',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_WARNING;
}else if(array_search('6',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_MAJOR;
}else if(array_search('5',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_MINOR;
}else if(array_search('20',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_NOT_NORMAL;
}else if(array_search('34',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_WARNING_OR_CRITICAL;
}else if(array_search('2',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_NORMAL;
}else if(array_search('0',$events_criticity) !== false){
$data[$cont]['data'] = EVENT_CRIT_MAINTENANCE;
}else {
$data[$cont]['data'] = EVENT_CRIT_INFORMATIONAL;
}
$data[$cont]['utimestamp'] = $periodtime;
} else {
$data[$cont]['utimestamp'] = $periodtime; $data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1; $data[$cont]['data'] = 1;
} }

View File

@ -1277,7 +1277,7 @@ function visual_map_print_item($mode = "read", $layoutData,
if ($width == 0 || $height == 0) { if ($width == 0 || $height == 0) {
echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:450px;height:80px;'.$imgpos.'">'; echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:520px;height:80px;'.$imgpos.'">';
} }
else{ else{
echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">'; echo '<img id="image_'.$id.'" src="images/console/signes/group_status.png" style="width:'.$width.'px;height:'.$height.'px;'.$imgpos.'">';
@ -1318,7 +1318,7 @@ function visual_map_print_item($mode = "read", $layoutData,
$stat_agent_un = $agents_unknown[0]['total']/$total_agents*100; $stat_agent_un = $agents_unknown[0]['total']/$total_agents*100;
if($width == 0 || $height == 0){ if($width == 0 || $height == 0){
$dyn_width = 450; $dyn_width = 520;
$dyn_height = 80; $dyn_height = 80;
} }
else{ else{
@ -1344,14 +1344,14 @@ function visual_map_print_item($mode = "read", $layoutData,
echo "</tr>"; echo "</tr>";
echo "<tr style='background-color:whitesmoke;height:90%;'>"; echo "<tr style='background-color:whitesmoke;height:90%;'>";
echo "<td>"; echo "<td>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 15px;display:inline;background-color:#FC4444;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_cr, 2)) ."%</div>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#FC4444;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_cr, 2)) ."%</div>";
echo "<div style='background-color:white;color: black ;font-size: 15px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Critical</div>"; echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Critical</div>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 15px;display:inline;background-color:#f8db3f;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_wa, 2)) ."%</div>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#f8db3f;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_wa, 2)) ."%</div>";
echo "<div style='background-color:white;color: black ;font-size: 15px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Warning</div>"; echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Warning</div>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 15px;display:inline;background-color:#84b83c;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_ok, 2)) ."%</div>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#84b83c;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_ok, 2)) ."%</div>";
echo "<div style='background-color:white;color: black ;font-size: 15px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Normal</div>"; echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Normal</div>";
echo "<div style='margin-left:2%;color: #FFF;font-size: 15px;display:inline;background-color:#9d9ea0;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_un, 2)) ."%</div>"; echo "<div style='margin-left:2%;color: #FFF;font-size: 12px;display:inline;background-color:#9d9ea0;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>". remove_right_zeros(number_format($stat_agent_un, 2)) ."%</div>";
echo "<div style='background-color:white;color: black ;font-size: 15px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Unknown</div>"; echo "<div style='background-color:white;color: black ;font-size: 12px;display:inline;position:relative;height:80%;width:9.4%;height:80%;border-radius:2px;text-align:center;padding:5px;'>Unknown</div>";
echo "</td>"; echo "</td>";
echo "</tr>"; echo "</tr>";

View File

@ -51,7 +51,7 @@
<tr><td>Group Management<td>PM <tr><td>Group Management<td>PM
<tr><td>Creating inventory modules<td>PM <tr><td>Creating inventory modules<td>PM
<tr><td>Module Management (includes all suboptions)<td>PM <tr><td>Module Management (includes all suboptions)<td>PM
<tr><td>Massive Management Operations <td>AW <tr><td>Bulk Management Operations <td>AW
<tr><td>Creating agents<td>AW <tr><td>Creating agents<td>AW
<tr><td>Duplicating remote configurations<td>AW <tr><td>Duplicating remote configurations<td>AW
<tr><td>Downtime Management<td>AW <tr><td>Downtime Management<td>AW

View File

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

View File

@ -74,17 +74,35 @@ $table_agent->data = array();
$data = array(); $data = array();
$agent_name = ui_print_agent_name($agent["id_agente"], true, 500, "font-size: medium;font-weight:bold", true); $agent_name = ui_print_agent_name($agent["id_agente"], true, 500, "font-size: medium;font-weight:bold", true);
$in_planned_downtime = db_get_value_filter('id', 'tplanned_downtime_agents', array('id_agent' => $agent["id_agente"]));
if ($agent['disabled']) { if ($agent['disabled']) {
$agent_name = "<em>" . $agent_name . "</em>" . ui_print_help_tip(__('Disabled'), true); if ($in_planned_downtime) {
$agent_name = "<em>" . $agent_name . ui_print_help_tip(__('Disabled'), true);
}
else {
$agent_name = "<em>" . $agent_name . "</em>" . ui_print_help_tip(__('Disabled'), true);
}
} }
else if ($agent['quiet']) { else if ($agent['quiet']) {
$agent_name = "<em'>" . $agent_name . "&nbsp;" . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . "</em>"; if ($in_planned_downtime) {
$agent_name = "<em'>" . $agent_name . "&nbsp;" . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
}
else {
$agent_name = "<em'>" . $agent_name . "&nbsp;" . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . "</em>";
}
} }
else { else {
$agent_name = $agent_name; $agent_name = $agent_name;
} }
if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) {
$agent_name .= "<em>" . "&nbsp;" . ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png') . "</em>";
}
else if (($in_planned_downtime && !$agent['disabled']) || ($in_planned_downtime && !$agent['quiet'])) {
$agent_name .= "&nbsp;" . ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png') . "</em>";
}
if (!$config["show_group_name"]) if (!$config["show_group_name"])
$data[0] = ui_print_group_icon ($agent["id_grupo"], true); $data[0] = ui_print_group_icon ($agent["id_grupo"], true);
else else

View File

@ -150,6 +150,7 @@ $interface_traffic_modules = array(
$zoom = (int) get_parameter ("zoom", 1); $zoom = (int) get_parameter ("zoom", 1);
$baseline = get_parameter ("baseline", 0); $baseline = get_parameter ("baseline", 0);
$show_percentil = get_parameter ("show_percentil", 0); $show_percentil = get_parameter ("show_percentil", 0);
$fullscale = get_parameter("fullscale", 0);
if ($zoom > 1) { if ($zoom > 1) {
$height = $height * ($zoom / 2.1); $height = $height * ($zoom / 2.1);
@ -200,7 +201,9 @@ $interface_traffic_modules = array(
false, false,
false, false,
(($show_percentil)? $config['percentil'] : null), (($show_percentil)? $config['percentil'] : null),
true); true,
false,
$fullscale);
echo '</div>'; echo '</div>';
@ -258,6 +261,12 @@ $interface_traffic_modules = array(
$data[1] = html_print_checkbox ("show_percentil", 1, (bool) $show_percentil, true); $data[1] = html_print_checkbox ("show_percentil", 1, (bool) $show_percentil, true);
$table->data[] = $data; $table->data[] = $data;
$table->rowclass[] =''; $table->rowclass[] ='';
$data = array();
$data[0] = __('Show full scale graph (TIP)');
$data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, true);
$table->data[] = $data;
$table->rowclass[] ='';
$data = array(); $data = array();
$data[0] = __('Zoom factor'); $data[0] = __('Zoom factor');

View File

@ -282,7 +282,12 @@ $ignored_params['refr'] = '';
$('.item:not(.icon) img:not(.b64img)').each( function() { $('.item:not(.icon) img:not(.b64img)').each( function() {
if ($(this).css('float')=='left' || $(this).css('float')=='right') { if ($(this).css('float')=='left' || $(this).css('float')=='right') {
$(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); if( $(this).parent()[0].tagName == 'DIV'){
$(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px');
}
else if ( $(this).parent()[0].tagName == 'A') {
$(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px');
}
$(this).css('margin-left',''); $(this).css('margin-left','');
} }
else { else {
@ -290,7 +295,12 @@ $ignored_params['refr'] = '';
$(this).css('margin-left',''); $(this).css('margin-left','');
$(this).css('margin-top',''); $(this).css('margin-top','');
} else { } else {
$(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); if( $(this).parent()[0].tagName == 'DIV'){
$(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
}
else if ( $(this).parent()[0].tagName == 'A') {
$(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
}
$(this).css('margin-top',''); $(this).css('margin-top','');
} }
} }

View File

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

View File

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

View File

@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
`custom_id` varchar(255) default '', `custom_id` varchar(255) default '',
`server_name` varchar(100) default '', `server_name` varchar(100) default '',
`cascade_protection` tinyint(2) NOT NULL default '0', `cascade_protection` tinyint(2) NOT NULL default '0',
`cascade_protection_module` tinyint(2) NOT NULL default '0', `cascade_protection_module` int(10) unsigned NOT NULL default '0',
`timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'nuber of hours of diference with the server timezone' , `timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'nuber of hours of diference with the server timezone' ,
`icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' ,
`update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' , `update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' ,

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.712-170914 Version: 7.0NG.712-170925
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -607,7 +607,10 @@ sub main() {
$server->update(); $server->update();
} }
db_do ($DBH, "UPDATE tserver SET status = 0 WHERE now()-keepalive > 2*server_keepalive"); db_do ($DBH,
"UPDATE tserver SET status = 0
WHERE UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(keepalive) > 2*server_keepalive"
);
# Set the master server # Set the master server
pandora_set_master(\%Config, $DBH); pandora_set_master(\%Config, $DBH);

View File

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

View File

@ -211,6 +211,11 @@ sub pandora_snmptrapd {
# Try to save as much information as possible if the trap could not be parsed # Try to save as much information as possible if the trap could not be parsed
$oid = $type_desc if ($oid eq '' || $oid eq '.'); $oid = $type_desc if ($oid eq '' || $oid eq '.');
if (!defined($oid)) {
logger($pa_config, "[W] snmpTrapOID not found (Illegal SNMPv1 trap?)", 5);
return;
}
} elsif ($trap_ver eq "SNMPv2") { } elsif ($trap_ver eq "SNMPv2") {
($date, $time, $source, $data) = split(/\[\*\*\]/, $line, 4); ($date, $time, $source, $data) = split(/\[\*\*\]/, $line, 4);
my @data = split(/\t/, $data); my @data = split(/\t/, $data);
@ -219,7 +224,7 @@ sub pandora_snmptrapd {
$oid = shift @data; $oid = shift @data;
if (!defined($oid)) { if (!defined($oid)) {
logger($pa_config, "[W] snmpTrapOID not found (Illegal SNMPv2 trap?)", 1); logger($pa_config, "[W] snmpTrapOID not found (Illegal SNMPv2 trap?)", 5);
return; return;
} }
$oid =~ s/.* = OID: //; $oid =~ s/.* = OID: //;
@ -441,21 +446,32 @@ sub read_snmplogfile()
return undef if (! defined($line)); return undef if (! defined($line));
my $retry_count = 0;
# More lines ? # More lines ?
while($read_ahead_line = <SNMPLOGFILE>) { while(1) {
while($read_ahead_line = <SNMPLOGFILE>) {
# Get current file position # Get current file position
$read_ahead_pos = tell(SNMPLOGFILE); $read_ahead_pos = tell(SNMPLOGFILE);
# Get out of the loop if you find another Trap # Get out of the loop if you find another Trap
last if($read_ahead_line =~ /^SNMP/ ); last if($read_ahead_line =~ /^SNMP/ );
# $read_ahead_line looks continued line... # $read_ahead_line looks continued line...
# Append to the line and correct the position # Append to the line and correct the position
chomp($line); chomp($line);
$line .= "$read_ahead_line"; $line .= "$read_ahead_line";
$pos = $read_ahead_pos; $pos = $read_ahead_pos;
}
# if $line looks incomplete, try to get continued line
# just within 10sec. After that, giving up to complete it
# and flush $line as it is.
last if(chomp($line) > 0 || $retry_count++ >= 10);
sleep(1);
} }
# return fetched line with file position to be saved. # return fetched line with file position to be saved.

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.712 PS170914"; my $version = "7.0NG.712 PS170925";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;
@ -93,7 +93,7 @@ sub pandora_purgedb ($$) {
} }
# Delete old inventory data # Delete old inventory data
if (defined($conf->{'_inventory_purge'}) && $conf->{'_inventory_purge'} > 0) { if (defined ($conf->{'_inventory_purge'}) && $conf->{'_inventory_purge'} > 0) {
if (enterprise_load (\%conf) != 0) { if (enterprise_load (\%conf) != 0) {
my $ulimit_timestamp_inventory = time() - (86400 * $conf->{'_inventory_purge'}); my $ulimit_timestamp_inventory = time() - (86400 * $conf->{'_inventory_purge'});
@ -612,6 +612,7 @@ sub pandora_load_config ($) {
$conf->{'dbengine'} = 'mysql' unless defined ($conf->{'dbengine'}); $conf->{'dbengine'} = 'mysql' unless defined ($conf->{'dbengine'});
$conf->{'dbport'} = '3306' unless defined ($conf->{'dbport'}); $conf->{'dbport'} = '3306' unless defined ($conf->{'dbport'});
$conf->{'claim_back_snmp_modules'} = '1' unless defined ($conf->{'claim_back_snmp_modules'}); $conf->{'claim_back_snmp_modules'} = '1' unless defined ($conf->{'claim_back_snmp_modules'});
$conf->{'verbosity'} = '3' unless defined ($conf->{'verbosity'});
# Dynamic interval configuration. # Dynamic interval configuration.
$conf->{"dynamic_constant"} = 0.10 unless defined($conf->{"dynamic_constant"}); $conf->{"dynamic_constant"} = 0.10 unless defined($conf->{"dynamic_constant"});
@ -787,10 +788,10 @@ sub pandora_checkdb_consistency {
log_message ('CHECKDB', "Ignoring not-init data."); log_message ('CHECKDB', "Ignoring not-init data.");
} }
log_message ('CHECKDB',
"Deleting unknown data (More than " . $conf{'_days_delete_unknown'} . " days).");
if (defined($conf{'_days_delete_unknown'}) && $conf{'_days_delete_unknown'} > 0) { if (defined($conf{'_days_delete_unknown'}) && $conf{'_days_delete_unknown'} > 0) {
log_message ('CHECKDB',
"Deleting unknown data (More than " . $conf{'_days_delete_unknown'} . " days).");
my @modules = get_db_rows($dbh, my @modules = get_db_rows($dbh,
'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.id_agente 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.id_agente
FROM tagente_modulo, tagente_estado FROM tagente_modulo, tagente_estado
@ -1060,4 +1061,4 @@ if ($lock == 1) {
db_release_lock ($dbh, 'pandora_db'); db_release_lock ($dbh, 'pandora_db');
} }
exit 0; exit 0;

View File

@ -21,6 +21,7 @@ use JSON qw(decode_json encode_json);
use MIME::Base64; use MIME::Base64;
use Encode qw(decode encode_utf8); use Encode qw(decode encode_utf8);
use LWP::Simple; use LWP::Simple;
use Data::Dumper;
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; use lib '/usr/lib/perl5';
@ -35,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.712 PS170914"; my $version = "7.0NG.712 PS170925";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -213,6 +214,15 @@ sub help_screen{
help_screen_line('--create_tag', '<tag_name> <tag_description> [<tag_url>] [<tag_email>]', 'Create a new tag'); help_screen_line('--create_tag', '<tag_name> <tag_description> [<tag_url>] [<tag_email>]', 'Create a new tag');
help_screen_line('--add_tag_to_user_profile', '<user_id> <tag_name> <group_name> <profile_name>', 'Add a tag to the given user profile'); help_screen_line('--add_tag_to_user_profile', '<user_id> <tag_name> <group_name> <profile_name>', 'Add a tag to the given user profile');
help_screen_line('--add_tag_to_module', '<agent_name> <module_name> <tag_name>', 'Add a tag to the given module'); help_screen_line('--add_tag_to_module', '<agent_name> <module_name> <tag_name>', 'Add a tag to the given module');
print "\nVISUAL CONSOLES\n\n" unless $param ne '';
help_screen_line('--create_visual_console', '<name> <background> <width> <height> <group> <mode> [<position_to_locate_elements>] [<background_color>] [<elements>]', 'Create a new visual console');
help_screen_line('--edit_visual_console', '<id> [<name>] [<background>] [<width>] [<height>] [<group>] [<mode>] [<position_to_locate_elements>] [<background_color>] [<elements>]', 'Edit a visual console');
help_screen_line('--delete_visual_console', '<id>', 'Delete a visual console');
help_screen_line('--delete_visual_console_objects', '<id> <mode> <id_mode>', 'Delete a visual console elements');
help_screen_line('--duplicate_visual_console', '<id> <times> [<prefix>]', 'Duplicate a visual console');
help_screen_line('--export_json_visual_console', '<id> [<path>]', 'Creates a json with the visual console elements information');
print "\n"; print "\n";
exit; exit;
@ -4753,6 +4763,802 @@ sub cli_delete_special_day() {
exist_check($result,'special day',$special_day); exist_check($result,'special day',$special_day);
} }
##############################################################################
# Creates a new visual console.
# Related option: --create_visual_console
##############################################################################
sub cli_create_visual_console() {
my ($name,$background,$width,$height,$group,$mode,$element_square_positions,$background_color,$elements) = @ARGV[2..10];
if($name eq '') {
print_log "[ERROR] Name field cannot be empty.\n\n";
exit 1;
}
elsif ($background eq '') {
print_log "[ERROR] Background field cannot be empty.\n\n";
exit 1;
}
elsif (($width eq '') || ($height eq '')) {
print_log "[ERROR] Please specify size.\n\n";
exit 1;
}
elsif ($group eq '') {
print_log "[ERROR] Group field cannot be empty.\n\n";
exit 1;
}
elsif ($mode eq '') {
print_log "[ERROR] Mode parameter must be 'static_objects' or 'auto_creation'.\n\n";
exit 1;
}
if ($background_color eq '') {
$background_color = '#FFF';
}
print_log "[INFO] Creating visual console '$name' \n\n";
my $vc_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout (name, id_group, background, width, height, background_color)
VALUES (?, ?, ?, ?, ?, ?)', safe_input($name), $group, $background, $width, $height, $background_color);
print_log "[INFO] The visual console id is '$vc_id' \n\n";
if ($elements ne '') {
my $elements_in_array = decode_json($elements);
if ($mode eq 'static_objects') {
my $elem_count = 1;
foreach my $elem (@$elements_in_array) {
my $pos_x = $elem->{'pos_x'};
my $pos_y = $elem->{'pos_y'};
my $width = $elem->{'width'};
my $height = $elem->{'height'};
my $label = $elem->{'label'};
my $image = $elem->{'image'};
my $type = $elem->{'type'};
my $period = $elem->{'period'};
my $id_agente_modulo = $elem->{'id_agente_modulo'};
my $id_agent = $elem->{'id_agent'};
my $id_layout_linked = $elem->{'id_layout_linked'};
my $parent_item = $elem->{'parent_item'};
my $enable_link = $elem->{'enable_link'};
my $id_metaconsole = $elem->{'id_metaconsole'};
my $id_group = $elem->{'id_group'};
my $id_custom_graph = $elem->{'id_custom_graph'};
my $border_width = $elem->{'border_width'};
my $type_graph = $elem->{'type_graph'};
my $label_position = $elem->{'label_position'};
my $border_color = $elem->{'border_color'};
my $fill_color = $elem->{'fill_color'};
my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0);
print_log "[INFO] The element id in position $elem_count is '$elem_id' \n\n";
$elem_count++;
}
}
elsif ($mode eq 'auto_creation') {
if ($element_square_positions eq '') {
print_log "[ERROR] With this mode, square positions is obligatory'.\n\n";
exit 1;
}
else {
my $positions = decode_json($element_square_positions);
my $pos1X = $positions->{'pos1x'};
my $pos1Y = $positions->{'pos1y'};
my $pos2X = $positions->{'pos2x'};
my $pos2Y = $positions->{'pos2y'};
my $number_of_elements = scalar(@$elements_in_array);
my $x_divider = 4;
my $y_divider = 1;
for (my $i = 1; $i <= 1000; $i++) {
if (($i * 4) < $number_of_elements) {
$y_divider++;
}
else {
last;
}
}
my $elem_width = ($pos2X - $pos1X) / $x_divider;
my $elem_height = ($pos2Y - $pos1Y) / $y_divider;
if ($number_of_elements < 4) {
$elem_height = ($pos2Y - $pos1Y) / 3;
}
my $elem_count = 1;
my $pos_helper_x = 0;
my $pos_helper_y = 0;
foreach my $elem (@$elements_in_array) {
my $pos_x = $pos_helper_x * $elem_width;
my $pos_y = $pos_helper_y * $elem_height;
my $width = $elem_width;
my $height = $elem_height;
my $label = $elem->{'label'};
my $image = $elem->{'image'};
my $type = $elem->{'type'};
my $period = $elem->{'period'};
my $id_agente_modulo = $elem->{'id_agente_modulo'};
my $id_agent = $elem->{'id_agent'};
my $id_layout_linked = $elem->{'id_layout_linked'};
my $parent_item = $elem->{'parent_item'};
my $enable_link = $elem->{'enable_link'};
my $id_metaconsole = $elem->{'id_metaconsole'};
my $id_group = $elem->{'id_group'};
my $id_custom_graph = $elem->{'id_custom_graph'};
my $border_width = $elem->{'border_width'};
my $type_graph = $elem->{'type_graph'};
my $label_position = $elem->{'label_position'};
my $border_color = $elem->{'border_color'};
my $fill_color = $elem->{'fill_color'};
my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0);
print_log "[INFO] The element id in position $elem_count is '$elem_id' \n\n";
$elem_count++;
if ($pos_helper_x == 3) {
$pos_helper_x = 0;
$pos_helper_y++;
}
else {
$pos_helper_x++;
}
}
}
}
else {
print_log "[ERROR] Mode parameter must be 'static_objects' or 'auto_creation'.\n\n";
exit 1;
}
}
}
##############################################################################
# Edit a visual console.
# Related option: --edit_visual_console
##############################################################################
sub cli_edit_visual_console() {
my ($id,$name,$background,$width,$height,$group,$mode,$element_square_positions,$background_color,$elements) = @ARGV[2..11];
if($id eq '') {
print_log "[ERROR] ID field cannot be empty.\n\n";
exit 1;
}
my $console = get_db_single_row ($dbh, "SELECT *
FROM tlayout
WHERE id = $id");
my $new_name = $console->{'name'};
my $new_background = $console->{'background'};
my $new_console_width = $console->{'width'};
my $new_console_height = $console->{'height'};
my $new_console_id_group = $console->{'id_group'};
my $new_background_color = $console->{'background_color'};
if($name ne '') {
$new_name = $name;
}
if ($background ne '') {
$new_background = $background;
}
if ($width ne '') {
$new_console_width = $width;
}
if ($height ne '') {
$new_console_height = $height;
}
if ($group ne '') {
$new_console_id_group = $group;
}
if ($background_color ne '') {
$new_background_color = $background_color;
}
print_log "[INFO] The visual console with id $id is updated \n\n";
db_update ($dbh, "UPDATE tlayout SET name = '" . $new_name . "', background = '" . $new_background . "', width = " . $new_console_width . ", height = " . $new_console_height . ", id_group = " . $new_console_id_group . ", background_color = '" . $new_background_color . "' WHERE id = " . $id);
if ($elements ne '') {
my $elements_in_array = decode_json($elements);
if ($mode eq 'static_objects') {
foreach my $elem (@$elements_in_array) {
if (defined($elem->{'id'})) {
print_log "[INFO] Edit element with id " . $elem->{'id'} . " \n\n";
my $element_in_db = get_db_single_row ($dbh, "SELECT *
FROM tlayout_data
WHERE id = " . $elem->{'id'});
my $new_pos_x = $element_in_db->{'pos_x'};
my $new_pos_y = $element_in_db->{'pos_y'};
my $new_width = $element_in_db->{'width'};
my $new_height = $element_in_db->{'height'};
my $new_label = $element_in_db->{'label'};
my $new_image = $element_in_db->{'image'};
my $new_type = $element_in_db->{'type'};
my $new_period = $element_in_db->{'period'};
my $new_id_agente_modulo = $element_in_db->{'id_agente_modulo'};
my $new_id_agent = $element_in_db->{'id_agent'};
my $new_id_layout_linked = $element_in_db->{'id_layout_linked'};
my $new_parent_item = $element_in_db->{'parent_item'};
my $new_enable_link = $element_in_db->{'enable_link'};
my $new_id_metaconsole = $element_in_db->{'id_metaconsole'};
my $new_id_group = $element_in_db->{'id_group'};
my $new_id_custom_graph = $element_in_db->{'id_custom_graph'};
my $new_border_width = $element_in_db->{'border_width'};
my $new_type_graph = $element_in_db->{'type_graph'};
my $new_label_position = $element_in_db->{'label_position'};
my $new_border_color = $element_in_db->{'border_color'};
my $new_fill_color = $element_in_db->{'fill_color'};
if(defined($elem->{'pos_x'})) {
$new_pos_x = $elem->{'pos_x'};
}
if(defined($elem->{'pos_y'})) {
$new_pos_y = $elem->{'pos_y'};
}
if(defined($elem->{'width'})) {
$new_width = $elem->{'width'};
}
if(defined($elem->{'height'})) {
$new_height = $elem->{'height'};
}
if(defined($elem->{'label'})) {
$new_label = $elem->{'label'};
}
if(defined($elem->{'image'})) {
$new_image = $elem->{'image'};
}
if(defined($elem->{'type'})) {
$new_type = $elem->{'type'};
}
if(defined($elem->{'period'})) {
$new_period = $elem->{'period'};
}
if(defined($elem->{'id_agente_modulo'})) {
$new_id_agente_modulo = $elem->{'id_agente_modulo'};
}
if(defined($elem->{'id_agent'})) {
$new_id_agent = $elem->{'id_agent'};
}
if(defined($elem->{'id_layout_linked'})) {
$new_id_layout_linked = $elem->{'id_layout_linked'};
}
if(defined($elem->{'parent_item'})) {
$new_parent_item = $elem->{'parent_item'};
}
if(defined($elem->{'enable_link'})) {
$new_enable_link = $elem->{'enable_link'};
}
if(defined($elem->{'id_metaconsole'})) {
$new_id_metaconsole = $elem->{'id_metaconsole'};
}
if(defined($elem->{'id_group'})) {
$new_id_group = $elem->{'id_group'};
}
if(defined($elem->{'id_custom_graph'})) {
$new_id_custom_graph = $elem->{'id_custom_graph'};
}
if(defined($elem->{'border_width'})) {
$new_border_width = $elem->{'border_width'};
}
if(defined($elem->{'type_graph'})) {
$new_type_graph = $elem->{'type_graph'};
}
if(defined($elem->{'label_position'})) {
$new_label_position = $elem->{'label_position'};
}
if(defined($elem->{'border_color'})) {
$new_border_color = $elem->{'border_color'};
}
if(defined($elem->{'fill_color'})) {
$new_fill_color = $elem->{'fill_color'};
}
db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y . ", width = " . $new_width .
", height = " . $new_height . ", label = '" . $new_label . "', image = '" . $new_image .
"', type = " . $new_type . ", period = " . $new_period . ", id_agente_modulo = " . $new_id_agente_modulo .
", id_agent = " . $new_id_agent . ", id_layout_linked = " . $new_id_layout_linked . ", parent_item = " . $new_parent_item .
", enable_link = " . $new_enable_link . ", id_metaconsole = " . $new_id_metaconsole . ", id_group = " . $new_id_group .
", id_custom_graph = " . $new_id_custom_graph . ", border_width = " . $new_border_width . ", type_graph = '" . $new_type_graph .
"', label_position = '" . $new_label_position . "', border_color = '" . $new_border_color . "', fill_color = '" . $new_fill_color .
"' WHERE id = " . $elem->{'id'});
print_log "[INFO] Element with id " . $elem->{'id'} . " has been updated \n\n";
}
else {
my $pos_x = $elem->{'pos_x'};
my $pos_y = $elem->{'pos_y'};
my $width = $elem->{'width'};
my $height = $elem->{'height'};
my $label = $elem->{'label'};
my $image = $elem->{'image'};
my $type = $elem->{'type'};
my $period = $elem->{'period'};
my $id_agente_modulo = $elem->{'id_agente_modulo'};
my $id_agent = $elem->{'id_agent'};
my $id_layout_linked = $elem->{'id_layout_linked'};
my $parent_item = $elem->{'parent_item'};
my $enable_link = $elem->{'enable_link'};
my $id_metaconsole = $elem->{'id_metaconsole'};
my $id_group = $elem->{'id_group'};
my $id_custom_graph = $elem->{'id_custom_graph'};
my $border_width = $elem->{'border_width'};
my $type_graph = $elem->{'type_graph'};
my $label_position = $elem->{'label_position'};
my $border_color = $elem->{'border_color'};
my $fill_color = $elem->{'fill_color'};
my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0);
print_log "[INFO] New element with id $new_elem_id has been created \n\n";
}
}
}
elsif ($mode eq 'auto_creation') {
if ($element_square_positions eq '') {
print_log "[ERROR] With this mode, square positions is obligatory'.\n\n";
exit 1;
}
else {
foreach my $elem (@$elements_in_array) {
if (defined($elem->{'id'})) {
print_log "[INFO] Edit element with id " . $elem->{'id'} . " \n\n";
my $element_in_db = get_db_single_row ($dbh, "SELECT *
FROM tlayout_data
WHERE id = " . $elem->{'id'});
my $new_pos_x = $element_in_db->{'pos_x'};
my $new_pos_y = $element_in_db->{'pos_y'};
my $new_width = $element_in_db->{'width'};
my $new_height = $element_in_db->{'height'};
my $new_label = $element_in_db->{'label'};
my $new_image = $element_in_db->{'image'};
my $new_type = $element_in_db->{'type'};
my $new_period = $element_in_db->{'period'};
my $new_id_agente_modulo = $element_in_db->{'id_agente_modulo'};
my $new_id_agent = $element_in_db->{'id_agent'};
my $new_id_layout_linked = $element_in_db->{'id_layout_linked'};
my $new_parent_item = $element_in_db->{'parent_item'};
my $new_enable_link = $element_in_db->{'enable_link'};
my $new_id_metaconsole = $element_in_db->{'id_metaconsole'};
my $new_id_group = $element_in_db->{'id_group'};
my $new_id_custom_graph = $element_in_db->{'id_custom_graph'};
my $new_border_width = $element_in_db->{'border_width'};
my $new_type_graph = $element_in_db->{'type_graph'};
my $new_label_position = $element_in_db->{'label_position'};
my $new_border_color = $element_in_db->{'border_color'};
my $new_fill_color = $element_in_db->{'fill_color'};
if(defined($elem->{'width'})) {
$new_width = $elem->{'width'};
}
if(defined($elem->{'height'})) {
$new_height = $elem->{'height'};
}
if(defined($elem->{'label'})) {
$new_label = $elem->{'label'};
}
if(defined($elem->{'image'})) {
$new_image = $elem->{'image'};
}
if(defined($elem->{'type'})) {
$new_type = $elem->{'type'};
}
if(defined($elem->{'period'})) {
$new_period = $elem->{'period'};
}
if(defined($elem->{'id_agente_modulo'})) {
$new_id_agente_modulo = $elem->{'id_agente_modulo'};
}
if(defined($elem->{'id_agent'})) {
$new_id_agent = $elem->{'id_agent'};
}
if(defined($elem->{'id_layout_linked'})) {
$new_id_layout_linked = $elem->{'id_layout_linked'};
}
if(defined($elem->{'parent_item'})) {
$new_parent_item = $elem->{'parent_item'};
}
if(defined($elem->{'enable_link'})) {
$new_enable_link = $elem->{'enable_link'};
}
if(defined($elem->{'id_metaconsole'})) {
$new_id_metaconsole = $elem->{'id_metaconsole'};
}
if(defined($elem->{'id_group'})) {
$new_id_group = $elem->{'id_group'};
}
if(defined($elem->{'id_custom_graph'})) {
$new_id_custom_graph = $elem->{'id_custom_graph'};
}
if(defined($elem->{'border_width'})) {
$new_border_width = $elem->{'border_width'};
}
if(defined($elem->{'type_graph'})) {
$new_type_graph = $elem->{'type_graph'};
}
if(defined($elem->{'label_position'})) {
$new_label_position = $elem->{'label_position'};
}
if(defined($elem->{'border_color'})) {
$new_border_color = $elem->{'border_color'};
}
if(defined($elem->{'fill_color'})) {
$new_fill_color = $elem->{'fill_color'};
}
db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y . ", width = " . $new_width .
", height = " . $new_height . ", label = '" . $new_label . "', image = '" . $new_image .
"', type = " . $new_type . ", period = " . $new_period . ", id_agente_modulo = " . $new_id_agente_modulo .
", id_agent = " . $new_id_agent . ", id_layout_linked = " . $new_id_layout_linked . ", parent_item = " . $new_parent_item .
", enable_link = " . $new_enable_link . ", id_metaconsole = " . $new_id_metaconsole . ", id_group = " . $new_id_group .
", id_custom_graph = " . $new_id_custom_graph . ", border_width = " . $new_border_width . ", type_graph = '" . $new_type_graph .
"', label_position = '" . $new_label_position . "', border_color = '" . $new_border_color . "', fill_color = '" . $new_fill_color .
"' WHERE id = " . $elem->{'id'});
print_log "[INFO] Element with id " . $elem->{'id'} . " has been updated \n\n";
}
else {
my $pos_x = 0;
my $pos_y = 0;
my $width = $elem->{'width'};
my $height = $elem->{'height'};
my $label = $elem->{'label'};
my $image = $elem->{'image'};
my $type = $elem->{'type'};
my $period = $elem->{'period'};
my $id_agente_modulo = $elem->{'id_agente_modulo'};
my $id_agent = $elem->{'id_agent'};
my $id_layout_linked = $elem->{'id_layout_linked'};
my $parent_item = $elem->{'parent_item'};
my $enable_link = $elem->{'enable_link'};
my $id_metaconsole = $elem->{'id_metaconsole'};
my $id_group = $elem->{'id_group'};
my $id_custom_graph = $elem->{'id_custom_graph'};
my $border_width = $elem->{'border_width'};
my $type_graph = $elem->{'type_graph'};
my $label_position = $elem->{'label_position'};
my $border_color = $elem->{'border_color'};
my $fill_color = $elem->{'fill_color'};
my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0);
print_log "[INFO] New element with id $new_elem_id has been created \n\n";
}
}
my $positions = decode_json($element_square_positions);
my $pos1X = $positions->{'pos1x'};
my $pos1Y = $positions->{'pos1y'};
my $pos2X = $positions->{'pos2x'};
my $pos2Y = $positions->{'pos2y'};
my @console_elements = get_db_rows ($dbh, "SELECT *
FROM tlayout_data
WHERE id_layout = $id");
my $number_of_elements = scalar(@console_elements);
my $x_divider = 4;
my $y_divider = 1;
for (my $i = 1; $i <= 1000; $i++) {
if (($i * 4) < $number_of_elements) {
$y_divider++;
}
else {
last;
}
}
my $elem_width = ($pos2X - $pos1X) / $x_divider;
my $elem_height = ($pos2Y - $pos1Y) / $y_divider;
if ($number_of_elements < 4) {
$elem_height = ($pos2Y - $pos1Y) / 3;
}
my $elem_count = 1;
my $pos_helper_x = 0;
my $pos_helper_y = 0;
foreach my $elem (@console_elements) {
my $new_pos_x = $pos_helper_x * $elem_width;
my $new_pos_y = $pos_helper_y * $elem_height;
my $new_elem_width = $elem_width;
my $new_elem_height = $elem_height;
db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y .
", width = " . $new_elem_width . ", height = " . $new_elem_height .
" WHERE id = " . $elem->{'id'});
print_log "[INFO] Recolocate element with id " . $elem->{'id'} . " \n\n";
$elem_count++;
if ($pos_helper_x == 3) {
$pos_helper_x = 0;
$pos_helper_y++;
}
else {
$pos_helper_x++;
}
}
}
}
else {
print_log "[ERROR] Mode parameter must be 'static_objects' or 'auto_creation'.\n\n";
exit 1;
}
}
}
##############################################################################
# Delete a visual console.
# Related option: --delete_visual_console
##############################################################################
sub cli_delete_visual_console() {
my ($id) = @ARGV[2];
if($id eq '') {
print_log "[ERROR] ID field cannot be empty.\n\n";
exit 1;
}
print_log "[INFO] Delete visual console with ID '$id' \n\n";
my $delete_layout = db_do($dbh, 'DELETE FROM tlayout WHERE id = ?', $id);
if ($delete_layout eq 1) {
db_do($dbh, 'DELETE FROM tlayout_data WHERE id_layout = ?', $id);
print_log "[INFO] Delete visual console elements with console ID '$id' \n\n";
}
else {
print_log "[ERROR] Error at remove the visual console.\n\n";
exit 1;
}
}
##############################################################################
# Delete a visual console objects.
# Related option: --delete_visual_console_objects
##############################################################################
sub cli_delete_visual_console_objects() {
my ($id_console,$mode,$id_mode) = @ARGV[2..4];
if($id_console eq '') {
print_log "[ERROR] Console ID field cannot be empty.\n\n";
exit 1;
}
elsif ($mode eq '') {
print_log "[ERROR] Mode field cannot be empty.\n\n";
exit 1;
}
elsif ($id_mode eq '') {
print_log "[ERROR] Mode index field cannot be empty.\n\n";
exit 1;
}
if (($mode eq 'type') || ($mode eq 'image') || ($mode eq 'id_agent') ||
($mode eq 'id_agente_modulo') || ($mode eq 'id_group') || ($mode eq 'type_graph')) {
print_log "[INFO] Removind objects with mode '$mode' and id '$id_mode' \n\n";
db_do($dbh, 'DELETE FROM tlayout_data WHERE id_layout = ' . $id_console . ' AND ' . $mode . ' = "' . $id_mode . '"');
}
else {
print_log "[ERROR] Mode is not correct.\n\n";
exit 1;
}
}
##############################################################################
# Duplicate a visual console.
# Related option: --duplicate_visual_console
##############################################################################
sub cli_duplicate_visual_console () {
my ($id_console,$times,$prefix) = @ARGV[2..4];
if($id_console eq '') {
print_log "[ERROR] Console ID field cannot be empty.\n\n";
exit 1;
}
my $console = get_db_single_row ($dbh, "SELECT *
FROM tlayout
WHERE id = $id_console");
my $name_to_compare = $console->{'name'};
my $new_name = $console->{'name'} . "_1";
my $name_count = 2;
if ($prefix ne '') {
$new_name = $prefix;
$name_to_compare = $prefix;
$name_count = 1;
}
for (my $iteration = 0; $iteration < $times; $iteration++) {
my $exist = 1;
while ($exist == 1) {
my $name_in_db = get_db_single_row ($dbh, "SELECT name FROM tlayout WHERE name = '$new_name'");
if (defined($name_in_db->{'name'}) && ($name_in_db->{'name'} eq $new_name)) {
$new_name = $name_to_compare . "_" . $name_count;
$name_count++;
}
else {
$exist = 0;
}
}
my $new_console_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout (name, id_group, background, width, height, background_color)
VALUES (?, ?, ?, ?, ?, ?)', $new_name, $console->{'id_group'}, $console->{'background'}, $console->{'width'}, $console->{'height'}, $console->{'background_color'});
print_log "[INFO] The new visual console '$new_name' has been created. The new ID is '$new_console_id' \n\n";
my @console_elements = get_db_rows ($dbh, "SELECT *
FROM tlayout_data
WHERE id_layout = $id_console");
foreach my $element (@console_elements) {
my $pos_x = $element->{'pos_x'};
my $pos_y = $element->{'pos_y'};
my $width = $element->{'width'};
my $height = $element->{'height'};
my $label = $element->{'label'};
my $image = $element->{'image'};
my $type = $element->{'type'};
my $period = $element->{'period'};
my $id_agente_modulo = $element->{'id_agente_modulo'};
my $id_agent = $element->{'id_agent'};
my $id_layout_linked = $element->{'id_layout_linked'};
my $parent_item = $element->{'parent_item'};
my $enable_link = $element->{'enable_link'};
my $id_metaconsole = $element->{'id_metaconsole'};
my $id_group = $element->{'id_group'};
my $id_custom_graph = $element->{'id_custom_graph'};
my $border_width = $element->{'border_width'};
my $type_graph = $element->{'type_graph'};
my $label_position = $element->{'label_position'};
my $border_color = $element->{'border_color'};
my $fill_color = $element->{'fill_color'};
my $element_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $new_console_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0);
print_log "[INFO] Element with ID " . $element->{"id"} . " has been duplicated to the new console \n\n";
}
}
}
##############################################################################
# Export a visual console elements to json.
# Related option: --export_json_visual_console
##############################################################################
sub cli_export_visual_console() {
my ($id,$path) = @ARGV[2..3];
if($id eq '') {
print_log "[ERROR] ID field cannot be empty.\n\n";
exit 1;
}
my $data_to_json = '';
my $first = 1;
print_log "[INFO] Exporting visual console elements with ID '$id' \n\n";
my $console = get_db_single_row ($dbh, "SELECT *
FROM tlayout
WHERE id = $id");
$data_to_json .= '"' . safe_output($console->{'name'}) . '"';
$data_to_json .= ' "' . $console->{'background'} . '"';
$data_to_json .= ' ' . $console->{'width'};
$data_to_json .= ' ' . $console->{'height'};
$data_to_json .= ' ' . $console->{'id_group'};
$data_to_json .= ' "static_objects"';
$data_to_json .= ' ""';
$data_to_json .= ' "' . $console->{'background_color'} . '" ';
my @console_elements = get_db_rows ($dbh, "SELECT *
FROM tlayout_data
WHERE id_layout = $id");
$data_to_json .= '[';
foreach my $element (@console_elements) {
my $pos_x = $element->{'pos_x'};
my $pos_y = $element->{'pos_y'};
my $width = $element->{'width'};
my $height = $element->{'height'};
my $label = $element->{'label'};
my $image = $element->{'image'};
my $type = $element->{'type'};
my $period = $element->{'period'};
my $id_agente_modulo = $element->{'id_agente_modulo'};
my $id_agent = $element->{'id_agent'};
my $id_layout_linked = $element->{'id_layout_linked'};
my $parent_item = $element->{'parent_item'};
my $enable_link = $element->{'enable_link'};
my $id_metaconsole = $element->{'id_metaconsole'};
my $id_group = $element->{'id_group'};
my $id_custom_graph = $element->{'id_custom_graph'};
my $border_width = $element->{'border_width'};
my $type_graph = $element->{'type_graph'};
my $label_position = $element->{'label_position'};
my $border_color = $element->{'border_color'};
my $fill_color = $element->{'fill_color'};
if ($first == 0) {
$data_to_json .= ','
}
else {
$first = 0;
}
$label =~ s/"/\\"/g;
$data_to_json .= '{"image":"' . $image . '"';
$data_to_json .= ',"pos_y":' . $pos_y;
$data_to_json .= ',"pos_x":' . $pos_x;
$data_to_json .= ',"width":' . $width;
$data_to_json .= ',"height":' . $height;
$data_to_json .= ',"label":"' . $label . '"';
$data_to_json .= ',"type":' . $type;
$data_to_json .= ',"period":' . $period;
$data_to_json .= ',"id_agente_modulo":' . $id_agente_modulo;
$data_to_json .= ',"id_agent":' . $id_agent;
$data_to_json .= ',"id_layout_linked":' . $id_layout_linked;
$data_to_json .= ',"parent_item":' . $parent_item;
$data_to_json .= ',"enable_link":' . $enable_link;
$data_to_json .= ',"id_metaconsole":' . $id_metaconsole;
$data_to_json .= ',"id_group":' . $id_group;
$data_to_json .= ',"id_custom_graph":' . $id_custom_graph;
$data_to_json .= ',"border_width":' . $border_width;
$data_to_json .= ',"type_graph":"' . $type_graph . '"';
$data_to_json .= ',"label_position":"' . $label_position . '"';
$data_to_json .= ',"border_color":"' . $border_color . '"';
$data_to_json .= ',"fill_color":"' . $fill_color . '"';
$data_to_json .= '}';
}
$data_to_json .= ']';
if ($path eq '') {
open(FicheroJSON, ">console_" . $id . "_elements");
}
else {
open(FicheroJSON, ">" . $path . "/console_" . $id . "_elements");
}
print FicheroJSON $data_to_json;
print_log "[INFO] JSON file now contents: \n" . $data_to_json . "\n\n";
}
############################################################################### ###############################################################################
############################################################################### ###############################################################################
@ -5183,7 +5989,31 @@ sub pandora_manage_main ($$$) {
elsif ($param eq '--locate_agent') { elsif ($param eq '--locate_agent') {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_locate_agent(); cli_locate_agent();
} }
elsif ($param eq '--create_visual_console') {
param_check($ltotal, 9, 3);
cli_create_visual_console();
}
elsif ($param eq '--edit_visual_console') {
param_check($ltotal, 10, 9);
cli_edit_visual_console();
}
elsif ($param eq '--delete_visual_console') {
param_check($ltotal, 1);
cli_delete_visual_console();
}
elsif ($param eq '--delete_visual_console_objects') {
param_check($ltotal, 3);
cli_delete_visual_console_objects();
}
elsif ($param eq '--duplicate_visual_console') {
param_check($ltotal, 3, 2);
cli_duplicate_visual_console();
}
elsif ($param eq '--export_json_visual_console') {
param_check($ltotal, 2, 1);
cli_export_visual_console();
}
else { else {
print_log "[ERROR] Invalid option '$param'.\n\n"; print_log "[ERROR] Invalid option '$param'.\n\n";
$param = ''; $param = '';