diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 4fc8c757ba..d78044b76d 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -58,6 +58,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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_pwd mypassword diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a06e7378ca..b1a7b7e149 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.712-170919 +Version: 7.0NG.712-170928 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index f8d8fb9030..ac8dc8ee74 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.712-170919" +pandora_version="7.0NG.712-170928" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 41c6747052..11a58e3225 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -88,6 +88,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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_pwd mypassword diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 29d6e893b7..6d988c94ac 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -98,6 +98,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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) #transfer_timeout 30 diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 9db22b3b47..01bc718c43 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -60,6 +60,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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_pwd mypassword diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index fcfa94b429..00fa91f85f 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -104,6 +104,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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) #transfer_timeout 30 diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index 4f89baee8b..088a6b5159 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -66,6 +66,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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) #transfer_timeout 30 diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 94bc194a05..3c50a12bfa 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -60,6 +60,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local 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) #transfer_timeout 30 diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 2549bfd26c..6f62a5189c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.712'; -use constant AGENT_BUILD => '170919'; +use constant AGENT_BUILD => '170928'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -128,6 +128,9 @@ my @BrokerPid; my %DefaultConf = ( 'server_ip' => 'localhost', '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', 'logsize' => DEFAULT_MAX_LOG_SIZE, 'logrotate' => DEFAULT_LOG_ROTATE, @@ -146,6 +149,7 @@ my %DefaultConf = ( 'encoding' => 'UTF-8', 'server_port' => 41121, 'transfer_mode' => 'tentacle', + 'transfer_mode_user' => 'apache', 'transfer_timeout' => 30, 'server_user' => 'pandora', 'server_pwd' => '', @@ -906,13 +910,17 @@ sub fix_directory ($) { ################################################################################ # Sends a file to the server. ################################################################################ -#sub send_file ($;$$$) { sub send_file { - my ($file, $secondary, $rc_primary, $flag_always) = @_; + my ($file, $secondary, $rc_primary, $flag_always, $relative) = @_; + my $output; my $pid = fork(); 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) { # execute the transfer program by child process. eval { @@ -935,7 +943,7 @@ sub send_file { quit FEOF1` } 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); }; @@ -966,7 +974,7 @@ sub send_file { $rc_primary = 1; } swap_servers (); - $rc = send_file ($file, undef, $rc_primary); + $rc = send_file ($file, undef, $rc_primary, undef, $relative); swap_servers (); 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)); swap_servers (); - $rc = send_file ($file); + $rc = send_file ($file, undef, undef, undef, $relative); swap_servers (); return $rc; } @@ -1075,12 +1083,16 @@ sub swap_servers () { ################################################################################ # Receive a file from the server. ################################################################################ -sub recv_file ($) { - my $file = shift; +sub recv_file { + my ($file, $relative) = @_; my $output; - + 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) { # execute the transfer program by child process. @@ -1104,7 +1116,7 @@ sub recv_file ($) { quit FEOF1` } 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); }; @@ -1148,14 +1160,19 @@ sub check_remote_config () { } # 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: $!."); print MD5_FILE $conf_md5; close (MD5_FILE); copy ("$ConfDir/$ConfFile", "$Conf{'temporal'}/$RemoteConfFile"); - send_file ("$Conf{'temporal'}/$RemoteConfFile"); - send_file ("$Conf{'temporal'}/$RemoteMD5File"); - log_message ('remote config', 'Uploading configuration for the first time.'); + if ($Conf{'transfer_mode'} eq 'local') { + my (undef, undef, $uid, $gid) = getpwnam($Conf{'transfer_mode_user'}); + 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'}/$RemoteMD5File"); return; @@ -1169,7 +1186,7 @@ sub check_remote_config () { return if ($remote_conf_md5 eq $conf_md5); # 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!'); # Save the new configuration @@ -1255,7 +1272,7 @@ sub check_collections () { # 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")); - 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: $!."); my $remote_collection_md5 = ; close (MD5_FILE); @@ -1273,7 +1290,7 @@ sub check_collections () { next if ($local_collection_md5 eq $remote_collection_md5); # 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"); `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`; unlink ("$Conf{'temporal'}/$collection_file"); diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 78c0aa401c..ec5e0e5663 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.712 -%define release 170919 +%define release 170928 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index c288bed121..b223d4f90a 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.712 -%define release 170919 +%define release 170928 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index b5beb38046..0789a24800 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.712" -PI_BUILD="170919" +PI_BUILD="170928" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 1b6c70f863..8ea5ceb41f 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{170919} +{170928} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 73695629ba..fb996cc36a 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.712(Build 170919)") +#define PANDORA_VERSION ("7.0NG.712(Build 170928)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 3adac4c3c5..a0e80df580 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.712(Build 170919))" + VALUE "ProductVersion", "(7.0NG.712(Build 170928))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 192f84302a..173c1ae0bf 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.712-170919 +Version: 7.0NG.712-170928 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index e967db8d6a..afdbd8a6c2 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.712-170919" +pandora_version="7.0NG.712-170928" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index e5e1d84331..f70859d134 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -184,7 +184,7 @@ function extension_db_check_tables_differences($connection_test, ui_print_result_message( empty($diff_tables), __('Successful the DB Pandora has all tables'), - __('Unsuccessful the DB Pandora has not all tables. The tables lost are (%s)', + __('Unsuccessful the DB Pandora has not all tables. The missing tables are (%s)', implode(", ", $diff_tables))); if (!empty($diff_tables)) { @@ -233,16 +233,15 @@ function extension_db_check_tables_differences($connection_test, if (!empty($result)) { while ($row = mysql_fetch_array ($result)) { $fields_system[$row[0]] = array( - 'field ' => $row[0], - 'type' => $row[1], - 'null' => $row[2], - 'key' => $row[3], + 'field ' => $row[0], + 'type' => $row[1], + 'null' => $row[2], + 'key' => $row[3], 'default' => $row[4], - 'extra' => $row[5]); + 'extra' => $row[5]); } mysql_free_result ($result); } - foreach ($fields_test as $name_field => $field_test) { if (!isset($fields_system[$name_field])) { $correct_fields = false; @@ -262,7 +261,6 @@ function extension_db_check_tables_differences($connection_test, $field_system = $fields_system[$name_field]; $diff = array_diff($field_test, $field_system); - if (!empty($diff)) { foreach ($diff as $config_field => $value) { switch ($config_field) { @@ -279,13 +277,14 @@ function extension_db_check_tables_differences($connection_test, break; case 'null': ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be setted the null values with %s.', + __('Unsuccessful the field %s in the table %s must be null: (%s).', $name_field, $table, $value)); - if ($value == "no") { + + if ($value == "YES") { ui_print_info_message( __('You can execute this SQL query for to fix.') . "
" . '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . "INT NULL;" .
+											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " "  . $field_test['type'] . " NULL;" .
 										'
' ); } @@ -293,7 +292,7 @@ function extension_db_check_tables_differences($connection_test, ui_print_info_message( __('You can execute this SQL query for to fix.') . "
" . '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . "INT NOT NULL;" .
+											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $field_test['type'] . " NOT NULL;" .
 										'
' ); } @@ -307,11 +306,21 @@ function extension_db_check_tables_differences($connection_test, __('Please check the SQL file for to know the kind of key needed.')); break; case 'default': + if($field_test['null'] == "YES" || !isset($field_test['null']) || $field_test['null'] == ""){ + $null_defect = " NULL"; + } + else{ + $null_defect = " NOT NULL"; + } ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be setted the default value as %s.', + __('Unsuccessful the field %s in the table %s must be setted %s as default value.', $name_field, $table, $value)); ui_print_info_message( - __('Please check the SQL file for to know the kind of default value needed.')); + __('You can execute this SQL query for to fix.') . "
" . + '
' .
+											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " "  . $field_test['type'] . $null_defect . " DEFAULT " . $value . ";" .
+										'
' + ); break; case 'extra': ui_print_error_message( diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index bd34c56503..fc42c1f85a 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -793,7 +793,7 @@ if ($update_agent) { // if modified some agent paramenter WHERE id_group = ".$group_old); $result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agente)); - if ($result === false) { + if ($result == false) { ui_print_error_message( __('There was a problem updating the agent')); } diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 023ed6e84c..6be8d61b40 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -35,6 +35,7 @@ if (is_ajax ()) { $get_group_json = (bool) get_parameter ('get_group_json'); $get_group_agents = (bool) get_parameter ('get_group_agents'); + $get_is_disabled = (bool) get_parameter ('get_is_disabled'); if ($get_group_json) { $id_group = (int) get_parameter ('id_group'); @@ -70,6 +71,7 @@ if (is_ajax ()) { $search = (string) get_parameter ('search', ''); $recursion = (int) get_parameter ('recursion', 0); $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 $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 @@ -96,7 +98,12 @@ if (is_ajax ()) { $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 != '') { $filter['string'] = $search; @@ -126,17 +133,42 @@ if (is_ajax ()) { false, $recursion, false, '|', $add_alert_bulk_op); } + $agents_disabled = array(); // Add keys prefix if ($keys_prefix !== "") { foreach($agents as $k => $v) { $agents[$keys_prefix . $k] = $v; 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); 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; } diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 00df36a2c7..534bf07a0b 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -94,6 +94,7 @@ $inventory_modules = array(); $date = null; // Only avg is selected by default for the simple graphs $only_avg = true; +$fullscale = false; $percentil = false; $time_compare_overlapped = false; @@ -212,6 +213,7 @@ switch ($action) { break; case 'simple_graph': $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; // The break hasn't be forgotten. case 'simple_baseline_graph': @@ -480,6 +482,7 @@ switch ($action) { $description = $item['description']; $group = $item['id_group']; $period = $item['period']; + $fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0; break; case 'top_n': $description = $item['description']; @@ -1353,6 +1356,11 @@ You can of course remove the warnings, that's why we include the source and do n + + + + @@ -2643,6 +2651,7 @@ function chooseType() { $("#row_show_graph").hide(); $("#row_max_min_avg").hide(); $("#row_only_avg").hide(); + $("#row_fullscale").hide(); $("#row_time_compare_overlapped").hide(); $("#row_quantity").hide(); $("#row_exception_condition_value").hide(); @@ -2725,6 +2734,7 @@ function chooseType() { case 'simple_graph': $("#row_time_compare_overlapped").show(); $("#row_only_avg").show(); + $("#row_fullscale").show(); if ($("#checkbox-percentil").prop("checked")) $("#row_percentil").show(); // The break hasn't be forgotten, this element @@ -3122,6 +3132,7 @@ function chooseType() { $("#row_description").show(); $("#row_period").show(); $("#row_historical_db_check").hide(); + $("#row_fullscale").show(); break; case 'top_n': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 705f49c2d0..4dd13e9af0 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1172,13 +1172,17 @@ switch ($action) { case 'simple_graph': // Warning. We are using this column to hold this value to avoid // 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['fullscale'] = (int) get_parameter('fullscale'); if ($label != '') $style['label'] = $label; else $style['label'] = ''; break; + case 'network_interfaces_report': + $style['fullscale'] = (int) get_parameter('fullscale'); + break; case 'module_histogram_graph': case 'agent_configuration': case 'alert_report_agent': @@ -1516,13 +1520,17 @@ switch ($action) { case 'simple_graph': // Warning. We are using this column to hold this value to avoid // 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['fullscale'] = (int) get_parameter('fullscale'); if ($label != '') $style['label'] = $label; else $style['label'] = ''; break; + case 'network_interfaces_report': + $style['fullscale'] = (int) get_parameter('fullscale'); + break; case 'module_histogram_graph': case 'agent_configuration': case 'alert_report_agent': diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index a7e710dcb2..97fb142a8d 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -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_base_dn = isset($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; - - 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_login_attr = !empty($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) . "=" : ''; + + $ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; + + if(!empty($ldap_base_dn)){ + if (strlen($password) == 0 || + !@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'; + @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); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index cbcd7ec774..b01a037303 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC170919'; +$build_version = 'PC170928'; $pandora_version = 'v7.0NG.712'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index c5830bfbfa..f8edfd1d27 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1809,10 +1809,12 @@ function check_acl($id_user, $id_group, $access, $onlyOneGroup = false) { $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])) { + if (isset($three_eyes_crow_group[$acl_column]) && $three_eyes_crow_group[$acl_column] == 1) { return 1; } } diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 499a8a817f..adf077ec6a 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -164,7 +164,7 @@ function custom_graphs_print($id_graph, $height, $width, $period, $background_color = 'white', $modules_param = array(), $homeurl = '', $name_list = array(), $unit_list = array(), $show_last = true, $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; @@ -261,7 +261,8 @@ function custom_graphs_print($id_graph, $height, $width, $period, $vconsole, $percentil, $from_interface, - $id_widget_dashboard); + $id_widget_dashboard, + $fullscale); if ($return) return $output; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 0ef5e1d9d3..7e3fe9fbdb 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -502,7 +502,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $baseline = 0, $return_data = 0, $show_title = true, $projection = false, $adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '', $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false, - $type_graph='area', $fullscale = false) { + $type_graph='area', $fullscale = false, $flash_chart = false) { global $config; global $chart; @@ -570,12 +570,14 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, // Get module data if ($fullscale) { - $data = db_get_all_rows_filter ('tagente_datos', - array ('id_agente_modulo' => (int)$agent_module_id, - "utimestamp > $datelimit", - "utimestamp < $date", - 'order' => 'utimestamp ASC'), - array ('datos', 'utimestamp'), 'AND', true); + fullscale_data( $chart, $chart_data_extra, $long_index, $series_type, + $agent_module_id, $datelimit, $date, $events, + $show_events, $show_unknown, $show_alerts, + $series_suffix, $percentil, $flash_chart); + if (count($chart) > $resolution) { + $resolution = count($chart); //Number of points of the graph + $interval = (int) ($period / $resolution); + } } else { $data = db_get_all_rows_filter ('tagente_datos', @@ -619,73 +621,68 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, } $data = $new_data; } - } - // Get module warning_min and critical_min - $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id); - $critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$agent_module_id); - - if ($data === false) { - $data = array (); - } - - - if ($uncompressed_module) { - // Uncompressed module data - $min_necessary = 1; - } - else { - // Compressed module data - // Get previous data - $previous_data = modules_get_previous_data ($agent_module_id, $datelimit); - if ($previous_data !== false) { - $previous_data['utimestamp'] = $datelimit; - array_unshift ($data, $previous_data); + if ($data === false) { + $data = array (); } - // Get next data - $nextData = modules_get_next_data ($agent_module_id, $date); - if ($nextData !== false) { - array_push ($data, $nextData); + if ($uncompressed_module) { + // Uncompressed module data + $min_necessary = 1; } - else if (count ($data) > 0) { - // Propagate the last known data to the end of the interval - $nextData = array_pop ($data); - array_push ($data, $nextData); - $nextData['utimestamp'] = $date; - array_push ($data, $nextData); + else { + // Compressed module data + + // Get previous data + $previous_data = modules_get_previous_data ($agent_module_id, $datelimit); + if ($previous_data !== false) { + $previous_data['utimestamp'] = $datelimit; + array_unshift ($data, $previous_data); + } + + // Get next data + $nextData = modules_get_next_data ($agent_module_id, $date); + if ($nextData !== false) { + array_push ($data, $nextData); + } + else if (count ($data) > 0) { + // Propagate the last known data to the end of the interval + $nextData = array_pop ($data); + array_push ($data, $nextData); + $nextData['utimestamp'] = $date; + array_push ($data, $nextData); + } + $min_necessary = 2; } - - $min_necessary = 2; - } - // Check available data - if (count ($data) < $min_necessary) { - if (!$graphic_type) { - if (!$projection) { - return fs_error_image (); - } - else { - return fs_error_image (); + // Check available data + if (count ($data) < $min_necessary) { + if (!$graphic_type) { + if (!$projection) { + return fs_error_image (); + } + else { + return fs_error_image (); + } } + graphic_error (); + } + + + // Data iterator + $data_i = 0; + + // Set initial conditions + if ($data[0]['utimestamp'] == $datelimit) { + $previous_data = $data[0]['datos']; + $data_i++; + } + else { + $previous_data = 0; } - graphic_error (); } - - // Data iterator - $data_i = 0; - - // Set initial conditions - if ($data[0]['utimestamp'] == $datelimit) { - $previous_data = $data[0]['datos']; - $data_i++; - } - else { - $previous_data = 0; - } - // Get baseline data $baseline_data = array(); if ($baseline) { @@ -704,49 +701,29 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $unit = modules_get_unit($agent_module_id); } - if ($fullscale) { - if (count($data) > $resolution) { - $resolution = count($data); //Number of points of the graph - $interval = (int) ($period / $resolution); - } + // Get module warning_min and critical_min + $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id); + $critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$agent_module_id); + + // Calculate chart data + if($fullscale){ + $avg_only = 1; + } + else{ + grafico_modulo_sparse_data_chart ($chart, $chart_data_extra, $long_index, + $data, $data_i, $previous_data, $resolution, $interval, $period, $datelimit, + $projection, $avg_only, $uncompressed_module, + $show_events, $show_alerts, $show_unknown, $baseline, + $baseline_data, $events, $series_suffix, $start_unknown, + $percentil, $fullscale); } - // Calculate chart data - grafico_modulo_sparse_data_chart ($chart, $chart_data_extra, $long_index, - $data, $data_i, $previous_data, $resolution, $interval, $period, $datelimit, - $projection, $avg_only, $uncompressed_module, - $show_events, $show_alerts, $show_unknown, $baseline, - $baseline_data, $events, $series_suffix, $start_unknown, - $percentil, $fullscale); - - if ($fullscale) { - if (!$flash_chart) { - $time_format = "Y M \nd H:i:s"; - } - else { - $time_format = "Y M d H:i:s"; - } - - $new_chart = array(); - $new_long_index = array(); - foreach ($chart as $c_timestamp => $c_data) { - $timestamp_short = date($time_format, $c_timestamp); - $new_long_index[$timestamp_short] = date( - html_entity_decode($time_format, ENT_QUOTES, "UTF-8"), $c_timestamp); - $new_chart[$timestamp_short] = $c_data; - } - - $long_index = $new_long_index; - $chart = $new_chart; - } - // Return chart data and don't draw if ($return_data == 1) { return $chart; } $graph_stats = get_statwin_graph_statistics($chart, $series_suffix); - // Fix event and alert scale if ($max_value > 0) { $event_max = 2 + (float)$max_value * 1.05; @@ -811,11 +788,11 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, 'border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => CHART_DEFAULT_ALPHA); - $color['unit'.$series_suffix] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10); + $color['unit'.$series_suffix] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10); if ($show_events) { $legend['event'.$series_suffix_str] = __('Events').$series_suffix_str; - $chart_extra_data['legend_events'] = $legend['event'].$series_suffix_str; + $chart_extra_data['legend_events'] = $legend['event'.$series_suffix_str]; } if ($show_alerts) { $legend['alert'.$series_suffix] = __('Alerts').$series_suffix_str; @@ -837,11 +814,14 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, __('Last') . ': ' . remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])) . ($unit ? ' ' . $unit : '') . ' ; ' . __('Avg') . ': ' . remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])) . ($unit ? ' ' . $unit : ''); } - else if (!$avg_only) { + else if (!$avg_only && !$fullscale) { $legend['max'.$series_suffix] = __('Max').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['max']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['max']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['max']['min'], $config['graph_precision'])).' '.$unit; $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; $legend['min'.$series_suffix] = __('Min').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['min']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['min']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['min']['min'], $config['graph_precision'])).' '.$unit; } + else if ($fullscale){ + $legend['sum'.$series_suffix] = __('Data').$series_suffix_str.': '; + } else { $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; } @@ -850,7 +830,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $legend['unknown'.$series_suffix] = __('Unknown').$series_suffix_str; $chart_extra_data['legend_unknown'] = $legend['unknown'.$series_suffix_str]; } - + if (!is_null($percentil) && $percentil) { $first_data = reset($chart); $percentil_value = format_for_graph($first_data['percentil'], 2); @@ -899,7 +879,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $return_data, $show_title, $projection, $adapt_key, $compare, $series_suffix, $series_suffix_str, $show_unknown, $percentil, $dashboard, $vconsole,$type_graph, - $fullscale); + $fullscale, $flash_chart); switch ($compare) { case 'separated': @@ -932,12 +912,10 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_alerts, $avg_only, $date, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, '', '', $show_unknown, - $percentil, $dashboard, $vconsole, $type_graph, $fullscale); - + $percentil, $dashboard, $vconsole, $type_graph, $fullscale, $flash_chart); if ($return_data) { return $data_returned; } - if ($compare === 'overlapped') { $i = 0; foreach ($chart as $k=>$v) { @@ -1077,488 +1055,521 @@ function graphic_combined_module ($module_list, $weight_list, $period, $prediction_period = false, $background_color = 'white', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $labels = array(), $dashboard = false, - $vconsole = false, $percentil = null, $from_interface = false, $id_widget_dashboard=false) { + $vconsole = false, $percentil = null, $from_interface = false, + $id_widget_dashboard=false, $fullscale = false) { global $config; global $graphic_type; + + if(!$fullscale){ + $time_format_2 = ''; + $temp_range = $period; - $time_format_2 = ''; - $temp_range = $period; - - if ($projection != false) { - if ($period < $prediction_period) - $temp_range = $prediction_period; - } - - // Set the title and time format - if ($temp_range <= SECONDS_1DAY) { - $time_format = 'Y M d H:i:s'; - } - elseif ($temp_range < SECONDS_15DAYS) { - $time_format = 'Y M d'; - $time_format_2 = 'H:i'; if ($projection != false) { + if ($period < $prediction_period) + $temp_range = $prediction_period; + } + + // Set the title and time format + if ($temp_range <= SECONDS_1DAY) { + $time_format = 'Y M d H:i:s'; + } + elseif ($temp_range < SECONDS_15DAYS) { + $time_format = 'Y M d'; + $time_format_2 = 'H:i'; + if ($projection != false) { + $time_format_2 = 'H\h'; + } + } + elseif ($temp_range <= SECONDS_1MONTH) { + $time_format = 'Y M d'; $time_format_2 = 'H\h'; } - } - elseif ($temp_range <= SECONDS_1MONTH) { - $time_format = 'Y M d'; - $time_format_2 = 'H\h'; - } - elseif ($temp_range <= SECONDS_1MONTH) { - $time_format = 'Y M d'; - $time_format_2 = 'H\h'; - } - elseif ($period < SECONDS_6MONTHS) { - $time_format = 'Y M d'; - $time_format_2 = 'H\h'; - } - else { - $time_format = "Y M d"; - $time_format_2 = 'H\h'; - } - - // Set variables - if ($date == 0) - $date = get_system_time(); - $datelimit = $date - $period; - - $resolution = $config['graph_res'] * 50; //Number of points of the graph - $interval = (int) ($period / $resolution); - - // If projection graph, fill with zero previous data to projection interval - if ($projection != false) { - $j = $datelimit; - $in_range = true; - while ($in_range) { - $timestamp_f = graph_get_formatted_date($j, $time_format, $time_format_2); - - $before_projection[$timestamp_f] = 0; - - if ($j > $date) { - $in_range = false; - } - $j = $j + $interval; + elseif ($temp_range <= SECONDS_1MONTH) { + $time_format = 'Y M d'; + $time_format_2 = 'H\h'; } - } - - // Added support for projection graphs (normal_module + 1(prediction data)) - if ($projection !== false) { - $module_number = count ($module_list) + 1; - } - else { - $module_number = count ($module_list); - } - - $names_number = count($name_list); - $units_number = count($unit_list); - - // interval - This is the number of "rows" we are divided the time to fill data. - // more interval, more resolution, and slower. - // periodo - Gap of time, in seconds. This is now to (now-periodo) secs - - // Init weights - for ($i = 0; $i < $module_number; $i++) { - if (! isset ($weight_list[$i])) { - $weight_list[$i] = 1; - } - else if ($weight_list[$i] == 0) { - $weight_list[$i] = 1; - } - } - - // Set data containers - for ($i = 0; $i < $resolution; $i++) { - $timestamp = $datelimit + ($interval * $i);/* - $timestamp_short = date($time_format, $timestamp); - $long_index[$timestamp_short] = date( - html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); - $timestamp = $timestamp_short;*/ - - $graph[$timestamp]['count'] = 0; - $graph[$timestamp]['timestamp_bottom'] = $timestamp; - $graph[$timestamp]['timestamp_top'] = $timestamp + $interval; - $graph[$timestamp]['min'] = 0; - $graph[$timestamp]['max'] = 0; - $graph[$timestamp]['event'] = 0; - $graph[$timestamp]['alert'] = 0; - } - - $long_index = array(); - - $graph_values = array(); - $module_name_list = array(); - $collector = 0; - $user = users_get_user_by_id($config['id_user']); - $user_flash_charts = $user['flash_chart']; - - if ($user_flash_charts == 1) - $flash_charts = true; - elseif($user_flash_charts == -1) - $flash_charts = $config['flash_charts']; - elseif($user_flash_charts == 0) - $flash_charts = false; - - if ($only_image) { - $flash_charts = false; - } - - // Calculate data for each module - for ($i = 0; $i < $module_number; $i++) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id ($module_list[$i]['server']); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - $search_in_history_db = db_search_in_history_db($datelimit); - - // If its a projection graph, - // first module will be data and second will be the projection - if ($projection != false && $i != 0) { - if ($automatic_custom_graph_meta) - $agent_module_id = $module_list[0]['module']; - else - $agent_module_id = $module_list[0]; - - $id_module_type = modules_get_agentmodule_type ($agent_module_id); - $module_type = modules_get_moduletype_name ($id_module_type); - $uncompressed_module = is_module_uncompressed ($module_type); + elseif ($period < SECONDS_6MONTHS) { + $time_format = 'Y M d'; + $time_format_2 = 'H\h'; } else { - if ($automatic_custom_graph_meta) - $agent_module_id = $module_list[$i]['module']; - else - $agent_module_id = $module_list[$i]; - - - $id_module_type = modules_get_agentmodule_type ($agent_module_id); - $module_type = modules_get_moduletype_name ($id_module_type); - $uncompressed_module = is_module_uncompressed ($module_type); + $time_format = "Y M d"; + $time_format_2 = 'H\h'; } - if ($uncompressed_module) { - $avg_only = 1; + // Set variables + if ($date == 0) + $date = get_system_time(); + $datelimit = $date - $period; + + $resolution = $config['graph_res'] * 50; //Number of points of the graph + $interval = (int) ($period / $resolution); + + // If projection graph, fill with zero previous data to projection interval + if ($projection != false) { + $j = $datelimit; + $in_range = true; + while ($in_range) { + $timestamp_f = graph_get_formatted_date($j, $time_format, $time_format_2); + + $before_projection[$timestamp_f] = 0; + + if ($j > $date) { + $in_range = false; + } + $j = $j + $interval; + } } - // Get event data (contains alert data too) - if ($show_events == 1 || $show_alerts == 1) { - $events = db_get_all_rows_filter ('tevento', - array ('id_agentmodule' => $agent_module_id, + // Added support for projection graphs (normal_module + 1(prediction data)) + if ($projection !== false) { + $module_number = count ($module_list) + 1; + } + else { + $module_number = count ($module_list); + } + + $names_number = count($name_list); + $units_number = count($unit_list); + + // interval - This is the number of "rows" we are divided the time to fill data. + // more interval, more resolution, and slower. + // periodo - Gap of time, in seconds. This is now to (now-periodo) secs + + // Init weights + for ($i = 0; $i < $module_number; $i++) { + if (! isset ($weight_list[$i])) { + $weight_list[$i] = 1; + } + else if ($weight_list[$i] == 0) { + $weight_list[$i] = 1; + } + } + + // Set data containers + for ($i = 0; $i < $resolution; $i++) { + $timestamp = $datelimit + ($interval * $i);/* + $timestamp_short = date($time_format, $timestamp); + $long_index[$timestamp_short] = date( + html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); + $timestamp = $timestamp_short;*/ + + $graph[$timestamp]['count'] = 0; + $graph[$timestamp]['timestamp_bottom'] = $timestamp; + $graph[$timestamp]['timestamp_top'] = $timestamp + $interval; + $graph[$timestamp]['min'] = 0; + $graph[$timestamp]['max'] = 0; + $graph[$timestamp]['event'] = 0; + $graph[$timestamp]['alert'] = 0; + } + $long_index = array(); + + $graph_values = array(); + $module_name_list = array(); + $collector = 0; + $user = users_get_user_by_id($config['id_user']); + $user_flash_charts = $user['flash_chart']; + + if ($user_flash_charts == 1) + $flash_charts = true; + elseif($user_flash_charts == -1) + $flash_charts = $config['flash_charts']; + elseif($user_flash_charts == 0) + $flash_charts = false; + + if ($only_image) { + $flash_charts = false; + } + + // Calculate data for each module + for ($i = 0; $i < $module_number; $i++) { + $automatic_custom_graph_meta = false; + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[$i])) { + $server = metaconsole_get_connection_by_id ($module_list[$i]['server']); + metaconsole_connect($server); + $automatic_custom_graph_meta = true; + } + } + + $search_in_history_db = db_search_in_history_db($datelimit); + + // If its a projection graph, + // first module will be data and second will be the projection + if ($projection != false && $i != 0) { + if ($automatic_custom_graph_meta) + $agent_module_id = $module_list[0]['module']; + else + $agent_module_id = $module_list[0]; + + $id_module_type = modules_get_agentmodule_type ($agent_module_id); + $module_type = modules_get_moduletype_name ($id_module_type); + $uncompressed_module = is_module_uncompressed ($module_type); + } + else { + if ($automatic_custom_graph_meta) + $agent_module_id = $module_list[$i]['module']; + else + $agent_module_id = $module_list[$i]; + + + $id_module_type = modules_get_agentmodule_type ($agent_module_id); + $module_type = modules_get_moduletype_name ($id_module_type); + $uncompressed_module = is_module_uncompressed ($module_type); + } + + if ($uncompressed_module) { + $avg_only = 1; + } + + // Get event data (contains alert data too) + if ($show_events == 1 || $show_alerts == 1) { + $events = db_get_all_rows_filter ('tevento', + array ('id_agentmodule' => $agent_module_id, + "utimestamp > $datelimit", + "utimestamp < $date", + 'order' => 'utimestamp ASC'), + array ('evento', 'utimestamp', 'event_type')); + if ($events === false) { + $events = array (); + } + } + + // Get module data + $data = db_get_all_rows_filter ('tagente_datos', + array ('id_agente_modulo' => $agent_module_id, "utimestamp > $datelimit", "utimestamp < $date", 'order' => 'utimestamp ASC'), - array ('evento', 'utimestamp', 'event_type')); - if ($events === false) { - $events = array (); - } - } - - // Get module data - $data = db_get_all_rows_filter ('tagente_datos', - array ('id_agente_modulo' => $agent_module_id, - "utimestamp > $datelimit", - "utimestamp < $date", - 'order' => 'utimestamp ASC'), - array ('datos', 'utimestamp'), 'AND', $search_in_history_db); - if ($data === false) { - $data = array (); - } - - // Uncompressed module data - if ($uncompressed_module) { - $min_necessary = 1; - - // Compressed module data - } - else { - // Get previous data - $previous_data = modules_get_previous_data ($agent_module_id, $datelimit); - if ($previous_data !== false) { - $previous_data['utimestamp'] = $datelimit; - array_unshift ($data, $previous_data); - } + array ('datos', 'utimestamp'), 'AND', $search_in_history_db); - // Get next data - $nextData = modules_get_next_data ($agent_module_id, $date); - if ($nextData !== false) { - array_push ($data, $nextData); - } - else if (count ($data) > 0) { - // Propagate the last known data to the end of the interval - $nextData = array_pop ($data); - array_push ($data, $nextData); - $nextData['utimestamp'] = $date; - array_push ($data, $nextData); + if ($data === false) { + $data = array (); } + + // Uncompressed module data + if ($uncompressed_module) { + $min_necessary = 1; - $min_necessary = 2; - } - - // Set initial conditions - $graph_values[$i] = array(); - - // Check available data - if (count ($data) < $min_necessary) { - continue; - } - - if (!empty($name_list) && $names_number == $module_number && isset($name_list[$i])) { - if ($labels[$agent_module_id] != '') - $module_name_list[$i] = $labels[$agent_module_id]; + // Compressed module data + } else { + // Get previous data + $previous_data = modules_get_previous_data ($agent_module_id, $datelimit); + if ($previous_data !== false) { + $previous_data['utimestamp'] = $datelimit; + array_unshift ($data, $previous_data); + } + + // Get next data + $nextData = modules_get_next_data ($agent_module_id, $date); + if ($nextData !== false) { + array_push ($data, $nextData); + } + else if (count ($data) > 0) { + // Propagate the last known data to the end of the interval + $nextData = array_pop ($data); + array_push ($data, $nextData); + $nextData['utimestamp'] = $date; + array_push ($data, $nextData); + } + + $min_necessary = 2; + } + + // Set initial conditions + $graph_values[$i] = array(); + + // Check available data + if (count ($data) < $min_necessary) { + continue; + } + + if (!empty($name_list) && $names_number == $module_number && isset($name_list[$i])) { + if ($labels[$agent_module_id] != '') + $module_name_list[$i] = $labels[$agent_module_id]; + else { + $agent_name = io_safe_output( + modules_get_agentmodule_agent_name ($agent_module_id)); + $alias = db_get_value ("alias","tagente","nombre",$agent_name); + $module_name = io_safe_output( + modules_get_agentmodule_name ($agent_module_id)); + + if ($flash_charts) + $module_name_list[$i] = '' . $alias . " / " . $module_name. ''; + else + $module_name_list[$i] = $alias . " / " . $module_name; + } + } + else { + //Get and process agent name $agent_name = io_safe_output( modules_get_agentmodule_agent_name ($agent_module_id)); $alias = db_get_value ("alias","tagente","nombre",$agent_name); + $agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false); + + $agent_id = agents_get_agent_id ($agent_name); + + //Get and process module name $module_name = io_safe_output( modules_get_agentmodule_name ($agent_module_id)); + $module_name = sprintf(__("%s"), $module_name); + $module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false); - if ($flash_charts) - $module_name_list[$i] = '' . $alias . " / " . $module_name. ''; - else - $module_name_list[$i] = $alias . " / " . $module_name; - } - } - else { - //Get and process agent name - $agent_name = io_safe_output( - modules_get_agentmodule_agent_name ($agent_module_id)); - $alias = db_get_value ("alias","tagente","nombre",$agent_name); - $agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false); - - $agent_id = agents_get_agent_id ($agent_name); - - //Get and process module name - $module_name = io_safe_output( - modules_get_agentmodule_name ($agent_module_id)); - $module_name = sprintf(__("%s"), $module_name); - $module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false); - - if ($flash_charts) { - if ($labels[$agent_module_id] != '') - $module_name_list[$i] = '' . - $labels[$agent_module_id] . ''; - else - $module_name_list[$i] = '' . - $alias . ' / ' . $module_name . ''; - } - else { - if ($labels[$agent_module_id] != '') - $module_name_list[$i] = $labels[$agent_module_id]; - else - $module_name_list[$i] = $alias . ' / ' . $module_name; - } - } - - // Data iterator - $j = 0; - - // Event iterator - $k = 0; - - // Set initial conditions - - //$graph_values[$i] = array(); - $temp_graph_values = array(); - - if ($data[0]['utimestamp'] == $datelimit) { - $previous_data = $data[0]['datos']; - $j++; - } - else { - $previous_data = 0; - } - - $max = 0; - $min = null; - $avg = 0; - $countAvg = 0; - - // Calculate chart data - $last_known = $previous_data; - - for ($l = 0; $l <= $resolution; $l++) { - $countAvg ++; - - $timestamp = $datelimit + ($interval * $l); - $timestamp_short = graph_get_formatted_date($timestamp, $time_format, $time_format_2); - - $long_index[$timestamp_short] = date( - html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); - //$timestamp = $timestamp_short; - - $total = 0; - $count = 0; - - // Read data that falls in the current interval - $interval_min = $last_known; - $interval_max = $last_known; - - while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) { - if ($data[$j]['datos'] > $interval_max) { - $interval_max = $data[$j]['datos']; - } - else if ($data[$j]['datos'] < $interval_max) { - $interval_min = $data[$j]['datos']; - } - $total += $data[$j]['datos']; - $last_known = $data[$j]['datos']; - $count++; - $j++; - } - - // Average - if ($count > 0) { - $total /= $count; - } - - // Read events and alerts that fall in the current interval - $event_value = 0; - $alert_value = 0; - while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) { - if ($show_events == 1) { - $event_value++; - } - if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') { - $alert_value++; - } - $k++; - } - - // Data - if ($count > 0) { - //$graph_values[$i][$timestamp] = $total * $weight_list[$i]; - $temp_graph_values[$timestamp_short] = $total * $weight_list[$i]; - } - else { - // Compressed data - if ($uncompressed_module || ($timestamp > time ())) { - $temp_graph_values[$timestamp_short] = 0; + if ($flash_charts) { + if ($labels[$agent_module_id] != '') + $module_name_list[$i] = '' . + $labels[$agent_module_id] . ''; + else + $module_name_list[$i] = '' . + $alias . ' / ' . $module_name . ''; } else { - $temp_graph_values[$timestamp_short] = $last_known * $weight_list[$i]; + if ($labels[$agent_module_id] != '') + $module_name_list[$i] = $labels[$agent_module_id]; + else + $module_name_list[$i] = $alias . ' / ' . $module_name; } } - //Extract max, min, avg - if ($max < $temp_graph_values[$timestamp_short]) { - $max = $temp_graph_values[$timestamp_short]; + // Data iterator + $j = 0; + + // Event iterator + $k = 0; + + // Set initial conditions + + //$graph_values[$i] = array(); + $temp_graph_values = array(); + + if ($data[0]['utimestamp'] == $datelimit) { + $previous_data = $data[0]['datos']; + $j++; + } + else { + $previous_data = 0; } - if (isset($min)) { - if ($min > $temp_graph_values[$timestamp_short]) { + $max = 0; + $min = null; + $avg = 0; + $countAvg = 0; + + // Calculate chart data + $last_known = $previous_data; + for ($l = 0; $l <= $resolution; $l++) { + $countAvg ++; + + $timestamp = $datelimit + ($interval * $l); + $timestamp_short = graph_get_formatted_date($timestamp, $time_format, $time_format_2); + + $long_index[$timestamp_short] = date( + html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); + //$timestamp = $timestamp_short; + + $total = 0; + $count = 0; + + // Read data that falls in the current interval + $interval_min = $last_known; + $interval_max = $last_known; + + while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) { + if ($data[$j]['datos'] > $interval_max) { + $interval_max = $data[$j]['datos']; + } + else if ($data[$j]['datos'] < $interval_max) { + $interval_min = $data[$j]['datos']; + } + $total += $data[$j]['datos']; + $last_known = $data[$j]['datos']; + $count++; + $j++; + } + + // Average + if ($count > 0) { + $total /= $count; + } + + // Read events and alerts that fall in the current interval + $event_value = 0; + $alert_value = 0; + while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) { + if ($show_events == 1) { + $event_value++; + } + if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') { + $alert_value++; + } + $k++; + } + + // Data + if ($count > 0) { + //$graph_values[$i][$timestamp] = $total * $weight_list[$i]; + $temp_graph_values[$timestamp_short] = $total * $weight_list[$i]; + } + else { + // Compressed data + if ($uncompressed_module || ($timestamp > time ())) { + $temp_graph_values[$timestamp_short] = 0; + } + else { + $temp_graph_values[$timestamp_short] = $last_known * $weight_list[$i]; + } + } + + //Extract max, min, avg + if ($max < $temp_graph_values[$timestamp_short]) { + $max = $temp_graph_values[$timestamp_short]; + } + + if (isset($min)) { + if ($min > $temp_graph_values[$timestamp_short]) { + $min = $temp_graph_values[$timestamp_short]; + } + } + else { $min = $temp_graph_values[$timestamp_short]; } + $avg += $temp_graph_values[$timestamp_short]; + + // Added to support projection graphs + if ($projection != false and $i != 0) { + $projection_data = array(); + $projection_data = array_merge($before_projection, $projection); + $graph_values[$i] = $projection_data; + } + else { + $graph_values[$i] = $temp_graph_values; + } + } + + //Add the max, min and avg in the legend + $avg = round($avg / $countAvg, 1); + + $graph_stats = get_graph_statistics($graph_values[$i]); + + if (!isset($config["short_module_graph_data"])) + $config["short_module_graph_data"] = true; + + if ($config["short_module_graph_data"]) { + $min = $graph_stats['min']; + $max = $graph_stats['max']; + $avg = $graph_stats['avg']; + $last = $graph_stats['last']; + + if ($min > 1000000) + $min = sprintf("%sM", remove_right_zeros(number_format($min / 1000000, remove_right_zeros))); + else if ($min > 1000) + $min = sprintf("%sK", remove_right_zeros(number_format($min / 1000, $config['graph_precision']))); + + if ($max > 1000000) + $max = sprintf("%sM", remove_right_zeros(number_format($max / 1000000, $config['graph_precision']))); + else if ($max > 1000) + $max = sprintf("%sK", remove_right_zeros(number_format($max / 1000, $config['graph_precision']))); + + if ($avg > 1000000) + $avg = sprintf("%sM", remove_right_zeros(number_format($avg / 1000000, $config['graph_precision']))); + else if ($avg > 1000) + $avg = sprintf("%sK", remove_right_zeros(number_format($avg / 1000, $config['graph_precision']))); + + if ($last > 1000000) + $last = sprintf("%sM", remove_right_zeros(number_format($last / 1000000, $config['graph_precision']))); + else if ($last > 1000) + $last = sprintf("%sK", remove_right_zeros(number_format($last / 1000, $config['graph_precision']))); } else { - $min = $temp_graph_values[$timestamp_short]; + $min = remove_right_zeros(number_format($graph_stats['min'], $config['graph_precision'])); + $max = remove_right_zeros(number_format($graph_stats['max'], $config['graph_precision'])); + $avg = remove_right_zeros(number_format($graph_stats['avg'], $config['graph_precision'])); + $last = remove_right_zeros(number_format($graph_stats['last'], $config['graph_precision'])); } - $avg += $temp_graph_values[$timestamp_short]; - // Added to support projection graphs - if ($projection != false and $i != 0) { - $projection_data = array(); - $projection_data = array_merge($before_projection, $projection); - $graph_values[$i] = $projection_data; + + if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) { + $unit = $unit_list[$i]; } - else { - $graph_values[$i] = $temp_graph_values; + + if ($projection == false or ($projection != false and $i == 0)) { + $module_name_list[$i] .= ": "; + if ($show_max) + $module_name_list[$i] .= __("Max") . ": $max $unit; "; + if ($show_min) + $module_name_list[$i] .= __("Min") . ": $min $unit; "; + if ($show_avg) + $module_name_list[$i] .= __("Avg") . ": $avg $unit"; + } + + if ($weight_list[$i] != 1) { + //$module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; + $module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; + } + + //$graph_values[$module_name_list[$i]] = $graph_values[$i]; + //unset($graph_values[$i]); + + //$graph_values[$i] = $graph_values[$i]; + + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[0])) { + metaconsole_restore_db(); + } } } - //Add the max, min and avg in the legend - $avg = round($avg / $countAvg, 1); + $temp = array(); - $graph_stats = get_graph_statistics($graph_values[$i]); + if ($flash_charts === false && $stacked == CUSTOM_GRAPH_GAUGE) + $stacked = CUSTOM_GRAPH_BULLET_CHART; - if (!isset($config["short_module_graph_data"])) - $config["short_module_graph_data"] = true; - - if ($config["short_module_graph_data"]) { - $min = $graph_stats['min']; - $max = $graph_stats['max']; - $avg = $graph_stats['avg']; - $last = $graph_stats['last']; - - if ($min > 1000000) - $min = sprintf("%sM", remove_right_zeros(number_format($min / 1000000, remove_right_zeros))); - else if ($min > 1000) - $min = sprintf("%sK", remove_right_zeros(number_format($min / 1000, $config['graph_precision']))); - - if ($max > 1000000) - $max = sprintf("%sM", remove_right_zeros(number_format($max / 1000000, $config['graph_precision']))); - else if ($max > 1000) - $max = sprintf("%sK", remove_right_zeros(number_format($max / 1000, $config['graph_precision']))); - - if ($avg > 1000000) - $avg = sprintf("%sM", remove_right_zeros(number_format($avg / 1000000, $config['graph_precision']))); - else if ($avg > 1000) - $avg = sprintf("%sK", remove_right_zeros(number_format($avg / 1000, $config['graph_precision']))); - - if ($last > 1000000) - $last = sprintf("%sM", remove_right_zeros(number_format($last / 1000000, $config['graph_precision']))); - else if ($last > 1000) - $last = sprintf("%sK", remove_right_zeros(number_format($last / 1000, $config['graph_precision']))); - } - else { - $min = remove_right_zeros(number_format($graph_stats['min'], $config['graph_precision'])); - $max = remove_right_zeros(number_format($graph_stats['max'], $config['graph_precision'])); - $avg = remove_right_zeros(number_format($graph_stats['avg'], $config['graph_precision'])); - $last = remove_right_zeros(number_format($graph_stats['last'], $config['graph_precision'])); - } - - - if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) { - $unit = $unit_list[$i]; - } - - if ($projection == false or ($projection != false and $i == 0)) { - $module_name_list[$i] .= ": "; - if ($show_max) - $module_name_list[$i] .= __("Max") . ": $max $unit; "; - if ($show_min) - $module_name_list[$i] .= __("Min") . ": $min $unit; "; - if ($show_avg) - $module_name_list[$i] .= __("Avg") . ": $avg $unit"; - } - - if ($weight_list[$i] != 1) { - //$module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; - $module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; - } - - //$graph_values[$module_name_list[$i]] = $graph_values[$i]; - //unset($graph_values[$i]); - - //$graph_values[$i] = $graph_values[$i]; - - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } - } - } - - $temp = array(); - - if ($flash_charts === false && $stacked == CUSTOM_GRAPH_GAUGE) - $stacked = CUSTOM_GRAPH_BULLET_CHART; - - switch ($stacked) { - case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD: - case CUSTOM_GRAPH_BULLET_CHART: - $datelimit = $date - $period; - if($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ - $acumulador = 0; + switch ($stacked) { + case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD: + case CUSTOM_GRAPH_BULLET_CHART: + $datelimit = $date - $period; + if($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $acumulador = 0; + foreach ($module_list as $module_item) { + $module = $module_item; + $query_last_value = sprintf(' + SELECT datos + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp < %d + ORDER BY utimestamp DESC', + $module, $date); + $temp_data = db_get_value_sql($query_last_value); + if ($acumulador < $temp_data){ + $acumulador = $temp_data; + } + } + } foreach ($module_list as $module_item) { - $module = $module_item; + $automatic_custom_graph_meta = false; + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[$i])) { + $server = metaconsole_get_connection_by_id ($module_item['server']); + metaconsole_connect($server); + $automatic_custom_graph_meta = true; + } + } + + if ($automatic_custom_graph_meta) + $module = $module_item['module']; + else + $module = $module_item; + + $search_in_history_db = db_search_in_history_db($datelimit); + + $temp[$module] = modules_get_agentmodule($module); $query_last_value = sprintf(' SELECT datos FROM tagente_datos @@ -1567,295 +1578,300 @@ function graphic_combined_module ($module_list, $weight_list, $period, ORDER BY utimestamp DESC', $module, $date); $temp_data = db_get_value_sql($query_last_value); - if ($acumulador < $temp_data){ - $acumulador = $temp_data; + + if ($temp_data) { + if (is_numeric($temp_data)) + $value = $temp_data; + else + $value = count($value); } - } - } - foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id ($module_item['server']); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; + else { + if ($flash_charts === false) + $value = 0; + else + $value = false; } - } - - if ($automatic_custom_graph_meta) - $module = $module_item['module']; - else - $module = $module_item; - - $search_in_history_db = db_search_in_history_db($datelimit); - - $temp[$module] = modules_get_agentmodule($module); - $query_last_value = sprintf(' - SELECT datos - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp < %d - ORDER BY utimestamp DESC', - $module, $date); - $temp_data = db_get_value_sql($query_last_value); - - if ($temp_data) { - if (is_numeric($temp_data)) - $value = $temp_data; - else - $value = count($value); - } - else { - if ($flash_charts === false) - $value = 0; - else - $value = false; - } - - if ( !empty($labels) && isset($labels[$module]) ){ - $label = io_safe_input($labels[$module]); - }else{ - $alias = db_get_value ("alias","tagente","id_agente",$temp[$module]['id_agente']); - $label = $alias . ': ' . $temp[$module]['nombre']; - } - - $temp[$module]['label'] = $label; - $temp[$module]['value'] = $value; - $temp_max = reporting_get_agentmodule_data_max($module,$period,$date); - if ($temp_max < 0) - $temp_max = 0; - if (isset($acumulador)){ - $temp[$module]['max'] = $acumulador; - }else{ - $temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max; - } + if ( !empty($labels) && isset($labels[$module]) ){ + $label = io_safe_input($labels[$module]); + }else{ + $alias = db_get_value ("alias","tagente","id_agente",$temp[$module]['id_agente']); + $label = $alias . ': ' . $temp[$module]['nombre']; + } + + + $temp[$module]['label'] = $label; + $temp[$module]['value'] = $value; + $temp_max = reporting_get_agentmodule_data_max($module,$period,$date); + if ($temp_max < 0) + $temp_max = 0; + if (isset($acumulador)){ + $temp[$module]['max'] = $acumulador; + }else{ + $temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max; + } - $temp_min = reporting_get_agentmodule_data_min($module,$period,$date); - if ($temp_min < 0) - $temp_min = 0; - $temp[$module]['min'] = ($temp_min === false) ? 0 : $temp_min; - - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } - } - - } - - break; - case CUSTOM_GRAPH_HBARS: - case CUSTOM_GRAPH_VBARS: - $datelimit = $date - $period; - - $label = ''; - foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id ($module_item['server']); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta) - $module = $module_item['module']; - else - $module = $module_item; - - - $module_data = modules_get_agentmodule($module); - $query_last_value = sprintf(' - SELECT datos - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp < %d - ORDER BY utimestamp DESC', - $module, $date); - $temp_data = db_get_value_sql($query_last_value); - - $agent_name = io_safe_output( - modules_get_agentmodule_agent_name ($module)); - - if (!empty($labels) && isset($labels[$module]) ){ - $label = $labels[$module]; - }else { - $alias = db_get_value ("alias","tagente","id_agente",$module_data['id_agente']); - $label = $alias . " - " .$module_data['nombre']; - } + $temp_min = reporting_get_agentmodule_data_min($module,$period,$date); + if ($temp_min < 0) + $temp_min = 0; + $temp[$module]['min'] = ($temp_min === false) ? 0 : $temp_min; - $temp[$label]['g'] = round($temp_data,4); - - - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } - } - - } - break; - case CUSTOM_GRAPH_PIE: - $datelimit = $date - $period; - $total_modules = 0; - foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id ($module_item['server']); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta) - $module = $module_item['module']; - else - $module = $module_item; - - $data_module = modules_get_agentmodule($module); - $query_last_value = sprintf(' - SELECT datos - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp > %d - AND utimestamp < %d - ORDER BY utimestamp DESC', - $module, $datelimit, $date); - $temp_data = db_get_value_sql($query_last_value); - - if ( $temp_data ){ - if (is_numeric($temp_data)) - $value = $temp_data; - else - $value = count($value); - } - else { - $value = false; - } - $total_modules += $value; - - if ( !empty($labels) && isset($labels[$module]) ){ - $label = io_safe_output($labels[$module]); - }else { - $alias = db_get_value ("alias","tagente","id_agente",$data_module['id_agente']); - $label = io_safe_output($alias . ": " . $data_module['nombre']); - } - - $temp[$label] = array('value'=>$value, - 'unit'=>$data_module['unit']); - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } - } - } - $temp['total_modules'] = $total_modules; - - break; - case CUSTOM_GRAPH_GAUGE: - $datelimit = $date - $period; - $i = 0; - foreach ($module_list as $module_item) { - $automatic_custom_graph_meta = false; - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id ($module_item['server']); - metaconsole_connect($server); - $automatic_custom_graph_meta = true; - } - } - - if ($automatic_custom_graph_meta) - $module = $module_item['module']; - else - $module = $module_item; - - $temp[$module] = modules_get_agentmodule($module); - $query_last_value = sprintf(' - SELECT datos - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp < %d - ORDER BY utimestamp DESC', - $module, $date); - $temp_data = db_get_value_sql($query_last_value); - if ( $temp_data ) { - if (is_numeric($temp_data)) - $value = $temp_data; - else - $value = count($value); - } - else { - $value = false; - } - $temp[$module]['label'] = ($labels[$module] != '') ? $labels[$module] : $temp[$module]['nombre']; - - $temp[$module]['value'] = $value; - $temp[$module]['label'] = ui_print_truncate_text($temp[$module]['label'],"module_small",false,true,false,".."); - - if ($temp[$module]['unit'] == '%') { - $temp[$module]['min'] = 0; - $temp[$module]['max'] = 100; - } - else { - $min = $temp[$module]['min']; - if ($temp[$module]['max'] == 0) - $max = reporting_get_agentmodule_data_max($module,$period,$date); - else - $max = $temp[$module]['max']; - $temp[$module]['min'] = ($min == 0 ) ? 0 : $min; - $temp[$module]['max'] = ($max == 0 ) ? 100 : $max; - } - $temp[$module]['gauge'] = uniqid('gauge_'); - - if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole - if (is_array($module_list[0])) { - metaconsole_restore_db(); - } - } - $i++; - } - break; - default: - if (!is_null($percentil) && $percentil) { - foreach ($graph_values as $graph_group => $point) { - foreach ($point as $timestamp_point => $point_value) { - $temp[$timestamp_point][$graph_group] = $point_value; + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[0])) { + metaconsole_restore_db(); + } } - $percentile_value = get_percentile($config['percentil'], $point); - $percentil_result[$graph_group] = array_fill ( 0, count($point), $percentile_value); - $series_type[$graph_group] = 'line'; + } + + break; + case CUSTOM_GRAPH_HBARS: + case CUSTOM_GRAPH_VBARS: + $datelimit = $date - $period; + + $label = ''; + foreach ($module_list as $module_item) { + $automatic_custom_graph_meta = false; + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[$i])) { + $server = metaconsole_get_connection_by_id ($module_item['server']); + metaconsole_connect($server); + $automatic_custom_graph_meta = true; + } + } + + if ($automatic_custom_graph_meta) + $module = $module_item['module']; + else + $module = $module_item; + + + $module_data = modules_get_agentmodule($module); + $query_last_value = sprintf(' + SELECT datos + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp < %d + ORDER BY utimestamp DESC', + $module, $date); + $temp_data = db_get_value_sql($query_last_value); + $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias ($module_list[$graph_group])); - $module_name = io_safe_output( - modules_get_agentmodule_name ($module_list[$graph_group])); - $module_name_list['percentil'.$graph_group] = __('Percentile %dº', $config['percentil']) . __(' of module ') . $agent_name .' / ' . $module_name . ' (' . $percentile_value . ' ' . $unit . ') '; + modules_get_agentmodule_agent_name ($module)); + + if (!empty($labels) && isset($labels[$module]) ){ + $label = $labels[$module]; + }else { + $alias = db_get_value ("alias","tagente","id_agente",$module_data['id_agente']); + $label = $alias . " - " .$module_data['nombre']; + } + + $temp[$label]['g'] = round($temp_data,4); + + + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[0])) { + metaconsole_restore_db(); + } + } + } - } - else { - foreach ($graph_values as $graph_group => $point) { - foreach ($point as $timestamp_point => $point_value) { - $temp[$timestamp_point][$graph_group] = $point_value; + break; + case CUSTOM_GRAPH_PIE: + $datelimit = $date - $period; + $total_modules = 0; + foreach ($module_list as $module_item) { + $automatic_custom_graph_meta = false; + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[$i])) { + $server = metaconsole_get_connection_by_id ($module_item['server']); + metaconsole_connect($server); + $automatic_custom_graph_meta = true; + } + } + + if ($automatic_custom_graph_meta) + $module = $module_item['module']; + else + $module = $module_item; + + $data_module = modules_get_agentmodule($module); + $query_last_value = sprintf(' + SELECT datos + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp > %d + AND utimestamp < %d + ORDER BY utimestamp DESC', + $module, $datelimit, $date); + $temp_data = db_get_value_sql($query_last_value); + + if ( $temp_data ){ + if (is_numeric($temp_data)) + $value = $temp_data; + else + $value = count($value); + } + else { + $value = false; + } + $total_modules += $value; + + if ( !empty($labels) && isset($labels[$module]) ){ + $label = io_safe_output($labels[$module]); + }else { + $alias = db_get_value ("alias","tagente","id_agente",$data_module['id_agente']); + $label = io_safe_output($alias . ": " . $data_module['nombre']); + } + + $temp[$label] = array('value'=>$value, + 'unit'=>$data_module['unit']); + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[0])) { + metaconsole_restore_db(); + } } } + $temp['total_modules'] = $total_modules; + + break; + case CUSTOM_GRAPH_GAUGE: + $datelimit = $date - $period; + $i = 0; + foreach ($module_list as $module_item) { + $automatic_custom_graph_meta = false; + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[$i])) { + $server = metaconsole_get_connection_by_id ($module_item['server']); + metaconsole_connect($server); + $automatic_custom_graph_meta = true; + } + } + + if ($automatic_custom_graph_meta) + $module = $module_item['module']; + else + $module = $module_item; + + $temp[$module] = modules_get_agentmodule($module); + $query_last_value = sprintf(' + SELECT datos + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp < %d + ORDER BY utimestamp DESC', + $module, $date); + $temp_data = db_get_value_sql($query_last_value); + if ( $temp_data ) { + if (is_numeric($temp_data)) + $value = $temp_data; + else + $value = count($value); + } + else { + $value = false; + } + $temp[$module]['label'] = ($labels[$module] != '') ? $labels[$module] : $temp[$module]['nombre']; + + $temp[$module]['value'] = $value; + $temp[$module]['label'] = ui_print_truncate_text($temp[$module]['label'],"module_small",false,true,false,".."); + + if ($temp[$module]['unit'] == '%') { + $temp[$module]['min'] = 0; + $temp[$module]['max'] = 100; + } + else { + $min = $temp[$module]['min']; + if ($temp[$module]['max'] == 0) + $max = reporting_get_agentmodule_data_max($module,$period,$date); + else + $max = $temp[$module]['max']; + $temp[$module]['min'] = ($min == 0 ) ? 0 : $min; + $temp[$module]['max'] = ($max == 0 ) ? 100 : $max; + } + $temp[$module]['gauge'] = uniqid('gauge_'); + + if ($config['metaconsole']) { + // Automatic custom graph from the report template in metaconsole + if (is_array($module_list[0])) { + metaconsole_restore_db(); + } + } + $i++; + } + break; + default: + if (!is_null($percentil) && $percentil) { + foreach ($graph_values as $graph_group => $point) { + foreach ($point as $timestamp_point => $point_value) { + $temp[$timestamp_point][$graph_group] = $point_value; + } + + $percentile_value = get_percentile($config['percentil'], $point); + $percentil_result[$graph_group] = array_fill ( 0, count($point), $percentile_value); + $series_type[$graph_group] = 'line'; + $agent_name = io_safe_output( + modules_get_agentmodule_agent_alias ($module_list[$graph_group])); + $module_name = io_safe_output( + modules_get_agentmodule_name ($module_list[$graph_group])); + $module_name_list['percentil'.$graph_group] = __('Percentile %dº', $config['percentil']) . __(' of module ') . $agent_name .' / ' . $module_name . ' (' . $percentile_value . ' ' . $unit . ') '; + } + } + else { + foreach ($graph_values as $graph_group => $point) { + foreach ($point as $timestamp_point => $point_value) { + $temp[$timestamp_point][$graph_group] = $point_value; + } + } + } + break; + } + } + else{ + $flash_charts = true; + if($ttl>1 || !$config['flash_charts']){ + $flash_charts = false; + } + + $temp = fullscale_data_combined($module_list, $period, $date, $flash_charts); + + $resolution = count($temp); //Number of points of the graph + $interval = (int) ($period / $resolution); + $module_name_list = array(); + + if($ttl>1 || !$config['flash_charts']){ + $temp2 = array(); + foreach ($temp as $key => $value) { + $real_date = date("Y/M/d", $key); + $real_date .= "\n"; + $real_date .= date(" H:i:s", $key); + $temp2[$real_date] = $value; } - break; + $temp = $temp2; + } + + foreach ($module_list as $key => $value) { + $agent_name = io_safe_output( modules_get_agentmodule_agent_name ($value) ); + $alias = db_get_value ("alias","tagente","nombre",$agent_name); + $module_name = io_safe_output( modules_get_agentmodule_name ($value) ); + + if ($flash_charts){ + $module_name_list[$key] = '' . $alias . " / " . $module_name. ''; + } + else{ + $module_name_list[$key] = $alias . " / " . $module_name; + } + } } $graph_values = $temp; - + if($config["fixed_graph"] == false){ $water_mark = array( 'file' => $config['homedir'] . "/images/logo_vertical_water.png", @@ -2103,6 +2119,47 @@ function graphic_combined_module ($module_list, $weight_list, $period, } } +function fullscale_data_combined($module_list, $period, $date, $flash_charts){ + + // Set variables + if ($date == 0){ + $date = get_system_time(); + } + + $datelimit = $date - $period; + + foreach ($module_list as $key_module => $value_module) { + $data_uncompress = db_uncompress_module_data($value_module, $datelimit, $date); + foreach ($data_uncompress as $key_data => $value_data) { + foreach ($value_data['data'] as $k => $v) { + if($flash_charts) { + $real_date = date("Y M d H:i:s", $v['utimestamp']); + } + else{ + $real_date = $v['utimestamp']; + } + $data_all[$real_date][$key_module] = $v['datos']; + } + } + } + + $data_prev = array(); + + ksort($data_all); + foreach ($data_all as $key => $value) { + foreach ($module_list as $key_module => $value_module) { + if(!isset($value[$key_module])){ + $data_all[$key][$key_module] = $data_prev[$key_module]; + } + else{ + $data_prev[$key_module] = $value[$key_module]; + } + } + } + + return $data_all; +} + /** * Print a graph with access data of agents * @@ -3793,7 +3850,7 @@ function fs_error_image ($width = 300, $height = 110) { function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only = 0, $date = 0, $series_suffix = '', $series_suffix_str = '', $show_unknown = false, - $fullscale = false) { + $fullscale = false, $flash_chart = true) { global $config; global $chart; @@ -3850,75 +3907,15 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } if ($fullscale) { - // Get module data - $events = db_get_all_rows_filter('tevento', - array ('id_agentmodule' => $agent_module_id, - "utimestamp > $datelimit", - "utimestamp < $date", - 'order' => 'utimestamp ASC'), - array ('evento', 'utimestamp', 'event_type', 'id_evento')); - - $table = "tagente_datos"; - $module_type_str = modules_get_type_name ($agent_module_id); - if (strstr ($module_type_str, 'string') !== false) { - $table = "tagente_datos_string"; - } - - $query = " SELECT utimestamp, datos FROM $table "; - $query .= " WHERE id_agente_modulo=$agent_module_id "; - $query .= " ORDER BY utimestamp ASC LIMIT 1"; - - $ret = db_get_all_rows_sql( $query , true); - - $first_data = $ret[0]['utimestamp']; - /* - // Get the last event after inverval to know if graph start on unknown - $prev_event = db_get_row_filter ('tevento', - array ('id_agentmodule' => $agent_module_id, - "utimestamp <= $datelimit", - 'order' => 'utimestamp DESC')); - if (isset($prev_event['event_type']) && $prev_event['event_type'] == 'going_unknown') { - $start_unknown = true; - } - */ - if ($events === false) { - $events = array (); - } - - $data_uncompress = db_uncompress_module_data($agent_module_id, $datelimit, $date); - - $i = 0; - $data = array(); - if(is_array($data_uncompress)){ - foreach ($data_uncompress as $value) { - foreach ($value['data'] as $key => $value) { - $data[$i]['datos'] = $value['datos']; - if(empty($value['datos'])){ - if($value['utimestamp'] < $first_data){ - $data[$i]['unknown'] = 0; - $data[$i]['not_init'] = 1; - $data[$i]['utimestamp'] = $value['utimestamp']; - } - else{ - $data[$i]['not_init'] = 0; - $data[$i]['unknown'] = 1; - $data[$i]['utimestamp'] = $value['utimestamp']; - } - } - else{ - $data[$i]['not_init'] = 0; - $data[$i]['unknown'] = 0; - } - $data[$i]['utimestamp'] = $value['utimestamp']; - $i++; - } - } - } - - if (count($data) > $resolution) { - $resolution = count($data); //Number of points of the graph + fullscale_data( $chart, $chart_data_extra, $long_index, $series_type, + $agent_module_id, $datelimit, $date, $events, + $show_events, $show_unknown, $show_alerts, + $series_suffix, $percentil, $flash_chart); + if (count($chart) > $resolution) { + $resolution = count($chart); //Number of points of the graph $interval = (int) ($period / $resolution); } + $max_value=1; } else { // Get module data @@ -3928,241 +3925,241 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, "utimestamp < $date", 'order' => 'utimestamp ASC'), array ('datos', 'utimestamp'), 'AND', $search_in_history_db); - } - if ($data === false) { - $data = array (); - } - // Uncompressed module data - if ($uncompressed_module) { - $min_necessary = 1; - - // Compressed module data - } - else { - // Get previous data - $previous_data = modules_get_previous_data ($agent_module_id, $datelimit); - if ($previous_data !== false) { - $previous_data['utimestamp'] = $datelimit; - array_unshift ($data, $previous_data); + if ($data === false) { + $data = array (); } - // Get next data - $nextData = modules_get_next_data ($agent_module_id, $date); - if ($nextData !== false) { - array_push ($data, $nextData); + // Uncompressed module data + if ($uncompressed_module) { + $min_necessary = 1; + + // Compressed module data } - else if (count ($data) > 0) { - // Propagate the last known data to the end of the interval - $nextData = array_pop ($data); - array_push ($data, $nextData); - $nextData['utimestamp'] = $date; - array_push ($data, $nextData); + else { + // Get previous data + $previous_data = modules_get_previous_data ($agent_module_id, $datelimit); + if ($previous_data !== false) { + $previous_data['utimestamp'] = $datelimit; + array_unshift ($data, $previous_data); + } + + // Get next data + $nextData = modules_get_next_data ($agent_module_id, $date); + if ($nextData !== false) { + array_push ($data, $nextData); + } + else if (count ($data) > 0) { + // Propagate the last known data to the end of the interval + $nextData = array_pop ($data); + array_push ($data, $nextData); + $nextData['utimestamp'] = $date; + array_push ($data, $nextData); + } + + $min_necessary = 2; } - $min_necessary = 2; - } - - // Check available data - if (count ($data) < $min_necessary) { - if (!$graphic_type) { - return fs_error_image (); + // Check available data + if (count ($data) < $min_necessary) { + if (!$graphic_type) { + return fs_error_image (); + } + graphic_error (); + } + + + + // Data iterator + $j = 0; + + // Event iterator + $k = 0; + + // Set initial conditions + if ($data[0]['utimestamp'] == $datelimit) { + $previous_data = $data[0]['datos']; + $j++; + } + else { + $previous_data = 0; + } + + $max_value = 0; + + // Calculate chart data + $last_known = $previous_data; + for ($i = 0; $i <= $resolution; $i++) { + $timestamp = $datelimit + ($interval * $i); + + /* + if ($fullscale && ($resolution > ($config['graph_res'] * 50))) { + $timestamp = $data[$i]['utimestamp']; + } + */ + $zero = 0; + $total = 0; + $count = 0; + $is_unknown = false; + // Read data that falls in the current interval + while (isset ($data[$j]) && + $data[$j]['utimestamp'] >= $timestamp && + $data[$j]['utimestamp'] <= ($timestamp + $interval)) { + if ($data[$j]['datos'] == 0) { + $zero = 1; + } + else { + $total += $data[$j]['datos']; + $count++; + } + + $last_known = $data[$j]['datos']; + + if ($show_unknown && $data[$j]['unknown']){ + $is_unknown = true; + } + $j++; + } + + // Average + if ($count > 0) { + $total /= $count; + } + + // Read events and alerts that fall in the current interval + $event_value = 0; + $alert_value = 0; + $unknown_value = 0; + + // Is the first point of a unknown interval + $first_unknown = false; + + $event_ids = array(); + $alert_ids = array(); + while (isset ($events[$k]) && + $events[$k]['utimestamp'] >= $timestamp && + $events[$k]['utimestamp'] < ($timestamp + $interval)) { + if ($show_events == 1) { + $event_value++; + $event_ids[] = $events[$k]['id_evento']; + } + if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') { + $alert_value++; + $alert_ids[] = $events[$k]['id_evento']; + } + if ($show_unknown) { + if ($events[$k]['event_type'] == 'going_unknown') { + if ($is_unknown == false) { + $first_unknown = true; + } + $is_unknown = true; + } + else if (substr ($events[$k]['event_type'], 0, 5) == 'going') { + $is_unknown = false; + } + } + $k++; + } + + // In some cases, can be marked as known because a recovery event + // was found in same interval. For this cases first_unknown is + // checked too + if ($is_unknown || $first_unknown) { + $unknown_value++; + } + + // Set the title and time format + if ($period <= SECONDS_6HOURS) { + $time_format = 'H:i:s'; + } + elseif ($period < SECONDS_1DAY) { + $time_format = 'H:i'; + } + elseif ($period < SECONDS_15DAYS) { + $time_format = 'M d H:i'; + } + elseif ($period < SECONDS_1MONTH) { + $time_format = 'M d H\h'; + } + else { + $time_format = 'M d H\h'; + } + + $timestamp_short = date($time_format, $timestamp); + $long_index[$timestamp_short] = date( + html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); + if (!$fullscale) { + $timestamp = $timestamp_short; + } + ///////////////////////////////////////////////////////////////// + + if ($total > $max_value) { + $max_value = $total; + } + + if ($show_events) { + if (!isset($chart[$timestamp]['event'.$series_suffix])) { + $chart[$timestamp]['event'.$series_suffix] = 0; + } + + $chart[$timestamp]['event'.$series_suffix] += $event_value; + $series_type['event'.$series_suffix] = 'points'; + } + if ($show_alerts) { + if (!isset($chart[$timestamp]['alert'.$series_suffix])) { + $chart[$timestamp]['alert'.$series_suffix] = 0; + } + + $chart[$timestamp]['alert'.$series_suffix] += $alert_value; + $series_type['alert'.$series_suffix] = 'points'; + } + + // Data and zeroes (draw a step) + if ($zero == 1 && $count > 0) { + $chart[$timestamp]['sum'.$series_suffix] = 0; + } + else if ($zero == 1) { // Just zeros + $chart[$timestamp]['sum'.$series_suffix] = 0; + } + else if ($count > 0) { // No zeros + $chart[$timestamp]['sum'.$series_suffix] = $total; + } + else { // Compressed data + if ($uncompressed_module || ($timestamp > time ()) || $is_unknown) { + $chart[$timestamp]['sum'.$series_suffix] = 0; + } + else { + $chart[$timestamp]['sum'.$series_suffix] = $last_known; + } + } + + if ($show_unknown) { + if (!isset($chart[$timestamp]['unknown'.$series_suffix])) { + $chart[$timestamp]['unknown'.$series_suffix] = 0; + } + $chart[$timestamp]['unknown'.$series_suffix] = $unknown_value; + $series_type['unknown'.$series_suffix] = 'area'; + } + + $series_type['sum' . $series_suffix] = 'boolean'; + + if (!empty($event_ids)) { + $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); + } + if (!empty($alert_ids)) { + $chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids); + } + } - graphic_error (); } - + if (empty($unit_name)) { $unit = modules_get_unit($agent_module_id); } else $unit = $unit_name; - - // Data iterator - $j = 0; - - // Event iterator - $k = 0; - - // Set initial conditions - if ($data[0]['utimestamp'] == $datelimit) { - $previous_data = $data[0]['datos']; - $j++; - } - else { - $previous_data = 0; - } - - $max_value = 0; - - // Calculate chart data - $last_known = $previous_data; - for ($i = 0; $i <= $resolution; $i++) { - $timestamp = $datelimit + ($interval * $i); - if ($fullscale && ($resolution > ($config['graph_res'] * 50))) { - $timestamp = $data[$i]['utimestamp']; - } - - $zero = 0; - $total = 0; - $count = 0; - $is_unknown = false; - // Read data that falls in the current interval - while (isset ($data[$j]) && - $data[$j]['utimestamp'] >= $timestamp && - $data[$j]['utimestamp'] <= ($timestamp + $interval)) { - if ($data[$j]['datos'] == 0) { - $zero = 1; - } - else { - $total += $data[$j]['datos']; - $count++; - } - - $last_known = $data[$j]['datos']; - - if ($show_unknown && $data[$j]['unknown']){ - $is_unknown = true; - } - $j++; - } - - // Average - if ($count > 0) { - $total /= $count; - } - - // Read events and alerts that fall in the current interval - $event_value = 0; - $alert_value = 0; - $unknown_value = 0; - - // Is the first point of a unknown interval - $first_unknown = false; - - $event_ids = array(); - $alert_ids = array(); - while (isset ($events[$k]) && - $events[$k]['utimestamp'] >= $timestamp && - $events[$k]['utimestamp'] < ($timestamp + $interval)) { - if ($show_events == 1) { - $event_value++; - $event_ids[] = $events[$k]['id_evento']; - } - if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') { - $alert_value++; - $alert_ids[] = $events[$k]['id_evento']; - } - if ($show_unknown) { - if ($events[$k]['event_type'] == 'going_unknown') { - if ($is_unknown == false) { - $first_unknown = true; - } - $is_unknown = true; - } - else if (substr ($events[$k]['event_type'], 0, 5) == 'going') { - $is_unknown = false; - } - } - $k++; - } - - // In some cases, can be marked as known because a recovery event - // was found in same interval. For this cases first_unknown is - // checked too - if ($is_unknown || $first_unknown) { - $unknown_value++; - } - - // Set the title and time format - if ($period <= SECONDS_6HOURS) { - $time_format = 'H:i:s'; - } - elseif ($period < SECONDS_1DAY) { - $time_format = 'H:i'; - } - elseif ($period < SECONDS_15DAYS) { - $time_format = 'M d H:i'; - } - elseif ($period < SECONDS_1MONTH) { - $time_format = 'M d H\h'; - } - else { - $time_format = 'M d H\h'; - } - - $timestamp_short = date($time_format, $timestamp); - $long_index[$timestamp_short] = date( - html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); - if (!$fullscale) { - $timestamp = $timestamp_short; - } - ///////////////////////////////////////////////////////////////// - - if ($total > $max_value) { - $max_value = $total; - } - - if ($show_events) { - if (!isset($chart[$timestamp]['event'.$series_suffix])) { - $chart[$timestamp]['event'.$series_suffix] = 0; - } - - $chart[$timestamp]['event'.$series_suffix] += $event_value; - $series_type['event'.$series_suffix] = 'points'; - } - if ($show_alerts) { - if (!isset($chart[$timestamp]['alert'.$series_suffix])) { - $chart[$timestamp]['alert'.$series_suffix] = 0; - } - - $chart[$timestamp]['alert'.$series_suffix] += $alert_value; - $series_type['alert'.$series_suffix] = 'points'; - } - - // Data and zeroes (draw a step) - if ($zero == 1 && $count > 0) { - - //New code set 0 if there is a 0 - //Please check the incident #665 - //http://192.168.50.2/integria/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=665 - $chart[$timestamp]['sum'.$series_suffix] = 0; - } - else if ($zero == 1) { // Just zeros - $chart[$timestamp]['sum'.$series_suffix] = 0; - } - else if ($count > 0) { // No zeros - $chart[$timestamp]['sum'.$series_suffix] = $total; - } - else { // Compressed data - if ($uncompressed_module || ($timestamp > time ()) || $is_unknown) { - $chart[$timestamp]['sum'.$series_suffix] = 0; - } - else { - $chart[$timestamp]['sum'.$series_suffix] = $last_known; - } - } - - if ($show_unknown) { - if (!isset($chart[$timestamp]['unknown'.$series_suffix])) { - $chart[$timestamp]['unknown'.$series_suffix] = 0; - } - $chart[$timestamp]['unknown'.$series_suffix] = $unknown_value; - $series_type['unknown'.$series_suffix] = 'area'; - } - - $series_type['sum' . $series_suffix] = 'boolean'; - - if (!empty($event_ids)) { - $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); - } - if (!empty($alert_ids)) { - $chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids); - } - - } - // Get min, max and avg (less efficient but centralized for all modules and reports) $graph_stats = get_statwin_graph_statistics($chart, $series_suffix); @@ -4186,26 +4183,27 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } /////////////////////////////////////////////////// - // Set the title and time format - if ($period <= SECONDS_6HOURS) { - $time_format = 'H:i:s'; + if(!$fullscale){ + // Set the title and time format + if ($period <= SECONDS_6HOURS) { + $time_format = 'H:i:s'; + } + elseif ($period < SECONDS_1DAY) { + $time_format = 'H:i'; + } + elseif ($period < SECONDS_15DAYS) { + $time_format = 'M d H:i'; + } + elseif ($period < SECONDS_1MONTH) { + $time_format = 'M d H\h'; + } + elseif ($period < SECONDS_6MONTHS) { + $time_format = "M d H\h"; + } + else { + $time_format = 'M d H\h'; + } } - elseif ($period < SECONDS_1DAY) { - $time_format = 'H:i'; - } - elseif ($period < SECONDS_15DAYS) { - $time_format = 'M d H:i'; - } - elseif ($period < SECONDS_1MONTH) { - $time_format = 'M d H\h'; - } - elseif ($period < SECONDS_6MONTHS) { - $time_format = "M d H\h"; - } - else { - $time_format = 'M d H\h'; - } - // Flash chart $caption = __('Max. Value').$series_suffix_str . ': ' . $graph_stats['sum']['max'] . ' ' . __('Avg. Value').$series_suffix_str . ': ' . $graph_stats['sum']['avg'] . ' ' . __('Min. Value').$series_suffix_str . ': ' . $graph_stats['sum']['min'] . ' ' . __('Units').$series_suffix_str . ': ' . $unit; @@ -4254,6 +4252,179 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } } +function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index, + $series_type, $agent_module_id, $datelimit, $date, + $events = false, $show_events = false, + $show_unknown = false, $show_alerts = false, + $series_suffix = '', $percentil = false, + $flash_chart = true ){ + + global $config; + global $max_value; + global $min_value; + global $series_type; + global $chart_extra_data; + + $ranges_unknown = db_get_module_ranges_unknown($agent_module_id, $datelimit, $date); + + $table = "tagente_datos"; + $module_type_str = modules_get_type_name ($agent_module_id); + if (strstr ($module_type_str, 'string') !== false) { + $table = "tagente_datos_string"; + } + + $query = " SELECT utimestamp, datos FROM $table "; + $query .= " WHERE id_agente_modulo=$agent_module_id "; + $query .= " ORDER BY utimestamp ASC LIMIT 1"; + + $ret = db_get_all_rows_sql( $query , true); + + $first_data = $ret[0]['utimestamp']; + $data_uncompress = db_uncompress_module_data($agent_module_id, $datelimit, $date); + $i = 0; + $max_value = 0; + $min_value = 0; + $timestamp_second = 0; + if(is_array($data_uncompress)){ + foreach ($data_uncompress as $v) { + foreach ($v['data'] as $key => $value) { + $real_date = date("Y M d H:i:s", $value['utimestamp']); + if(!$flash_chart){ + $real_date = date("Y/M/d", $value['utimestamp']); + $real_date .= "\n"; + $real_date .= date(" H:i:s", $value['utimestamp']); + } + // Read events and alerts that fall in the current interval + $event_value = 0; + $alert_value = 0; + $unknown_value = 0; + $event_i = 0; + // Is the first point of a unknown interval + $first_unknown = false; + + $event_ids = array(); + $alert_ids = array(); + + // + if($timestamp_second == 0){ + $timestamp_second = $value['utimestamp']; + } + $timestamp_first = $timestamp_second; + $timestamp_second = $value['utimestamp']; + + foreach ($events as $key => $val) { + if( $val['utimestamp'] > $timestamp_first && + $val['utimestamp'] <= $timestamp_second ){ + if ($show_events == 1) { + $event_ids[] = $val['id_evento']; + $event_value++; + } + if ($show_alerts == 1 && substr ($val['event_type'], 0, 5) == 'alert') { + $alert_ids[] = $val['id_evento']; + $alert_value++; + } + if ($show_unknown) { + if ($val['event_type'] == 'going_unknown') { + if ($is_unknown == false) { + $first_unknown = true; + } + $is_unknown = true; + } + else if (substr ($val['event_type'], 0, 5) == 'going') { + $is_unknown = false; + } + } + } + } + + if(empty($value['datos'])){ + if($value['utimestamp'] < $first_data){ + //$chart_data[$real_date]['unknown'.$series_suffix] = 0; + $is_unknown = false; + } + else{ + //$chart_data[$real_date]['unknown'.$series_suffix] = 1; + $first_unknown = true; + } + } + + $timestamp_short = date("Y M d H:i:s", $value['utimestamp']); + + if(!$flash_chart){ + $timestamp_short = date("Y/M/d", $value['utimestamp']); + $timestamp_short .= "\n"; + $timestamp_short .= date(" H:i:s", $value['utimestamp']); + } + + + $long_index[$timestamp_short] = date( + html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $value['utimestamp']); + // In some cases, can be marked as known because a recovery event + // was found in same interval. For this cases first_unknown is + // checked too + if ($is_unknown || $first_unknown) { + $unknown_value++; + } + + // Data + if ($show_events) { + if (!isset($chart_data[$real_date]['event'.$series_suffix])) { + $chart_data[$real_date]['event'.$series_suffix] = 0; + } + + $chart_data[$real_date]['event'.$series_suffix] += $event_value; + + $series_type['event'.$series_suffix] = 'points'; + } + + if ($show_alerts) { + if (!isset($chart_data[$real_date]['alert'.$series_suffix])) { + $chart_data[$real_date]['alert'.$series_suffix] = 0; + } + + $chart_data[$real_date]['alert'.$series_suffix] += $alert_value; + + $series_type['alert'.$series_suffix] = 'points'; + } + + $chart_data[$real_date]['sum'.$series_suffix] = $value['datos']; + + if($value['datos'] > $max_value){ + $max_value = $value['datos']; + } + + if($value['datos'] < $min_value){ + $min_value = $value['datos']; + } + + if ($show_unknown) { + if (!isset($chart_data[$real_date]['unknown'.$series_suffix])) { + $chart_data[$real_date]['unknown'.$series_suffix] = 0; + } + $chart_data[$real_date]['unknown'.$series_suffix] = $unknown_value; + $series_type['unknown'.$series_suffix] = 'area'; + } + + if (!empty($event_ids)) { + $chart_extra_data[count($chart_data)-1]['events'] = implode(',',$event_ids); + } + if (!empty($alert_ids)) { + $chart_extra_data[count($chart_data)-1]['alerts'] = implode(',',$alert_ids); + } + } + } + + if (!is_null($percentil) && $percentil) { + $avg = array_map(function($item) { return $item['sum']; }, $chart_data); + $percentil_result = get_percentile($percentil, $avg); + //Fill the data of chart + array_walk($chart_data, function(&$item) use ($percentil_result, $series_suffix) { + $item['percentil' . $series_suffix] = $percentil_result; }); + $series_type['percentil' . $series_suffix] = 'line'; + } + } +} + function grafico_modulo_boolean ($agent_module_id, $period, $show_events, $width, $height , $title='', $unit_name, $show_alerts, $avg_only = 0, $pure=0, $date = 0, $only_image = false, $homeurl = '', $adapt_key = '', $compare = false, @@ -4285,7 +4456,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, // Build the data of the previous period grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only, $date-$period, $series_suffix, - $series_suffix_str, $show_unknown, $fullscale); + $series_suffix_str, $show_unknown, $fullscale, $flash_chart); switch ($compare) { case 'separated': // Store the chart calculated @@ -4311,28 +4482,8 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, } grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, - $unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown, $fullscale); + $unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown, $fullscale, $flash_chart); - if ($fullscale) { - if (!$flash_chart) { - $time_format = "Y M \nd H:i:s"; - } - else { - $time_format = "Y M d H:i:s"; - } - - $new_chart = array(); - $new_long_index = array(); - foreach ($chart as $c_timestamp => $c_data) { - $timestamp_short = date($time_format, $c_timestamp); - $new_long_index[$timestamp_short] = date( - html_entity_decode($time_format, ENT_QUOTES, "UTF-8"), $c_timestamp); - $new_chart[$timestamp_short] = $c_data; - } - - $long_index = $new_long_index; - $chart = $new_chart; - } if ($compare === 'overlapped') { $i = 0; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0baeb463f7..8a47d2c7d2 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -98,10 +98,13 @@ function reporting_get_name($id_report) { function reporting_make_reporting_data($report = null, $id_report, $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; + enterprise_include_once('include/functions_metaconsole.php'); + $return = array(); if (!empty($report)) { @@ -126,6 +129,8 @@ function reporting_make_reporting_data($report = null, $id_report, $metaconsole_on = is_metaconsole(); foreach ($contents as $content) { + $server_name = $content['server_name']; + if (!empty($period)) { $content['period'] = $period; } @@ -153,6 +158,7 @@ function reporting_make_reporting_data($report = null, $id_report, continue; } } + array_push ($agents_to_macro, modules_get_agentmodule_agent($graph_item['id_agent_module'])); if ($metaconsole_on) { //Restore db connection @@ -170,6 +176,10 @@ function reporting_make_reporting_data($report = null, $id_report, } $agents_to_macro = $agents_to_macro_aux; + if (!empty($report) && $from_template) { + $agents_to_macro = $content['id_agent']; + } + if(isset($content['style']['name_label'])){ //Add macros name $items_label = array(); @@ -178,7 +188,6 @@ function reporting_make_reporting_data($report = null, $id_report, $items_label['id_agent_module'] = $content['id_agent_module']; $items_label['modules'] = $modules_to_macro; $items_label['agents'] = $agents_to_macro; - $server_name = $content['server_name']; //Metaconsole connection if ($metaconsole_on && $server_name != '') { @@ -2665,6 +2674,10 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic if (empty($content['name'])) { $content['name'] = __('Network interfaces report'); } + + if (isset($content['style']['fullscale'])) { + $fullscale = (bool) $content['style']['fullscale']; + } $group_name = groups_get_name($content['id_group']); @@ -2736,7 +2749,13 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic true, true, true, - 1); + 1, + false, + false, + null, + false, + false, + $fullscale); } break; case 'data': @@ -2759,7 +2778,13 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic true, true, true, - 2); + 2, + false, + false, + null, + false, + false, + $fullscale); } break; } @@ -6025,13 +6050,15 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', if (isset($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( modules_get_agentmodule_type( $content['id_agent_module'])); - - $return['chart'] = ''; // Get chart reporting_set_conf_charts($width, $height, $only_image, $type, @@ -6105,7 +6132,8 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', ($content['style']['percentil'] == 1) ? $config['percentil'] : null, false, false, - $config['type_module_charts']); + $config['type_module_charts'], + $fullscale); } break; case 'data': @@ -10320,7 +10348,6 @@ function reporting_get_agentmodule_sla_working_timestamp ($period, $date_end, $w } function reporting_label_macro ($item, $label) { - switch ($item['type']) { case 'event_report_agent': case 'alert_report_agent': diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 22fb6dafac..8d56a42918 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3886,15 +3886,16 @@ function reporting_get_event_histogram_meta ($width) { $user_groups_ids = array_keys($user_groups); if (empty($user_groups)) { - $groups_condition = ' 1 = 0 '; + $groups_condition = ' AND 1 = 0 '; } 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")) { $groups_condition .= " AND id_grupo != 0"; } + $status_condition = " AND estado = 0 "; $cont = 0; for ($i = 0; $i < $interval; $i++) { @@ -3923,49 +3924,45 @@ function reporting_get_event_histogram_meta ($width) { $full_legend[$cont] = $name; $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'])) { - $data[$cont]['utimestamp'] = $periodtime; - switch ($event['criticity']) { - case 0: - $data[$cont]['data'] = EVENT_CRIT_MAINTENANCE; - break; - case 1: - $data[$cont]['data'] = EVENT_CRIT_INFORMATIONAL; - break; - case 2: - $data[$cont]['data'] = EVENT_CRIT_NORMAL; - break; - 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; - } + $time_condition = 'utimestamp > '.$bottom . ' AND utimestamp < '.$top; + $sql = sprintf('SELECT criticity,utimestamp + FROM tmetaconsole_event + WHERE %s %s %s + ORDER BY criticity DESC', + $time_condition, $groups_condition, $status_condition); + + $events = db_get_all_rows_sql($sql); + + $events_criticity = array(); + foreach ($events as $key => $value) { + array_push($events_criticity,$value['criticity']); } - 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]['data'] = 1; } diff --git a/pandora_console/install.php b/pandora_console/install.php index 6acecb6d2e..5a8dac339d 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
data = array(); $data = array(); $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']) { - $agent_name = "" . $agent_name . "" . ui_print_help_tip(__('Disabled'), true); + if ($in_planned_downtime) { + $agent_name = "" . $agent_name . ui_print_help_tip(__('Disabled'), true); + } + else { + $agent_name = "" . $agent_name . "" . ui_print_help_tip(__('Disabled'), true); + } } else if ($agent['quiet']) { - $agent_name = "" . $agent_name . " " . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . ""; + if ($in_planned_downtime) { + $agent_name = "" . $agent_name . " " . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")); + } + else { + $agent_name = "" . $agent_name . " " . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . ""; + } } else { $agent_name = $agent_name; } +if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) { + $agent_name .= "" . " " . ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png') . ""; +} +else if (($in_planned_downtime && !$agent['disabled']) || ($in_planned_downtime && !$agent['quiet'])) { + $agent_name .= " " . ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png') . ""; +} + if (!$config["show_group_name"]) $data[0] = ui_print_group_icon ($agent["id_grupo"], true); else diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index 8d676b4340..eadcf256ff 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -150,6 +150,7 @@ $interface_traffic_modules = array( $zoom = (int) get_parameter ("zoom", 1); $baseline = get_parameter ("baseline", 0); $show_percentil = get_parameter ("show_percentil", 0); + $fullscale = get_parameter("fullscale", 0); if ($zoom > 1) { $height = $height * ($zoom / 2.1); @@ -200,7 +201,9 @@ $interface_traffic_modules = array( false, false, (($show_percentil)? $config['percentil'] : null), - true); + true, + false, + $fullscale); echo '
'; @@ -258,6 +261,12 @@ $interface_traffic_modules = array( $data[1] = html_print_checkbox ("show_percentil", 1, (bool) $show_percentil, true); $table->data[] = $data; $table->rowclass[] =''; + + $data = array(); + $data[0] = __('Show full scale graph (TIP)') . ui_print_help_tip(__('This option may cause performance issues'), true); + $data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, true); + $table->data[] = $data; + $table->rowclass[] =''; $data = array(); $data[0] = __('Zoom factor'); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 5199f58506..a9ff8ecc1d 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -404,7 +404,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); } $data = array(); - $data[0] = __('Show full scale graph (TIP)'); + $data[0] = __('Show full scale graph (TIP)') . ui_print_help_tip(__('This option may cause performance issues'), true); $data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, true); $table->data[] = $data; $table->rowclass[] = ''; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 733e684376..ae42cf0e56 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.712 -%define release 170919 +%define release 170928 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 948cda6ed7..f9099ef48a 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.712 -%define release 170919 +%define release 170928 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 3640357a8f..0d749db694 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `custom_id` varchar(255) default '', `server_name` varchar(100) default '', `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' , `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' , diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index cc2d4081e1..7c213ab75a 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.712-170919 +Version: 7.0NG.712-170928 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 643efc757c..78e1ab34eb 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.712-170919" +pandora_version="7.0NG.712-170928" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 1891fd9cbf..d8e6ce886d 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -43,7 +43,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.712"; -my $pandora_build = "170919"; +my $pandora_build = "170928"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index a9043d3d36..e8cdfba997 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -73,26 +73,8 @@ sub new ($$;$) { my $self = $class->SUPER::new($config, DATASERVER, \&PandoraFMS::DataServer::data_producer, \&PandoraFMS::DataServer::data_consumer, $dbh); # Load external .enc files for XML::Parser. - if ($config->{'enc_dir'} ne '') { - if (opendir(my $dh, $config->{'enc_dir'})) { - while (my $enc_file = readdir($dh)) { - - # Ignore unknown files. - next unless ($enc_file =~ m/.enc$/); - - # Load the .enc file. - eval { - local $SIG{__DIE__} = {}; - XML::Parser::Expat::load_encoding($config->{'enc_dir'} . '/' . $enc_file); - }; - if ($@) { - print_message ($config, " [WARNING] Error loading encoding file: $enc_file", 1); - } - } - closedir($dh); - } else { - print_message($config, " [WARNING] Error opening directory " . $config->{'enc_dir'} . ": $!", 1); - } + if ($config->{'enc_dir'} ne '' && !grep {$_ eq $config->{'enc_dir'}} @XML::Parser::Expat::Encoding_Path) { + push(@XML::Parser::Expat::Encoding_Path, $config->{'enc_dir'}); } bless $self, $class; diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index af15614465..bc7b3a708a 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -211,6 +211,11 @@ sub pandora_snmptrapd { # Try to save as much information as possible if the trap could not be parsed $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") { ($date, $time, $source, $data) = split(/\[\*\*\]/, $line, 4); my @data = split(/\t/, $data); @@ -219,7 +224,7 @@ sub pandora_snmptrapd { $oid = shift @data; 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; } $oid =~ s/.* = OID: //; @@ -441,21 +446,32 @@ sub read_snmplogfile() return undef if (! defined($line)); + my $retry_count = 0; + # More lines ? - while($read_ahead_line = ) { + while(1) { + while($read_ahead_line = ) { - # Get current file position - $read_ahead_pos = tell(SNMPLOGFILE); + # Get current file position + $read_ahead_pos = tell(SNMPLOGFILE); - # Get out of the loop if you find another Trap - last if($read_ahead_line =~ /^SNMP/ ); + # Get out of the loop if you find another Trap + 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 - chomp($line); - $line .= "$read_ahead_line"; - $pos = $read_ahead_pos; + # Append to the line and correct the position + chomp($line); + $line .= "$read_ahead_line"; + $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. diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 4e178f4c22..3eade74fba 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.712 -%define release 170919 +%define release 170928 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 6f9fe3303c..78d7f11959 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.712 -%define release 170919 +%define release 170928 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index c195760796..00af6461bf 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.712" -PI_BUILD="170919" +PI_BUILD="170928" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index b56b5b77c4..4cc2fe1f7b 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.712 PS170919"; +my $version = "7.0NG.712 PS170928"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ea41ed6a3f..68bb830521 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.712 PS170919"; +my $version = "7.0NG.712 PS170928"; # save program name for logging my $progname = basename($0); @@ -221,7 +221,7 @@ sub help_screen{ help_screen_line('--delete_visual_console', '', 'Delete a visual console'); help_screen_line('--delete_visual_console_objects', ' ', 'Delete a visual console elements'); help_screen_line('--duplicate_visual_console', ' []', 'Duplicate a visual console'); - help_screen_line('--export_json_visual_console', ' []', 'Creates a json with the visual console elements information'); + help_screen_line('--export_json_visual_console', ' [] []', 'Creates a json with the visual console elements information'); print "\n"; @@ -4821,7 +4821,7 @@ sub cli_create_visual_console() { 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 $parent_item = 0; my $enable_link = $elem->{'enable_link'}; my $id_metaconsole = $elem->{'id_metaconsole'}; my $id_group = $elem->{'id_group'}; @@ -4855,11 +4855,11 @@ sub cli_create_visual_console() { my $number_of_elements = scalar(@$elements_in_array); - my $x_divider = 4; + my $x_divider = 8; my $y_divider = 1; for (my $i = 1; $i <= 1000; $i++) { - if (($i * 4) < $number_of_elements) { + if (($i * 8) < $number_of_elements) { $y_divider++; } else { @@ -4870,16 +4870,17 @@ sub cli_create_visual_console() { my $elem_width = ($pos2X - $pos1X) / $x_divider; my $elem_height = ($pos2Y - $pos1Y) / $y_divider; - if ($number_of_elements < 4) { - $elem_height = ($pos2Y - $pos1Y) / 3; + if ($number_of_elements <= 8) { + $elem_height = ($pos2Y - $pos1Y) / 4; } my $elem_count = 1; - my $pos_helper_x = 0; - my $pos_helper_y = 0; + my $pos_aux_count = 0; + my $pos_helper_x = $pos1X; + my $pos_helper_y = $pos1Y; foreach my $elem (@$elements_in_array) { - my $pos_x = $pos_helper_x * $elem_width; - my $pos_y = $pos_helper_y * $elem_height; + my $pos_x = $pos_helper_x; + my $pos_y = $pos_helper_y; my $width = $elem_width; my $height = $elem_height; my $label = $elem->{'label'}; @@ -4907,12 +4908,14 @@ sub cli_create_visual_console() { $elem_count++; - if ($pos_helper_x == 3) { - $pos_helper_x = 0; - $pos_helper_y++; + if ($pos_aux_count == 7) { + $pos_helper_x = $pos1X; + $pos_helper_y += $elem_height; + $pos_aux_count = 0; } else { - $pos_helper_x++; + $pos_aux_count++; + $pos_helper_x += $elem_width; } } } @@ -5379,7 +5382,7 @@ sub cli_delete_visual_console_objects() { ############################################################################## sub cli_duplicate_visual_console () { - my ($id_console,$prefix) = @ARGV[2..3]; + my ($id_console,$times,$prefix) = @ARGV[2..4]; if($id_console eq '') { print_log "[ERROR] Console ID field cannot be empty.\n\n"; @@ -5400,55 +5403,57 @@ sub cli_duplicate_visual_console () { $name_count = 1; } - my $exist = 1; - while ($exist == 1) { - my $name_in_db = get_db_single_row ($dbh, "SELECT name FROM tlayout WHERE name = '$new_name'"); + 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'}); - if (defined($name_in_db->{'name'}) && ($name_in_db->{'name'} eq $new_name)) { - $new_name = $name_to_compare . "_" . $name_count; - $name_count++; + 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"; } - 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"; } } @@ -5458,23 +5463,38 @@ sub cli_duplicate_visual_console () { ############################################################################## sub cli_export_visual_console() { - my ($id,$path) = @ARGV[2..3]; + my ($id,$path,$with_id) = @ARGV[2..4]; 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"); - my $data_to_json = '['; - my $first = 1; - + $data_to_json .= "'["; foreach my $element (@console_elements) { + my $id_layout_data = $element->{'id'}; my $pos_x = $element->{'pos_x'}; my $pos_y = $element->{'pos_y'}; my $width = $element->{'width'}; @@ -5504,7 +5524,15 @@ sub cli_export_visual_console() { $first = 0; } - $data_to_json .= '{"image":"' . $image . '"'; + $label =~ s/"/\\"/g; + + if ($with_id == 1) { + $data_to_json .= '{"id":' . $id_layout_data; + $data_to_json .= ',"image":"' . $image . '"'; + } + else { + $data_to_json .= '{"image":"' . $image . '"'; + } $data_to_json .= ',"pos_y":' . $pos_y; $data_to_json .= ',"pos_x":' . $pos_x; $data_to_json .= ',"width":' . $width; @@ -5528,7 +5556,7 @@ sub cli_export_visual_console() { $data_to_json .= '}'; } - $data_to_json .= ']'; + $data_to_json .= "]'"; if ($path eq '') { open(FicheroJSON, ">console_" . $id . "_elements"); @@ -5989,11 +6017,11 @@ sub pandora_manage_main ($$$) { cli_delete_visual_console_objects(); } elsif ($param eq '--duplicate_visual_console') { - param_check($ltotal, 2, 1); + param_check($ltotal, 3, 2); cli_duplicate_visual_console(); } elsif ($param eq '--export_json_visual_console') { - param_check($ltotal, 2, 1); + param_check($ltotal, 3, 2); cli_export_visual_console(); } else {