diff --git a/extras/aditional_rpmspec/wmic-4.0.0tp4.rbn.spec b/extras/aditional_rpmspec/wmic-4.0.0tp4.rbn.spec new file mode 100644 index 0000000000..e35f75e88d --- /dev/null +++ b/extras/aditional_rpmspec/wmic-4.0.0tp4.rbn.spec @@ -0,0 +1,49 @@ +%define name wmic +%define version 4.0.0tp4.rbn +Summary: Linux WMI client to do WMI querys using DCOM http://samba.org +Name: %{name} +Version: %{version} +Release: 1 +License: GPL2 +Group: System/Management +Packager: Robert B. Nelson +Source: http://www.openvas.org/download/wmi/wmi-1.3.14.tar.bz2 +Patch1: http://www.openvas.org/download/wmi/openvas-wmi-1.3.14.patch +Patch2: http://www.openvas.org/download/wmi/openvas-wmi-1.3.14.patch2 +Patch3: http://www.openvas.org/download/wmi/openvas-wmi-1.3.14.patch3v2 +Patch4: http://www.openvas.org/download/wmi/openvas-wmi-1.3.14.patch4 +Patch5: http://www.openvas.org/download/wmi/openvas-wmi-1.3.14.patch5 +BuildRoot: %{_tmppath}/%{name}-%{version}-build +AutoReq: 1 +Provides: %{name}-%{version} + +%description +Linux WMI client to do WMI querys. More information at SAMBA4 project at http://www.samba.org/ + +%prep +rm -rf $RPM_BUILD_ROOT + +%setup -n wmi-1.3.14 + +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 + +%build +cd Samba/source +./autogen.sh +./configure --without-readline --enable-debug +make "CPP=gcc -E -ffreestanding" proto bin/wmic + +%install +mkdir -p $RPM_BUILD_ROOT/usr/bin/ +install Samba/source/bin/wmic $RPM_BUILD_ROOT%{_bindir} + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-, root, root) +%{_bindir}/wmic diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 62b8de0357..4a4132a737 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150602 +Version: 6.0dev-150618 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 a3362ae49c..736692308a 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="6.0dev-150602" +pandora_version="6.0dev-150618" 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/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index d2648ae96f..5d263a003c 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -68,40 +68,43 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local transfer_mode tentacle +# timeout in seconds for file transfer programs execution (30 by default) +#transfer_timeout 30 + # Server password (Tentacle or FTP). Leave empty for no password (default). -# server_pwd mypassword +#server_pwd mypassword # Set to yes/no to enable/disable OpenSSL support for Tentacle (disabled by default). -# server_ssl no +#server_ssl no # Extra options for the Tentacle client (for example, server_opts "-v -r 5"). -# server_opts +#server_opts # delayed_startup defines number of seconds before start execution # for first time when startup Pandora FMS Agent -# delayed_startup 10 +#delayed_startup 10 # Pandora nice defines priority of execution. Less priority means more intensive execution # A recommended value is 10. 0 priority means no Pandora CPU protection enabled (default) -# pandora_nice 0 +#pandora_nice 0 # Cron mode replace Pandora FMS own task schedule each XX interval seconds by the use # of old style cron. You should add to crontab Pandora FMS agent script to use this mode. # This is disabled by default, and is not recommended. Use Pandora FMS internal scheduler # is much more safe. -# cron_mode +#cron_mode # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) -# remote_config 1 +#remote_config 1 # If set to 1 start Drone Agent's Proxy Mode -# proxy_mode 1 +#proxy_mode 1 # Max number of simmultaneus connection for proxy (by default 10) -# proxy_max_connection 10 +#proxy_max_connection 10 # Proxy timeout (by default 1s) -# proxy_timeout 1 +#proxy_timeout 1 # Number of threads to execute modules in parallel #agent_threads 1 @@ -109,20 +112,21 @@ transfer_mode tentacle # User the agent will run as #pandora_user root -# Secondary server configuration -# ============================== +#Secondary server configuration +#============================== # If secondary_mode is set to on_error, data files are copied to the secondary # server only if the primary server fails. If set to always, data files are # always copied to the secondary server. -# secondary_mode on_error -# secondary_server_ip localhost -# secondary_server_path /var/spool/pandora/data_in -# secondary_server_port 41121 -# secondary_transfer_mode tentacle -# secondary_server_pwd mypassword -# secondary_server_ssl no -# secondary_server_opts +#secondary_mode on_error +#secondary_server_ip localhost +#secondary_server_path /var/spool/pandora/data_in +#secondary_server_port 41121 +#secondary_transfer_mode tentacle +#secondary_transfer_timeout 30 +#secondary_server_pwd mypassword +#secondary_server_ssl no +#secondary_server_opts # Module Definition # ================= diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index d5796e1037..13844d10a2 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -94,6 +94,9 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local transfer_mode tentacle +# timeout in seconds for file transfer programs execution (30 by default) +#transfer_timeout 30 + # Server password (Tentacle or FTP). Leave empty for no password (default). #server_pwd mypassword @@ -154,6 +157,7 @@ temporal_min_size 1024 #secondary_server_path /var/spool/pandora/data_in #secondary_server_port 41121 #secondary_transfer_mode tentacle +#secondary_transfer_timeout 30 #secondary_server_pwd mypassword #secondary_server_ssl no #secondary_server_opts diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index 3962874f25..648480c0d4 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -64,40 +64,43 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local transfer_mode tentacle +# timeout in seconds for file transfer programs execution (30 by default) +#transfer_timeout 30 + # Server password (Tentacle or FTP). Leave empty for no password (default). -# server_pwd mypassword +#server_pwd mypassword # Set to yes/no to enable/disable OpenSSL support for Tentacle (disabled by default). -# server_ssl no +#server_ssl no # Extra options for the Tentacle client (for example, server_opts "-v -r 5"). -# server_opts +#server_opts # delayed_startup defines number of seconds before start execution # for first time when startup Pandora FMS Agent -# delayed_startup 10 +#delayed_startup 10 # Pandora nice defines priority of execution. Less priority means more intensive execution # A recommended value is 10. 0 priority means no Pandora CPU protection enabled (default) -# pandora_nice 0 +#pandora_nice 0 # Cron mode replace Pandora FMS own task schedule each XX interval seconds by the use # of old style cron. You should add to crontab Pandora FMS agent script to use this mode. # This is disabled by default, and is not recommended. Use Pandora FMS internal scheduler # is much more safe. -# cron_mode +#cron_mode # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) -# remote_config 1 +#remote_config 1 # If set to 1 start Drone Agent's Proxy Mode -# proxy_mode 1 +#proxy_mode 1 # Max number of simmultaneus connection for proxy (by default 10) -# proxy_max_connection 10 +#proxy_max_connection 10 # Proxy timeout (by default 1s) -# proxy_timeout 1 +#proxy_timeout 1 # Number of threads to execute modules in parallel #agent_threads 1 @@ -111,14 +114,15 @@ transfer_mode tentacle # If secondary_mode is set to on_error, data files are copied to the secondary # server only if the primary server fails. If set to always, data files are # always copied to the secondary server. -# secondary_mode on_error -# secondary_server_ip localhost -# secondary_server_path /var/spool/pandora/data_in -# secondary_server_port 41121 -# secondary_transfer_mode tentacle -# secondary_server_pwd mypassword -# secondary_server_ssl no -# secondary_server_opts +#secondary_mode on_error +#secondary_server_ip localhost +#secondary_server_path /var/spool/pandora/data_in +#secondary_server_port 41121 +#secondary_transfer_mode tentacle +#secondary_transfer_timeout 30 +#secondary_server_pwd mypassword +#secondary_server_ssl no +#secondary_server_opts # Module Definition # ================= diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index e6fb48d0c0..60919981f4 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -58,40 +58,43 @@ server_port 41121 # Transfer mode: tentacle, ftp, ssh or local transfer_mode tentacle +# timeout in seconds for file transfer programs execution (30 by default) +#transfer_timeout 30 + # Server password (Tentacle or FTP). Leave empty for no password (default). -# server_pwd mypassword +#server_pwd mypassword # Set to yes/no to enable/disable OpenSSL support for Tentacle (disabled by default). -# server_ssl no +#server_ssl no # Extra options for the Tentacle client (for example, server_opts "-v -r 5"). -# server_opts +#server_opts # delayed_startup defines number of seconds before start execution # for first time when startup Pandora FMS Agent -# delayed_startup 10 +#delayed_startup 10 # Pandora nice defines priority of execution. Less priority means more intensive execution # A recommended value is 10. 0 priority means no Pandora CPU protection enabled (default) -# pandora_nice 0 +#pandora_nice 0 # Cron mode replace Pandora FMS own task schedule each XX interval seconds by the use # of old style cron. You should add to crontab Pandora FMS agent script to use this mode. # This is disabled by default, and is not recommended. Use Pandora FMS internal scheduler # is much more safe. -# cron_mode +#cron_mode # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) -# remote_config 1 +#remote_config 1 # If set to 1 start Drone Agent's Proxy Mode -# proxy_mode 1 +#proxy_mode 1 # Max number of simmultaneus connection for proxy (by default 10) -# proxy_max_connection 10 +#proxy_max_connection 10 # Proxy timeout (by default 1s) -# proxy_timeout 1 +#proxy_timeout 1 # User the agent will run as #pandora_user root @@ -102,14 +105,15 @@ transfer_mode tentacle # If secondary_mode is set to on_error, data files are copied to the secondary # server only if the primary server fails. If set to always, data files are # always copied to the secondary server. -# secondary_mode on_error -# secondary_server_ip localhost -# secondary_server_path /var/spool/pandora/data_in -# secondary_server_port 41121 -# secondary_transfer_mode tentacle -# secondary_server_pwd mypassword -# secondary_server_ssl no -# secondary_server_opts +#secondary_mode on_error +#secondary_server_ip localhost +#secondary_server_path /var/spool/pandora/data_in +#secondary_server_port 41121 +#secondary_transfer_mode tentacle +#secondary_transfer_timeout 30 +#secondary_server_pwd mypassword +#secondary_server_ssl no +#secondary_server_opts # Module Definition # ================= diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index aef77506bd..8127bbe319 100644 --- 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 => '6.0dev'; -use constant AGENT_BUILD => '150602'; +use constant AGENT_BUILD => '150618'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { @@ -510,6 +510,9 @@ sub parse_conf_modules($) { # Make the module run the first time $module->{'counter'} = $module->{'intensive_interval'}; + # Replace macros + replace_macros ($module); + push (@Modules, {%{$module}}); } else { $module->{'func'} = \&module_plugin; @@ -601,16 +604,20 @@ sub write_broker_conf($){ my ($broker_agent) = @_; my $content = ''; + # I don't think the following should be copied either: proxy_* + my %ignored_tokens = ( + 'broker_agent' => 1, 'agent_name_cmd' => 1, 'udp_server' => 1, 'cron_mode' => 1 + ); + open (CONF_FILE, "$ConfDir/$ConfFile") or error ("Could not open file '$ConfDir/$ConfFile': $!."); open (BROKER_FILE, ">$ConfDir/${broker_agent}.conf") or error ("Could not write configuration file: $!"); - while (my $line = ){ + while (my $line = ) { + + my ( $token ) = $line =~ m/^\s*(\S+)(\s.*)?$/; + # Skip tokens which should not be copied to broker configuration + next if defined $ignored_tokens{$token}; - # Skip broker definitions - if ($line =~ m/^\s*broker_agent/) { - next; - } - # Change the agent name if ($line =~ m/^\s*#*\s*agent_name\s+/) { $line = "agent_name $broker_agent\n"; @@ -647,19 +654,6 @@ sub read_config (;$) { # Replace CRLF with LF $line =~ s/\r\n/\n/g; - # Store the custom fields - - if (($line =~ m/^(custom_field\d+_name)\s+(.*)/) or ($line =~ m/^(custom_field\d+_value)\s+(.*)/)) { - $Customfields{$1} = $2; - next; - } - - # Save global macros - if ($line =~ m/^macro(\S+)\s+(.*)/) { - $Macros{$1} = $2; - next; - } - # Token search if (defined ($token)) { if ($line =~ /^\s*(\S+)\s+(.*)$/ && $1 eq $token) { @@ -675,6 +669,20 @@ sub read_config (;$) { } next; } + + # Store the custom fields + + if (($line =~ m/^(custom_field\d+_name)\s+(.*)/) or ($line =~ m/^(custom_field\d+_value)\s+(.*)/)) { + $Customfields{$1} = $2; + next; + } + + # Save global macros + if ($line =~ m/^macro(\S+)\s+(.*)/) { + $Macros{$1} = $2; + next; + } + next if ($line =~ /^module\s*\w*/); #Configuration token @@ -872,7 +880,7 @@ sub send_buffered_xml_files () { while (my $xml_file = readdir(TEMPORAL)) { # Skip non data files and symlinks - next if ($xml_file !~ m/\.data$/ || -l "$Conf{'temporal'}/$xml_file"); + next if ($xml_file !~ m/^$Conf{'agent_name'}\.[0-9]+\.data$/ || -l "$Conf{'temporal'}/$xml_file"); my $rc = send_file ("$Conf{'temporal'}/$xml_file", 1); unlink ("$Conf{'temporal'}/$xml_file") if ($rc == 0); diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index b732bcfe4c..5713faa5b2 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 6.0dev -%define release 150602 +%define release 150618 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -51,11 +51,6 @@ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_R cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ -# Checking old config file (if exists) -if [ -f /etc/pandora/pandora_agent.conf ] ; then - mv /etc/pandora/pandora_agent.conf /etc/pandora/pandora_agent.conf.backup -fi - cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 76923438e7..6ed8588b92 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 6.0dev -%define release 150602 +%define release 150618 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -51,16 +51,11 @@ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_R cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ -# Checking old config file (if exists) -if [ -f /etc/pandora/pandora_agent.conf ] ; then - mv /etc/pandora/pandora_agent.conf /etc/pandora/pandora_agent.conf.backup -fi - cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew -if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then - rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec -fi +#if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then +# rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec +#fi %clean rm -Rf $RPM_BUILD_ROOT diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index dcf98711da..8e5fbc82bb 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -62,6 +62,9 @@ interval 300 transfer_mode tentacle server_port 41121 +# timeout in seconds for file transfer programs execution (30 by default) +#transfer_timeout 30 + # In case of using FTP or tentacle with password. User is always "pandora" #server_pwd pandora @@ -98,6 +101,7 @@ xml_buffer 1 #secondary_server_path /var/spool/pandora/data_in #secondary_server_port 41121 #secondary_transfer_mode tentacle +#secondary_transfer_timeout 30 #secondary_server_pwd mypassword #secondary_server_ssl no #secondary_server_opts diff --git a/pandora_agents/win32/ftp/pandora_ftp_client.cc b/pandora_agents/win32/ftp/pandora_ftp_client.cc index a91b7c856a..65a281d885 100644 --- a/pandora_agents/win32/ftp/pandora_ftp_client.cc +++ b/pandora_agents/win32/ftp/pandora_ftp_client.cc @@ -107,7 +107,7 @@ read_func(void *ptr, size_t size, size_t nmemb, FILE *stream) */ int Pandora_Ftp_Client::ftpFileFilename (const string remote_filename, - const string filepath) + const string filepath, int timeout) { FILE *fd; string operation1; @@ -155,8 +155,8 @@ Pandora_Ftp_Client::ftpFileFilename (const string remote_filename, curl_easy_setopt (this->curl, CURLOPT_UPLOAD, 1) ; curl_easy_setopt (this->curl, CURLOPT_URL, url.c_str ()); curl_easy_setopt (this->curl, CURLOPT_POSTQUOTE, headerlist); - curl_easy_setopt (this->curl, CURLOPT_TIMEOUT, 240); - curl_easy_setopt (this->curl, CURLOPT_FTP_RESPONSE_TIMEOUT, 60); + curl_easy_setopt (this->curl, CURLOPT_TIMEOUT, timeout * 4); + curl_easy_setopt (this->curl, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout); curl_easy_setopt (this->curl, CURLOPT_READFUNCTION, read_func); curl_easy_setopt (this->curl, CURLOPT_READDATA, fd); curl_easy_setopt (curl, CURLOPT_INFILESIZE_LARGE, diff --git a/pandora_agents/win32/ftp/pandora_ftp_client.h b/pandora_agents/win32/ftp/pandora_ftp_client.h index 7ebd89772b..a31a3b3103 100644 --- a/pandora_agents/win32/ftp/pandora_ftp_client.h +++ b/pandora_agents/win32/ftp/pandora_ftp_client.h @@ -72,7 +72,7 @@ namespace FTP { void disconnect (); int ftpFileFilename (const string remote_filename, - const string filepath); + const string filepath, int timeout); string getError (); }; diff --git a/pandora_agents/win32/ftp/pandora_ftp_test.cc b/pandora_agents/win32/ftp/pandora_ftp_test.cc index 07cc4b5446..edf9d5e35c 100644 --- a/pandora_agents/win32/ftp/pandora_ftp_test.cc +++ b/pandora_agents/win32/ftp/pandora_ftp_test.cc @@ -79,10 +79,16 @@ Pandora_FTP_Test::test () { char *err; DIR *dir; FILE *conf_fh = NULL; + int timeout; remote_host = this->conf->getValue ("server_ip"); cout << "Connecting with " << remote_host << "..." << endl; password = this->conf->getValue ("server_pwd"); + timeout = atoi (conf->getValue ("transfer_timeout").c_str ()); + if (timeout == 0) { + timeout = 30; + } + if (password == "") { cout << "FTP password not found in configuration file." << endl; cout << "Check that server_pwd variable is set." << endl; @@ -136,7 +142,7 @@ Pandora_FTP_Test::test () { try { ftp_client->ftpFileFilename (remote_filepath + tmp_filename, - tmp_filepath); + tmp_filepath, timeout); } catch (FTP::Unknown_Host e) { cout << "Failed when copying to " << remote_host << " (" << ftp_client->getError () << ")" << endl; diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 55d48d0900..3ae975f81d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150602} +{150618} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index cc0b604f6d..20b9faec38 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 ("6.0dev(Build 150602)") +#define PANDORA_VERSION ("6.0dev(Build 150618)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 1a60579675..383727f7a2 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -687,14 +687,14 @@ Pandora_Windows_Service::copyTentacleDataFile (string host, string port, string ssl, string pass, - string opts) + string opts, + int timeout) { DWORD rc; string var, filepath; string tentacle_cmd, working_dir; PROCESS_INFORMATION pi; STARTUPINFO si; - int tentacle_timeout = 0; var = conf->getValue ("temporal"); if (var[var.length () - 1] != '\\') { @@ -740,24 +740,25 @@ Pandora_Windows_Service::copyTentacleDataFile (string host, CloseHandle (pi.hThread); /* Timeout */ - tentacle_timeout = atoi (conf->getValue ("tentacle_timeout").c_str ()); - if (tentacle_timeout <= 0) { - tentacle_timeout = INFINITE; - } else { - /* Convert to milliseconds */ - tentacle_timeout *= 1000; - } + if (timeout <= 0) { + timeout = 30; + } + /* Convert to milliseconds */ + timeout *= 1000; - if (WaitForSingleObject(pi.hProcess, tentacle_timeout) == WAIT_TIMEOUT) { + if (WaitForSingleObject(pi.hProcess, timeout) == WAIT_TIMEOUT) { TerminateProcess(pi.hProcess, STILL_ACTIVE); CloseHandle (pi.hProcess); + pandoraLog ("Pandora Agent: Failed when copying to %s (tentacle timeout)", host.c_str ()); return -1; } /* Get the return code of the tentacle client*/ - GetExitCodeProcess (pi.hProcess, &rc); + GetExitCodeProcess (pi.hProcess, &rc); if (rc != 0) { CloseHandle (pi.hProcess); + pandoraLog ("Pandora Agent: Failed when copying to %s", + host.c_str ()); return -1; } @@ -770,6 +771,8 @@ Pandora_Windows_Service::copyScpDataFile (string host, string remote_path, string filename) { + /* TODO: timeout implementation */ + int rc = 0; SSH::Pandora_Ssh_Client ssh_client; string tmp_dir, filepath,port_str; @@ -830,7 +833,8 @@ int Pandora_Windows_Service::copyFtpDataFile (string host, string remote_path, string filename, - string password) + string password, + int timeout) { int rc = 0; FTP::Pandora_Ftp_Client ftp_client; @@ -856,7 +860,7 @@ Pandora_Windows_Service::copyFtpDataFile (string host, password); rc = ftp_client.ftpFileFilename (remote_path + filename, - filepath); + filepath, timeout); if (rc == UNKNOWN_HOST) { pandoraLog ("Pandora Agent: Failed when copying to %s (%s)", host.c_str (), ftp_client.getError ().c_str ()); @@ -882,13 +886,18 @@ Pandora_Windows_Service::copyFtpDataFile (string host, int Pandora_Windows_Service::copyDataFile (string filename) { - int rc = 0; + int rc = 0, timeout; unsigned char copy_to_secondary = 0; string mode, host, remote_path; mode = conf->getValue ("transfer_mode"); host = conf->getValue ("server_ip"); remote_path = conf->getValue ("server_path"); + timeout = atoi (conf->getValue ("transfer_timeout").c_str ()); + if (timeout == 0) { + timeout = 30; + } + // Fix remote path if (mode != "local" && remote_path[remote_path.length () - 1] != '/') { remote_path += "/"; @@ -897,11 +906,11 @@ Pandora_Windows_Service::copyDataFile (string filename) } if (mode == "ftp") { - rc = copyFtpDataFile (host, remote_path, filename, conf->getValue ("server_pwd")); + rc = copyFtpDataFile (host, remote_path, filename, conf->getValue ("server_pwd"), timeout); } else if (mode == "tentacle" || mode == "") { rc = copyTentacleDataFile (host, filename, conf->getValue ("server_port"), conf->getValue ("server_ssl"), conf->getValue ("server_pwd"), - conf->getValue ("server_opts")); + conf->getValue ("server_opts"), timeout); } else if (mode == "ssh") { rc =copyScpDataFile (host, remote_path, filename); } else if (mode == "local") { @@ -932,6 +941,10 @@ Pandora_Windows_Service::copyDataFile (string filename) mode = conf->getValue ("secondary_transfer_mode"); host = conf->getValue ("secondary_server_ip"); remote_path = conf->getValue ("secondary_server_path"); + timeout = atoi (conf->getValue ("secondary_transfer_timeout").c_str ()); + if (timeout == 0) { + timeout = 30; + } // Fix remote path if (mode != "local" && remote_path[remote_path.length () - 1] != '/') { @@ -942,11 +955,11 @@ Pandora_Windows_Service::copyDataFile (string filename) // Send the file to the secondary server if (mode == "ftp") { - rc = copyFtpDataFile (host, remote_path, filename, conf->getValue ("secondary_server_pwd")); + rc = copyFtpDataFile (host, remote_path, filename, conf->getValue ("secondary_server_pwd"), timeout); } else if (mode == "tentacle" || mode == "") { rc = copyTentacleDataFile (host, filename, conf->getValue ("secondary_server_port"), conf->getValue ("secondary_server_ssl"), conf->getValue ("secondary_server_pwd"), - conf->getValue ("secondary_server_opts")); + conf->getValue ("secondary_server_opts"), timeout); } else if (mode == "ssh") { rc = copyScpDataFile (host, remote_path, filename); } else { @@ -965,11 +978,14 @@ Pandora_Windows_Service::copyDataFile (string filename) void Pandora_Windows_Service::recvTentacleDataFile (string host, - string filename) + string filename, + int timeout) { - int rc; + DWORD rc; string var; string tentacle_cmd; + PROCESS_INFORMATION pi; + STARTUPINFO si; /* Change directory to "temporal" */ var = conf->getValue ("temporal"); @@ -1008,42 +1024,58 @@ Pandora_Windows_Service::recvTentacleDataFile (string host, filename.c_str (), host.c_str ()); pandoraDebug ("Command %s", tentacle_cmd.c_str()); - rc = system (tentacle_cmd.c_str()); - switch (rc) { - - /* system() error */ - case -1: - pandoraLog ("Unable to receive file %s", filename.c_str ()); - throw Pandora_Exception (); - - /* tentacle_client.exe returned OK */ - case 0: - break; - - /* tentacle_client.exe error */ - default: - pandoraDebug ("Tentacle client was unable to receive file %s", - filename.c_str ()); - throw Pandora_Exception (); + ZeroMemory (&si, sizeof (si)); + ZeroMemory (&pi, sizeof (pi)); + if (CreateProcess (NULL , (CHAR *)tentacle_cmd.c_str (), NULL, NULL, FALSE, + CREATE_NO_WINDOW, NULL, NULL, &si, &pi) == 0) { + return; } + /* close thread handle, because it won't be used */ + CloseHandle (pi.hThread); + + /* Timeout */ + if (timeout <= 0) { + timeout = 30; + } + /* Convert to milliseconds */ + timeout *= 1000; + + if (WaitForSingleObject(pi.hProcess, timeout) == WAIT_TIMEOUT) { + TerminateProcess(pi.hProcess, STILL_ACTIVE); + CloseHandle (pi.hProcess); + pandoraLog ("Unable to receive file %s (tentacle timeout)", filename.c_str ()); + return; + } + + /* Get the return code of the tentacle client*/ + GetExitCodeProcess (pi.hProcess, &rc); + if (rc != 0) { + CloseHandle (pi.hProcess); + pandoraLog ("Unable to receive file %s", filename.c_str ()); + return; + } + + CloseHandle (pi.hProcess); return; } void Pandora_Windows_Service::recvDataFile (string filename) { string mode, host, remote_path; + int timeout; mode = conf->getValue ("transfer_mode"); host = conf->getValue ("server_ip"); remote_path = conf->getValue ("server_path"); + timeout = atoi (conf->getValue ("transfer_timeout").c_str ()); if (remote_path[remote_path.length () - 1] != '/') { remote_path += "/"; } try { if (mode == "tentacle") { - recvTentacleDataFile (host, filename); + recvTentacleDataFile (host, filename, timeout); } else { pandoraLog ("Transfer mode %s does not support file retrieval.", mode.c_str () ); throw Pandora_Exception (); diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index c64152dd0f..c0b6b2f9a9 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -61,19 +61,22 @@ namespace Pandora { string port, string ssl, string pass, - string opts); + string opts, + int timeout); int copyScpDataFile (string host, string remote_path, string filename); int copyFtpDataFile (string host, string remote_path, string filename, - string password); + string password, + int timeout); int copyLocalDataFile (string remote_path, string filename); void recvDataFile (string filename); void recvTentacleDataFile (string host, - string filename); + string filename, + int timeout); int unzipCollection(string zip_path, string dest_dir); void checkCollections (); diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 9af9dafcce..18d80b0f18 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", "(6.0dev(Build 150602))" + VALUE "ProductVersion", "(6.0dev(Build 150618))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc index c541d44745..e4763cc433 100644 --- a/pandora_agents/win32/windows/pandora_wmi.cc +++ b/pandora_agents/win32/windows/pandora_wmi.cc @@ -116,11 +116,8 @@ Pandora_Wmi::isServiceRunning (string service_name) { if (str_state == "Running") { retval = 1; } - else if (str_state == "Stopped") { - retval = 0; - } else { - retval = -1; + retval = 0; } dhFreeString (state); diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index f4f0ae4843..ee77899299 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150602 +Version: 6.0dev-150618 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 67d44f16f7..d560d89a92 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="6.0dev-150602" +pandora_version="6.0dev-150618" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 65bf295c11..7f79e1540c 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -140,15 +140,17 @@ function mainAgentsModules() { $filter_module_group['id_module_group'] = $modulegroup; } $count = 0; - foreach ($agents as $agent){ - $module = agents_get_modules($agent, false, $filter_module_group, true, false); - if ($module == false){ + foreach ($agents as $agent) { + $module = agents_get_modules($agent, false, + $filter_module_group, true, false); + if ($module == false) { unset($agents[$count]); } $count++; } $total_pagination = count($agents); - $all_modules = agents_get_modules($agents, false, $filter_module_group, true, false); + $all_modules = agents_get_modules($agents, false, + $filter_module_group, true, false); $modules_by_name = array(); $name = ''; diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index ee5a92eb33..7b1be5ebb4 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -30,7 +30,7 @@ if (is_ajax ()) { if ($get_info_alert_module_group) { $agents = agents_get_group_agents($id_agent_group); if (!empty($agents)) { - $alerts = agents_get_alerts_simple(array_keys($agents)); + $alerts = agents_get_alerts_simple(array_keys($agents)); foreach ($alerts as $alert) { $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); if ($module_group == $module['id_module_group']) { @@ -108,14 +108,14 @@ if (is_ajax ()) { echo 'No available data'; } } - + /** * Translate the array texts using gettext */ function translate(&$item, $key) { $item = __($item); } - + /** * The main function of module groups and the enter point to * execute the code. @@ -321,7 +321,7 @@ function mainModuleGroups() { diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index 7a83678c86..852e965513 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -86,25 +86,25 @@ function main_net_tools () { $principal_ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); $list_address = db_get_all_rows_sql ("select id_a from taddress_agent where id_agent = " . $id_agente); - foreach ($list_address as $address){ + foreach ($list_address as $address) { $ids []= join(",",$address); } $ids_address = implode(",",$ids); $ips = db_get_all_rows_sql ("select ip from taddress where id_a in (" . $ids_address . ")"); - + if ($ips == "") { echo "
" . __('The agent hasn\'t got IP') . "
"; return; } echo " \ No newline at end of file diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 592cc3ae2d..f7911d97f1 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -17,7 +17,7 @@ global $config; -require_once ($config["homedir"] . '/include/functions_graph.php'); +require_once ($config["homedir"] . '/include/functions_graph.php'); check_login (); @@ -164,7 +164,7 @@ switch ($config["dbtype"]) { $result = db_get_all_rows_sql ($sql); // Delete rnum row generated by oracle_recode_query() function -if (($config["dbtype"] == 'oracle') && ($result !== false)){ +if (($config["dbtype"] == 'oracle') && ($result !== false)) { for ($i=0; $i < count($result); $i++) { unset($result[$i]['rnum']); } diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index d5cb49641a..e65f2850a7 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -66,7 +66,7 @@ if (is_ajax ()) { $oid_snmp = array(); $out = false; foreach ($idSNMP as $id) { - foreach ($snmp[$id] as $key => $value){ + foreach ($snmp[$id] as $key => $value) { // Check if it has "ifXXXX" syntax and skip it if (! preg_match ( "/if/", $key)) { @@ -246,7 +246,7 @@ $table->data[3][1] = html_print_select_groups(false, "AR", false, 'grupo', $grup $table->data[4][0] = __('Interval'); $table->data[4][1] = html_print_extended_select_for_time ('intervalo', $intervalo, '', '', '0', 10, true); -if($intervalo<300){ +if ($intervalo < SECONDS_5MINUTES) { $table->data[4][1] .= clippy_context_help("interval_agent_min"); } $table->data[5][0] = __('OS'); diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 127bd0ab8b..000ee06c7f 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -27,9 +27,9 @@ require_once($config['homedir'] . "/include/functions_modules.php"); // ========================== if (isset ($_POST["template_id"])) { // Take agent data - $row = db_get_row ("tagente", "id_agente", $id_agente); + $row = db_get_row ("tagente", "id_agente", $id_agente); if ($row !== false) { - $intervalo = $row["intervalo"]; + $intervalo = $row["intervalo"]; $nombre_agente = $row["nombre"]; $direccion_agente =$row["direccion"]; $ultima_act = $row["ultimo_contacto"]; diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php index a8f30baf72..718b04c674 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php @@ -894,7 +894,7 @@ if (!$fail) { if ($arrow) { $table->data[2][1] .= '
' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '
'; } - $table->data[2][1] .= '

' . html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . '
'; + $table->data[2][1] .= '

' . html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . '
'; $table->cellstyle[2][1] = 'vertical-align: middle; text-align: center;'; $table->data[2][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:300px; height: 100%;'); @@ -1052,11 +1052,14 @@ $(document).ready (function () { }); $("#submit-create_modules_btn").click(function () { - if($("#module option").length == 0 || ($("#module option").length == 1 && $("#module option").eq(0).val() == 0)) { + if ($("#module option").length == 0 + || ($("#module option").length == 1 + && $("#module option").eq(0).val() == 0)) { + alert(''); return false; } - $('#module option').map(function(){ + $('#module option').map(function() { $(this).attr('selected','selected'); }); }); diff --git a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php index 55ce924c89..032f8110b9 100644 --- a/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.wmi_explorer.php @@ -307,7 +307,7 @@ if ($wmiexplore && !$fail) { $table->data[1][0] .= html_print_select ($modes, 'wmi_wizard_modes', '', '', '', '', true, false, false); $table->cellstyle[1][0] = 'vertical-align: middle;'; - + $table->colspan[1][0] = 2; $table->data[1][2] = ''.__('Modules').''; $table->cellstyle[1][2] = 'vertical-align: middle;'; @@ -321,13 +321,13 @@ if ($wmiexplore && !$fail) { $table->data[2][0] .= html_print_select (array (), 'network_component', '', '', '', '', true, true, true, '', false, 'width: 300px;'); $table->data[2][0] .= ''; - + // Services list $table->data[2][0] .= '
'; $table->data[2][0] .= html_print_select ($services, 'services', '', '', '', '', true, true, true, '', false, 'width: 300px;'); $table->data[2][0] .= '
'; - + // Processes list $table->data[2][0] .= '
'; $table->data[2][0] .= html_print_select ($processes, 'processes', '', '', @@ -343,8 +343,8 @@ if ($wmiexplore && !$fail) { '', '', true, true, true, '', false, 'width: 300px;'); $table->data[2][0] .= '
'; $table->cellstyle[2][0] = 'vertical-align: top; text-align: center;'; - - + + // Components arrow $table->data[2][1] = '
' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '
'; // Services arrow @@ -355,13 +355,15 @@ if ($wmiexplore && !$fail) { $table->data[2][1] .= '
' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '
'; - $table->data[2][1] .= '

' . html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . '
'; + $table->data[2][1] .= '

' . + html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . + '
'; $table->cellstyle[2][1] = 'vertical-align: middle; text-align: center;'; - + $table->data[2][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:300px; height: 100%;'); $table->data[2][2] .= html_print_input_hidden('agent', $id_agent, true); $table->cellstyle[2][2] = 'vertical-align: top; text-align: center;'; - + html_print_table($table); echo "
"; @@ -373,7 +375,7 @@ if ($wmiexplore && !$fail) { echo ""; echo '
'; } - + ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('bgiframe'); @@ -383,7 +385,7 @@ ui_require_javascript_file ('pandora_modules'); diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index a59187116c..664bc3e020 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -149,7 +149,7 @@ if (defined('METACONSOLE')) { echo '
'; echo __("Edit or delete groups can cause problems with synchronization"); - echo '
'; + echo ''; } else { @@ -198,7 +198,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) { $result = db_process_sql_insert('tgrupo', $values); if ($result) { - ui_print_success_message(__('Group successfully created')); + ui_print_success_message(__('Group successfully created')); } else { ui_print_error_message(__('There was a problem creating group')); @@ -323,11 +323,12 @@ foreach ($all_parents as $parent) { $groups_count = count($groups); if (check_acl($config['id_user'], 0, "PM")) { - if (!defined("METACONSOLE")){ + if (!defined("METACONSOLE")) { echo '
'; echo '
'; echo '
'; - html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); + html_print_submit_button(__('Create group'), 'crt', false, + 'class="sub next"'); echo '
'; echo '
'; } diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 0e48eca8f5..9dfc312a46 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -71,7 +71,7 @@ if ($create_group) { $result = db_process_sql_insert('tmodule_group', array('name' => $name)); if ($result) { - ui_print_success_message(__('Group successfully created')); + ui_print_success_message(__('Group successfully created')); } else { ui_print_error_message(__('There was a problem creating group')); @@ -132,7 +132,7 @@ if ($delete_group) { } if (! $result) - ui_print_error_message(__('There was a problem deleting group')); + ui_print_error_message(__('There was a problem deleting group')); else ui_print_success_message(__('Group successfully deleted')); } diff --git a/pandora_console/godmode/massive/massive_add_alerts.php b/pandora_console/godmode/massive/massive_add_alerts.php index 621223e396..c485754d27 100755 --- a/pandora_console/godmode/massive/massive_add_alerts.php +++ b/pandora_console/godmode/massive/massive_add_alerts.php @@ -262,11 +262,11 @@ $(document).ready (function () { $("#id_group").click ( function () { - $(this).css ("width", "auto"); + $(this).css ("width", "auto"); }); $("#id_group").blur (function () { - $(this).css ("width", "180px"); + $(this).css ("width", "180px"); }); $("#id_agents").click ( @@ -275,16 +275,16 @@ $(document).ready (function () { }); $("#id_agents").blur (function () { - $(this).css ("width", "180px"); + $(this).css ("width", "180px"); }); $("#module").click ( function () { - $(this).css ("width", "auto"); + $(this).css ("width", "auto"); }); $("#module").blur (function () { - $(this).css ("width", "180px"); + $(this).css ("width", "180px"); }); $("#modules_selection_mode").change (function() { diff --git a/pandora_console/godmode/massive/massive_add_tags.php b/pandora_console/godmode/massive/massive_add_tags.php index 25d311d4ec..6d97f0d9e9 100755 --- a/pandora_console/godmode/massive/massive_add_tags.php +++ b/pandora_console/godmode/massive/massive_add_tags.php @@ -215,11 +215,11 @@ $(document).ready (function () { $("#id_group").click ( function () { - $(this).css ("width", "auto"); + $(this).css ("width", "auto"); }); $("#id_group").blur (function () { - $(this).css ("width", "180px"); + $(this).css ("width", "180px"); }); $("#id_agents").click ( @@ -228,16 +228,16 @@ $(document).ready (function () { }); $("#id_agents").blur (function () { - $(this).css ("width", "180px"); + $(this).css ("width", "180px"); }); $("#module").click ( function () { - $(this).css ("width", "auto"); + $(this).css ("width", "auto"); }); $("#module").blur (function () { - $(this).css ("width", "180px"); + $(this).css ("width", "180px"); }); $("#modules_selection_mode").change (function() { diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index d3f91390d6..5e8803eaa0 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -74,11 +74,11 @@ $table->data[0][1] = html_print_select_groups(false, "AW", true, 'source_id_grou $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("source_recursion", 1, $source_recursion, true, false); $status_list = array (); -$status_list[AGENT_STATUS_NORMAL] = __('Normal'); +$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); +$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data[0][4] = __('Status'); $table->data[0][5] = html_print_select($status_list, @@ -185,11 +185,11 @@ $table->data[0][3] = html_print_checkbox ("destiny_recursion", 1, $destiny_recursion, true, false); $status_list = array (); -$status_list[AGENT_STATUS_NORMAL] = __('Normal'); +$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); +$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data[1][0] = __('Status'); $table->data[1][1] = html_print_select($status_list, diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index 6e44ebc67d..d6ebe29c3c 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -109,11 +109,11 @@ $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, true, false); $status_list = array (); -$status_list[AGENT_STATUS_NORMAL] = __('Normal'); +$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); +$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data[1][0] = __('Status'); $table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected', diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 40233a7127..d309e83f29 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -303,11 +303,11 @@ $table->rowclass['form_agents_2'] = 'select_agents_row'; $table->data['form_agents_2'][0] = __('Status'); $table->colspan['form_agents_2'][1] = 2; $status_list = array (); -$status_list[AGENT_STATUS_NORMAL] = __('Normal'); +$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); +$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data['form_agents_2'][1] = html_print_select($status_list, 'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true); diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index fa7c302c87..14c1783cf5 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -205,11 +205,11 @@ $table->data[0][3] = html_print_checkbox ("recursion", 1, $recursion, $status_list = array (); -$status_list[AGENT_STATUS_NORMAL] = __('Normal'); +$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); +$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data[1][0] = __('Status'); $table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected', diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 336b479da3..89f6890aa8 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -288,11 +288,11 @@ $table->rowclass['form_agents_2'] = 'select_agents_row'; $table->data['form_agents_2'][0] = __('Status'); $table->colspan['form_agents_2'][1] = 2; $status_list = array (); -$status_list[AGENT_STATUS_NORMAL] = __('Normal'); +$status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); +$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data['form_agents_2'][1] = html_print_select($status_list, 'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 537227ffc4..0c2debac22 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -306,7 +306,7 @@ if (check_acl ($config['id_user'], 0, "PM")) { $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]["enterprise"] = $extension['enterprise']; $menu_godmode[$extmenu['fatherId']]['hasExtensions'] = true; } - else{ + else { $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["text"] = __($extmenu['name']); $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["refr"] = 0; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["icon"] = $extmenu['icon']; @@ -316,7 +316,7 @@ if (check_acl ($config['id_user'], 0, "PM")) { $menu_godmode[$extmenu['fatherId']]['hasExtensions'] = true; } } - else{ + else { $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["text"] = __($extmenu['name']); $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["refr"] = 0; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['sec2']]["icon"] = $extmenu['icon']; diff --git a/pandora_console/godmode/modules/manage_nc_groups_form.php b/pandora_console/godmode/modules/manage_nc_groups_form.php index 4b271ad38b..2ed99d1128 100644 --- a/pandora_console/godmode/modules/manage_nc_groups_form.php +++ b/pandora_console/godmode/modules/manage_nc_groups_form.php @@ -45,7 +45,7 @@ else { } $table->width = '98%'; -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; if ($id) { diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index aa55ef66e2..e8114a779c 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -262,7 +262,7 @@ if ($update_component) { $custom_string_1 = $snmp3_privacy_method; $custom_string_2 = $snmp3_privacy_pass; $custom_string_3 = $snmp3_security_level; - //$name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); + //$name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); } if (!empty($name)) { @@ -442,12 +442,12 @@ $search_id_group = (int) get_parameter ('search_id_group'); $search_string = (string) get_parameter ('search_string'); $table->width = '98%'; -if(defined("METACONSOLE")){ +if(defined("METACONSOLE")) { $table->width = '50%'; $table->class = 'databox_filters'; } $table->style = array (); -if (!defined('METACONSOLE')){ +if (!defined('METACONSOLE')) { $table->style[0] = 'font-weight: bold'; $table->style[2] = 'font-weight: bold'; } @@ -501,14 +501,14 @@ $table->data[0][4] .= html_print_submit_button (__('Search'), 'search', false, 'class="sub search"', true); $table->data[0][4] .= ''; -if(defined("METACONSOLE")){ +if (defined("METACONSOLE")) { $filter = '
'; $filter .= html_print_table ($table,true); $filter .= '
'; ui_toggle($filter, __("Show Options")); } -else{ - echo '
'; +else { + echo ''; html_print_table ($table); echo '
'; } @@ -517,7 +517,10 @@ $filter = array (); if ($search_id_group) $filter['id_group'] = $search_id_group; if ($search_string != '') - $filter[] = '(name LIKE "%'.$search_string.'%" OR description LIKE "%'.$search_string.'%" OR tcp_send LIKE "%'.$search_string.'%" OR tcp_rcv LIKE "%'.$search_string.'%")'; + $filter[] = '(name LIKE "%' . $search_string . '%" ' . + 'OR description LIKE "%'. $search_string . '%" ' . + 'OR tcp_send LIKE "%' . $search_string . '%" ' . + 'OR tcp_rcv LIKE "%' . $search_string . '%")'; $total_components = network_components_get_network_components (false, $filter, 'COUNT(*) AS total'); $total_components = $total_components[0]['total']; diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index 305ec701cf..ec765c389b 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -233,7 +233,7 @@ else { echo '
'; /* $table came from manage_network_components_form_common.php */ -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; if ($id) { diff --git a/pandora_console/godmode/modules/manage_network_templates.php b/pandora_console/godmode/modules/manage_network_templates.php index eccdd38aa6..0bde904214 100644 --- a/pandora_console/godmode/modules/manage_network_templates.php +++ b/pandora_console/godmode/modules/manage_network_templates.php @@ -225,7 +225,7 @@ else { echo ''; echo '
'; -html_print_submit_button (__('Create'), "crt", '', 'class="sub next"'); +html_print_submit_button (__('Create'), "crt", '', 'class="sub next"'); echo '
'; ?> diff --git a/pandora_console/godmode/modules/manage_network_templates_form.php b/pandora_console/godmode/modules/manage_network_templates_form.php index c4ecde4e4b..fec049e970 100644 --- a/pandora_console/godmode/modules/manage_network_templates_form.php +++ b/pandora_console/godmode/modules/manage_network_templates_form.php @@ -267,10 +267,18 @@ if ($id_np > 0) { $group_filter .= ''; if ($ncgroup > 0) { - $sql = sprintf ("SELECT id_nc, name, id_group FROM tnetwork_component WHERE id_group = %d AND name LIKE '%".$ncfilter."%' ORDER BY name", $ncgroup); + $sql = sprintf (" + SELECT id_nc, name, id_group + FROM tnetwork_component + WHERE id_group = %d AND name LIKE '%" . $ncfilter . "%' + ORDER BY name", $ncgroup); } else { - $sql = "SELECT id_nc, name, id_group FROM tnetwork_component WHERE name LIKE '%".$ncfilter."%' ORDER BY name"; + $sql = " + SELECT id_nc, name, id_group + FROM tnetwork_component + WHERE name LIKE '%" . $ncfilter . "%' + ORDER BY name"; } $result = db_get_all_rows_sql ($sql); diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index 69d925aed7..5f6acf2a00 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -49,7 +49,7 @@ else { ui_meta_print_page_header($nav_bar); - ui_meta_print_header(__("Netflow filters")); + ui_meta_print_header(__("Netflow filters")); } $delete = (bool) get_parameter ('delete'); @@ -81,7 +81,7 @@ if ($multiple_delete) { $ids = (array)get_parameter('delete_multiple', array()); foreach ($ids as $id) { - $id_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id); + $id_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id); $result = db_process_sql_delete ('tnetflow_filter', array ('id_sg' => $id)); @@ -112,7 +112,7 @@ if ($filters === false) $filters = array (); $table->width = '90%'; -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->width = '100%'; } $table->head = array (); diff --git a/pandora_console/godmode/netflow/nf_edit_form.php b/pandora_console/godmode/netflow/nf_edit_form.php index 9fc235cbbf..d3742ac428 100644 --- a/pandora_console/godmode/netflow/nf_edit_form.php +++ b/pandora_console/godmode/netflow/nf_edit_form.php @@ -68,7 +68,7 @@ else { ui_meta_print_page_header($nav_bar); - ui_meta_print_header(__("Netflow filters")); + ui_meta_print_header(__("Netflow filters")); } if ($id) { @@ -91,7 +91,7 @@ else { $dst_port = ''; $src_port = ''; $aggregate = 'none'; - $output = 'bytes'; + $output = 'bytes'; $advanced_filter = ''; } @@ -173,7 +173,7 @@ $table->border = 0; $table->cellspacing = 3; $table->cellpadding = 5; $table->class = "databox_color"; -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; if($id) @@ -183,7 +183,7 @@ if (defined('METACONSOLE')){ $table->head_colspan[0] = 5; $table->headstyle[0] = 'text-align: center'; } -else{ +else { $table->style[0] = 'vertical-align: top;'; } diff --git a/pandora_console/godmode/netflow/nf_item_list.php b/pandora_console/godmode/netflow/nf_item_list.php index 76a97d4e4f..904607a197 100644 --- a/pandora_console/godmode/netflow/nf_item_list.php +++ b/pandora_console/godmode/netflow/nf_item_list.php @@ -195,14 +195,14 @@ $last_item = $item_max['id_rc']; foreach ($reports_item as $item) { $data = array (); - if (($item['id_rc'] == $first_item) && ($item['id_rc'] == $last_item)){ + if (($item['id_rc'] == $first_item) && ($item['id_rc'] == $last_item)) { $data[0] = ' '; } - else if (($item['id_rc'] == $first_item) && ($item['id_rc'] != $last_item)){ + else if (($item['id_rc'] == $first_item) && ($item['id_rc'] != $last_item)) { $data[0] = ' '; $data[0] .= '' . html_print_image("images/down.png", true, array("title" => __('Move to down'))) . ''; } - else if (($item['id_rc'] == $last_item) && ($item['id_rc'] != $first_item)){ + else if (($item['id_rc'] == $last_item) && ($item['id_rc'] != $first_item)) { $data[0] = '' . html_print_image("images/up.png", true, array("title" => __('Move to up'))) . ''; } else { diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index a21ef4f277..6ac807de01 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -73,7 +73,7 @@ if ($editGraph) { } // Modules table -if(count($module_array) > 0){ +if (count($module_array) > 0) { echo ""; echo " @@ -81,9 +81,9 @@ if(count($module_array) > 0){ "; $color = 0; - for ($a = 0; $a < count($module_array); $a++){ + for ($a = 0; $a < count($module_array); $a++) { // Calculate table line color - if ($color == 1){ + if ($color == 1) { $tdcolor = "datos"; $color = 0; } @@ -91,7 +91,7 @@ if(count($module_array) > 0){ $tdcolor = "datos2"; $color = 1; } - + echo ""; echo ""; diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 8d6165eec8..3e8f28edd4 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -30,7 +30,7 @@ if (is_ajax ()) { $filter = array (); $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; - $filter['id_grupo'] = $id_group; + $filter['id_grupo'] = $id_group; $agents = agents_get_agents ($filter, array ('nombre', 'direccion')); if ($agents === false) @@ -41,9 +41,9 @@ if (is_ajax ()) { } return; - } - - return; + } + + return; } check_login (); diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index c253c8e335..8a199d7c3f 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -28,7 +28,7 @@ if (is_ajax ()) { $filter = array (); $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; - $filter['id_grupo'] = $id_group; + $filter['id_grupo'] = $id_group; $agents = agents_get_agents ($filter, array ('nombre', 'direccion')); if ($agents === false) @@ -39,9 +39,9 @@ if (is_ajax ()) { } return; - } - - return; + } + + return; } check_login (); @@ -110,7 +110,7 @@ if ($update_graph) { $height = get_parameter('height'); $period = get_parameter('period'); $stacked = get_parameter('stacked'); - $alerts = get_parameter('alerts'); + $alerts = get_parameter('alerts'); if (trim($name) != "") { @@ -202,7 +202,7 @@ if (isset($name)) $head .= " - ".$name; // Header -$tab = get_parameter("tab", ""); +$tab = get_parameter("tab", ""); switch ($tab) { case "main": ui_print_page_header ($head, "images/chart.png", false, "graph_builder", false, $buttons); diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index de161a895f..2d132e04d5 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -38,7 +38,7 @@ $buttons['graph_list'] = array('active' => true, 'text' => '' . html_print_image("images/list.png", true, array ("title" => __('Graph list'))) .''); -if ($enterpriseEnable){ +if ($enterpriseEnable) { $buttons = reporting_enterprise_add_template_graph_tabs($buttons); } diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 8cafce0859..855d958c7f 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -153,7 +153,7 @@ if ($delete_layout || $copy_layout) { $id_relations[$old_id] = 0; if ($result !== false) { - $id_relations[$old_id] = $result; + $id_relations[$old_id] = $result; } if ($result) @@ -223,7 +223,7 @@ $table->align[4] = 'left'; // or has "VR" privileges, otherwise show only maps of user group $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || $vconsoles_read) - $maps = visual_map_get_user_layouts (); + $maps = visual_map_get_user_layouts (); else $maps = visual_map_get_user_layouts ($config['id_user'], false, false, false); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index b9f39acfcc..73499784cf 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -189,7 +189,7 @@ switch ($action) { $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); $period = $item['period']; // 'top_n_value' field will be reused for projection report - if ($type == 'projection_graph'){ + if ($type == 'projection_graph') { $projection_period = $item['top_n_value']; $period_pg = $item['period']; } @@ -545,16 +545,16 @@ else ?>
".__('Agent')."".__('Weight')." ".__('Delete')."
" . $agent_array[$a] . ""; echo modules_get_agentmodule_name ($module_array[$a])."
- - - - "; - } - ?> + if (defined("METACONSOLE")) { + echo " + + + + "; + } + ?> @@ -795,7 +795,7 @@ else $agent_name = ''; if (metaconsole_load_external_db($connection) == NOERR) - $agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent)); + $agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent)); // Append server name if (!empty($agent_name)) $agent_name .= ' (' . $server_name . ')'; @@ -962,8 +962,10 @@ else $metaconsole_connections = array(); } $result_servers = array(); - foreach ($metaconsole_connections as $metaconsole_element){ - $connection_data = enterprise_hook('metaconsole_get_connection', array($metaconsole_element)); + foreach ($metaconsole_connections as $metaconsole_element) { + $connection_data = enterprise_hook( + 'metaconsole_get_connection', + array($metaconsole_element)); $result_servers[$connection_data['server_name']] = $connection_data['server_name']; } // Print select combo with metaconsole servers @@ -1710,7 +1712,7 @@ function edit_custom_graph() { var id_element_graph; var id_server; - if (id_graph.indexOf("|") != -1){ + if (id_graph.indexOf("|") != -1) { agent_server_temp = id_graph.split('|'); id_element_graph = agent_server_temp[0]; id_server = agent_server_temp[1]; diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 110b2e83e1..9569bd87be 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -279,7 +279,7 @@ $table->style[0] = 'text-align: right;'; if ($items) { $table->width = '98%'; - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { $table->width = '100%'; $table->class = "databox data"; } @@ -448,7 +448,7 @@ foreach ($items as $item) { metaconsole_restore_db(); } } -if (defined("METACONSOLE")){ +if (defined("METACONSOLE")) { if ($items != false) { ui_pagination ($countItems, 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $idReport . $urlFilter); html_print_table($table); @@ -491,13 +491,13 @@ $table->size[0] = '25%'; $table->size[1] = '25%'; $table->size[2] = '25%'; $table->size[3] = '25%'; -if (defined("METACONSOLE")){ +if (defined("METACONSOLE")) { $table->class = "databox data"; $table->head[0] = __("Sort items"); $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align: center'; } -else{ +else { $table->data[0][0] = "". __("Sort items") . ""; } $table->data[1][0] = __('Sort selected items from position: '); @@ -522,13 +522,13 @@ $table->size[0] = '25%'; $table->size[1] = '25%'; $table->size[2] = '25%'; $table->size[3] = '25%'; -if (defined("METACONSOLE")){ +if (defined("METACONSOLE")) { $table->class = "databox data"; $table->head[0] = __("Delete items"); $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align: center'; } -else{ +else { $table->data[0][0] = "". __("Delete items") . ""; } $table->data[1][0] = __('Delete selected items from position: '); @@ -594,6 +594,11 @@ function added_ids_sorted_items_to_hidden_input() { function only_numbers(name) { var value = $("input[name='" + name + "']").val(); + if (value == "") { + // Do none it is a empty field. + return; + } + value = parseInt(value); if (isNaN(value)) { diff --git a/pandora_console/godmode/reporting/reporting_builder.main.php b/pandora_console/godmode/reporting/reporting_builder.main.php index 24c3f6530d..7db2c14e65 100755 --- a/pandora_console/godmode/reporting/reporting_builder.main.php +++ b/pandora_console/godmode/reporting/reporting_builder.main.php @@ -31,13 +31,13 @@ switch ($action) { case 'new': $actionButtonHtml = html_print_submit_button(__('Save'), 'add', false, 'class="sub wand"', true); - $hiddenFieldAction = 'save'; + $hiddenFieldAction = 'save'; break; case 'update': case 'edit': $actionButtonHtml = html_print_submit_button(__('Update'), 'edit', false, 'class="sub upd"', true); - $hiddenFieldAction = 'update'; + $hiddenFieldAction = 'update'; break; } @@ -47,7 +47,7 @@ $table->id = 'add_alert_table'; $table->class = 'databox'; $table->head = array (); -if(defined("METACONSOLE")){ +if (defined("METACONSOLE")) { $table->width = '100%'; $table->class = 'databox data'; $table->head[0] = __('Main data'); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 5ac34f7e66..88a0bc5dc0 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -374,7 +374,7 @@ switch ($action) { $table_aux->class = 'databox filters'; $table_aux->cellpadding = 0; $table_aux->cellspacing = 0; - if(defined('METACONSOLE')){ + if (defined('METACONSOLE')) { $table_aux->class = 'databox_filters'; $table_aux->width = '96%'; $table_aux->cellpadding = 0; @@ -390,14 +390,14 @@ switch ($action) { $table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true); - if(defined('METACONSOLE')){ + if (defined('METACONSOLE')) { $filter = ""; $filter .= html_print_table($table_aux,true); $filter .= ""; ui_toggle($filter, __("Show Option")); } - else{ + else { echo ""; html_print_table($table_aux); @@ -471,7 +471,7 @@ switch ($action) { $table->class = 'databox data'; $table->cellpadding = 0; $table->cellspacing = 0; - if(defined('METACONSOLE')){ + if (defined('METACONSOLE')) { $table->class = 'databox'; $table->width = '100%'; } @@ -579,7 +579,7 @@ switch ($action) { $data[$next] = ui_print_group_icon( - $report['id_group'], true, "groups_small", '', !defined('METACONSOLE')); + $report['id_group'], true, "groups_small", '', !defined('METACONSOLE')); $next++; } @@ -656,7 +656,7 @@ switch ($action) { } html_print_table ($table); } - else{ + else { ui_print_info_message ( array ( 'no_close' => true, 'message' => __('No data found.') ) ); } if (check_acl ($config['id_user'], 0, "RW")) { @@ -853,7 +853,7 @@ switch ($action) { $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); // Checks intervals fields - if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)){ + if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { $good_format = true; } $intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval'); @@ -1115,7 +1115,7 @@ switch ($action) { $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); // Checks intervals fields - if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)){ + if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { $good_format = true; } $intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval'); diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index b9bb134dfc..603d3a2083 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -483,7 +483,7 @@ foreach ($layoutDatas as $layoutData) { $table->rowclass[$i + 1] = 'rowPair'; $table->rowclass[$i + 2] = 'rowPair'; } - $alternativeStyle = !$alternativeStyle; + $alternativeStyle = !$alternativeStyle; $i = $i + 3; } diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 3bfcb8804d..6bea8bfbde 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -573,7 +573,7 @@ if ($action == 'new' || $idVisualConsole === false) { } $buttons[$activeTab]['active'] = true; - + if (!defined('METACONSOLE')) { ui_print_page_header($visualConsoleName, "images/visual_console.png", false, diff --git a/pandora_console/godmode/reporting/visual_console_builder.wizard.php b/pandora_console/godmode/reporting/visual_console_builder.wizard.php index 2196865ded..d3af899224 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.wizard.php +++ b/pandora_console/godmode/reporting/visual_console_builder.wizard.php @@ -188,7 +188,7 @@ $table->rowstyle["all_3"] = 'display: none;'; $table->data["all_3"][0] = __('Groups'); $table->colspan["all_3"][1] = "3"; $table->data["all_3"][1] = html_print_select_groups( - $config['id_user'], "AR", true, 'groups', '', '', '', 0, true); + $config['id_user'], "AR", true, 'groups', '', '', '', 0, true); $table->rowstyle["all_one_item_per_agent"] = 'display: none'; diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index 25f621afd6..6e5d84a4f0 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -156,7 +156,7 @@ if (isset($_GET["update"])) { else { if (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network)) $reason = __('Incorrect format in Subnet field'); - $result = false; + $result = false; } } else @@ -254,7 +254,7 @@ if ($result !== false) { $table->cellpadding = 4; $table->cellspacing = 4; $table->class = "databox"; - $table->data = array (); + $table->data = array (); $table->style[8] = 'text-align: center;'; diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 2d1ea57510..22d84026cc 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -263,12 +263,12 @@ if (($create != "") OR ($view != "")) { $table->colspan['plugin_desc'][1] = 3; $table->data['plugin_desc'] = $data; - if (!defined("METACONSOLE")){ + if (!defined("METACONSOLE")) { echo '
'; echo '
- " . __('Item Editor') . " -
+ " . __('Item Editor') . " +
'; } - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { $table->width = '100%'; $table->class = 'databox data'; $table->head[0] = __('General'); @@ -276,8 +276,9 @@ if (($create != "") OR ($view != "")) { $table->headstyle[0] = 'text-align: center'; echo '
'; html_print_table($table); - }else{ - echo '
'.__('General').''; + } + else { + echo '
' . __('General') . ''; html_print_table($table); echo '
'; } @@ -330,7 +331,7 @@ if (($create != "") OR ($view != "")) { $data[1] = '
'; $table->data['plugin_preview'] = $data; - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { $table->width = '100%'; $table->class = 'databox data'; $table->head[0] = __('Command'); @@ -338,8 +339,9 @@ if (($create != "") OR ($view != "")) { $table->headstyle[0] = 'text-align: center'; echo '
'; html_print_table($table); - }else{ - echo '
'.__('Command').''; + } + else { + echo '
' . __('Command') . ''; html_print_table($table); echo '
'; } @@ -449,7 +451,7 @@ if (($create != "") OR ($view != "")) { $table->data['plugin_action'] = $datam; } - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { $table->width = '100%'; $table->class = 'databox data'; $table->head[0] = __('Parameters macros'); @@ -457,8 +459,10 @@ if (($create != "") OR ($view != "")) { $table->headstyle[0] = 'text-align: center'; echo '
'; html_print_table($table); - }else{ - echo '
'.__('Parameters macros').ui_print_help_icon ('macros', true).''; + } + else { + echo '
' . + '' . __('Parameters macros') .ui_print_help_icon ('macros', true) . ''; html_print_table($table); echo '
'; } @@ -552,11 +556,12 @@ else { 'execute' => $plugin_execute, 'plugin_type' => $plugin_plugin_type, 'parameters' => $parameters, - 'macros' => $macros); + 'macros' => $macros); $result = false; if ($values['name'] != '' && $values['execute'] != '') - $result = db_process_sql_update('tplugin', $values, array('id' => $plugin_id)); + $result = db_process_sql_update('tplugin', $values, + array('id' => $plugin_id)); if (! $result) { ui_print_error_message(__('Problem updating plugin')); diff --git a/pandora_console/godmode/servers/recon_script.php b/pandora_console/godmode/servers/recon_script.php index 1db2fe9f3c..f590116e33 100644 --- a/pandora_console/godmode/servers/recon_script.php +++ b/pandora_console/godmode/servers/recon_script.php @@ -61,13 +61,13 @@ if ($create != "") { $form_name = ""; $form_description = ""; $form_script = ""; - $macros = ""; + $macros = ""; } // SHOW THE FORM // ================================================================= -if (($create != "") OR ($view != "")){ +if (($create != "") OR ($view != "")) { if ($create != "") ui_print_page_header (__('Recon script creation'), "images/gm_servers.png", false, "reconscript_definition", true); @@ -215,7 +215,7 @@ if (($create != "") OR ($view != "")){ echo ''; echo '"; echo ""; - $color=1; + $color = 1; foreach ($rows as $row) { - if ($color == 1){ + if ($color == 1) { $tdcolor = "datos"; $color = 0; } diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php index fd980b9505..63f9eb857c 100644 --- a/pandora_console/godmode/setup/news.php +++ b/pandora_console/godmode/setup/news.php @@ -190,12 +190,12 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) { echo ""; else echo ""; - echo ""; - + html_print_table($table); echo "
'; - if ($create != ""){ + if ($create != "") { echo ""; } else { @@ -332,7 +332,7 @@ else { else { ui_print_success_message(__('reconscript deleted successfully')); } - if ($reconscript_id != 0){ + if ($reconscript_id != 0) { $result = db_process_sql_delete('trecon_task', array('id_recon_script' => $reconscript_id)); } diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 448f5b48fc..146240baea 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -90,8 +90,8 @@ foreach ($servers as $server) { } // Type - $data[2] = ''.$server["img"]; - if ($server["master"] == 1){ + $data[2] = '' . $server["img"]; + if ($server["master"] == 1) { $data[2] .= ui_print_help_tip (__("This is a master server"), true); } //$data[2] .= ' v' .. ''; @@ -117,7 +117,7 @@ foreach ($servers as $server) { } $data[6] = $server['threads'].' : '.$server['queued_modules']; - if ($server['queued_modules'] > 200){ + if ($server['queued_modules'] > 200) { $data[6] .= clippy_context_help("server_queued_modules"); } $data[7] = ui_print_timestamp ($server['keepalive'], true); @@ -169,7 +169,7 @@ if ($tiny) { if ($tiny) { ui_toggle(html_print_table ($table,true), __('Tactical server information')); } -else{ +else { html_print_table ($table); } ?> diff --git a/pandora_console/godmode/setup/gis.php b/pandora_console/godmode/setup/gis.php index 0982db3de1..6288b3b751 100755 --- a/pandora_console/godmode/setup/gis.php +++ b/pandora_console/godmode/setup/gis.php @@ -79,7 +79,9 @@ if ($mapsConnections !== false) { ui_print_group_icon ($mapsConnection['group_id'], true), '' . html_print_image ("images/cross.png", true).''); + onClick="javascript: if (!confirm(\'' . + __('Do you wan delete this connection?') . '\')) return false;">' . + html_print_image ("images/cross.png", true).''); } } diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index 8e52572653..0c505e4b20 100755 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -471,14 +471,14 @@ function selMapConnectionType() { switch ($('#sel_type :selected').val()) { case 'OSM': $('#form_map_connection_type').html('').hide(); - break; + break; case 'Gmap': // TODO: Validate there is a key, and use it $('#form_map_connection_type').html('').hide(); - break; + break; case 'Static_Image': $('#form_map_connection_type').html('').hide(); - break; + break; default: $('#form_map_connection_type').html('').hide(); break; diff --git a/pandora_console/godmode/setup/links.php b/pandora_console/godmode/setup/links.php index 7527eecdfb..e8fa817d3d 100644 --- a/pandora_console/godmode/setup/links.php +++ b/pandora_console/godmode/setup/links.php @@ -38,7 +38,7 @@ if (isset($_POST["create"])) { // If create if (! $result) ui_print_error_message(__('There was a problem creating link')); else { - ui_print_success_message(__('Successfully created')); + ui_print_success_message(__('Successfully created')); $id_link = $result; } } @@ -66,8 +66,8 @@ if (isset($_GET["borrar"])) { // if delete if (! $result) ui_print_error_message(__('There was a problem deleting link')); else - ui_print_success_message(__('Successfully deleted')); - + ui_print_success_message(__('Successfully deleted')); + } // Main form view for Links edit @@ -136,9 +136,9 @@ else { // Main list view for Links editor echo "".__('Link name')."".__('Delete')."
"; diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 7c0c47bba9..38749a58d9 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -27,12 +27,12 @@ if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_us enterprise_include_once ('godmode/setup/setup.php'); /* - NOTICE FOR DEVELOPERS: - - Update operation is done in config_process.php - This is done in that way so the user can see the changes inmediatly. - If you added a new token, please check config_update_config() in functions_config.php - to add it there. +NOTICE FOR DEVELOPERS: + +Update operation is done in config_process.php +This is done in that way so the user can see the changes inmediatly. +If you added a new token, please check config_update_config() in functions_config.php +to add it there. */ $table = new StdClass(); diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 56c8be9aaa..7dcbe7c2db 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -54,12 +54,12 @@ enterprise_include_once ('include/functions_setup.php'); enterprise_include_once ('godmode/setup/setup.php'); /* - NOTICE FOR DEVELOPERS: - - Update operation is done in config_process.php - This is done in that way so the user can see the changes inmediatly. - If you added a new token, please check config_update_config() in functions_config.php - to add it there. +NOTICE FOR DEVELOPERS: + +Update operation is done in config_process.php +This is done in that way so the user can see the changes inmediatly. +If you added a new token, please check config_update_config() in functions_config.php +to add it there. */ // Gets section to jump to another section diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 56de8cdc4f..89d018a76d 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -98,7 +98,11 @@ $table->data[18][1] .= __('No').'   '.html_print_radio_button ('i if ($config["integria_enabled"]) { require_once('include/functions_incidents.php'); - $invent = incidents_call_api($config['integria_url']."/include/api.php?user=".$config['id_user']."&pass=".io_output_password($config['integria_api_password'])."&op=get_inventories"); + $invent = incidents_call_api( + $config['integria_url'] . "/include/api.php?" . + "user=" . $config['id_user'] . "&" . + "pass=" . io_output_password($config['integria_api_password']) ."&" . + "op=get_inventories"); $bad_input = false; // Wrong connection to api, bad password if (empty($invent)) { @@ -125,21 +129,24 @@ if ($config["integria_enabled"]) { if ((stristr($inv, 'ERROR 404') !== false) OR (stristr($inv, 'Status 404') !== false) OR (stristr($inv, 'Internal Server Error') !== false)) { - $inventories[""] = __('None'); - $bad_input = true; + $inventories[""] = __('None'); + $bad_input = true; break; } } } $table->data[20][0] = __('Integria URL') . ui_print_help_icon ("integria_url", true); - $table->data[20][1] = html_print_input_text ('integria_url', $config["integria_url"], '', 25, 255, true); + $table->data[20][1] = html_print_input_text('integria_url', + $config["integria_url"], '', 25, 255, true); // If something goes wrong - if ($bad_input){ - $table->data[20][1] .= html_print_image('images/error.png', true, array('title' => __('URL and/or Integria password are incorrect'))); + if ($bad_input) { + $table->data[20][1] .= html_print_image('images/error.png', + true, array('title' => __('URL and/or Integria password are incorrect'))); } $table->data[21][0] = __('Integria API password'); - $table->data[21][1] = html_print_input_text ('integria_api_password', io_output_password($config["integria_api_password"]), '', 25, 25, true); + $table->data[21][1] = html_print_input_text('integria_api_password', + io_output_password($config["integria_api_password"]), '', 25, 25, true); if (!$bad_input) { foreach ($invent as $inv) { @@ -190,8 +197,11 @@ foreach ($timezones as $timezone) { } } -$table->data[23][0] = __('Timezone setup'). ' ' . ui_print_help_tip (__('Must have the same time zone as the system or database to avoid mismatches of time.'), true); -$table->data[23][1] = html_print_input_text_extended ('timezone_text', $config["timezone"], 'text-timezone_text', '', 25, 25, false, '', 'readonly', true); +$table->data[23][0] = __('Timezone setup'). ' ' . ui_print_help_tip( + __('Must have the same time zone as the system or database to avoid mismatches of time.'), true); +$table->data[23][1] = html_print_input_text_extended( + 'timezone_text', $config["timezone"], 'text-timezone_text', '', 25, + 25, false, '', 'readonly', true); $table->data[23][1] .= ''.html_print_image ('images/pencil.png', true, array ('title' => __('Change timezone'))).''; $table->data[23][1] .= "  ". html_print_select($zone_name, 'zone', $zone_selected, 'show_timezone();', '', '', true); $table->data[23][1] .= "  ". html_print_select($timezone_n, 'timezone', $config["timezone"], '', '', '', true); @@ -310,18 +320,18 @@ function show_timezone () { url: "ajax.php", data: "page=&select_timezone=1&zone=" + zone, dataType: "json", - success: function(data){ - $("#timezone").empty(); - jQuery.each (data, function (id, value) { - timezone = value; - $("select[name='timezone']").append($("
"; $table->data[$row][1] .= __('Value') . ': ' . @@ -187,324 +558,6 @@ $table->data[$row][1] .= html_print_input_hidden ('interval_values', $config["in // This hidden field will be filled from jQuery before submit $table->data[$row][1] .= html_print_input_hidden ('interval_to_delete', '', true); //---------------------------------------------------------------------- - - - -$row++; -$table->data[$row][0] = __('Style template'); -$table->data[$row][1] = html_print_select (themes_get_css (), 'style', $config["style"].'.css', '', '', '', true); - -$row++; - -$table->data[$row][0] = __('Block size for pagination'); -$table->data[$row][1] = html_print_input_text ('block_size', $config["global_block_size"], '', 5, 5, true); - -$row++; - -$table->data[$row][0] = __('Use round corners'); -$table->data[$row][1] = __('Yes').' '.html_print_radio_button ('round_corner', 1, '', $config["round_corner"], true).'  '; -$table->data[$row][1] .= __('No').' '.html_print_radio_button ('round_corner', 0, '', $config["round_corner"], true); - -$row++; - -$table->data[$row][0] = __('Status icon set'); -$iconsets["default"] = __('Colors'); -$iconsets["faces"] = __('Faces'); -$iconsets["color_text"] = __('Colors and text'); -$table->data[$row][1] = html_print_select ($iconsets, 'status_images_set', $config["status_images_set"], '', '', '', true); -$table->data[$row][1] .= " " . html_print_button(__("View"), 'status_set_preview', false, '', '', true); - -$row++; - -$table->data[$row][0] = __('Font path'); -$fonts = load_fonts(); -$table->data[$row][1] = html_print_select($fonts, 'fontpath', $config["fontpath"], '', '', 0, true); - -$row++; - -$table->data[$row][0] = __('Font size'); - -$font_size_array = array( - 1 => 1, - 2 => 2, - 3 => 3, - 4 => 4, - 5 => 5, - 6 => 6, - 7 => 7, - 8 => 8, - 9 => 9, - 10 => 10, - 11 => 11, - 12 => 12, - 13 => 13, - 14 => 14, - 15 => 15); - -$table->data[$row][1] = html_print_select($font_size_array, 'font_size', $config["font_size"], '', '', 0, true); - -$row++; - -$table->data[$row][0] = __('Interactive charts') . ui_print_help_tip(__('Whether to use Javascript or static PNG graphs'), true); -$table->data[$row][1] = __('Yes').' '.html_print_radio_button ('flash_charts', 1, '', $config["global_flash_charts"], true).'  '; -$table->data[$row][1] .= __('No').' '.html_print_radio_button ('flash_charts', 0, '', $config["global_flash_charts"], true); - -$row++; - -$table->data[$row][0] = __('Custom logo') . ui_print_help_icon("custom_logo", true); -$table->data[$row][1] = html_print_select( - list_files('images/custom_logo', "png", 1, 0), 'custom_logo', - $config["custom_logo"], '', '', '', true); -$table->data[$row][1] .= " " . html_print_button(__("View"), 'custom_logo_preview', false, '', '', true); - -$row++; - -$table->data[$row][0] = __('Login background') . ui_print_help_tip(__('You can place your custom images into the folder images/backgrounds/'), true); -$backgrounds_list_jpg = list_files("images/backgrounds", "jpg", 1, 0); -$backgrounds_list_gif = list_files("images/backgrounds", "gif", 1, 0); -$backgrounds_list_png = list_files("images/backgrounds", "png", 1, 0); -$backgrounds_list = array_merge($backgrounds_list_jpg, $backgrounds_list_png); -$backgrounds_list = array_merge($backgrounds_list, $backgrounds_list_gif); -asort($backgrounds_list); -$table->data[$row][1] = html_print_select ($backgrounds_list, - 'login_background', $config["login_background"], '', __('Default'), - '', true); -$table->data[$row][1] .= " " . html_print_button(__("View"), 'login_background_preview', false, '', '', true); - -$row++; - -$values = array (); -$values[5] = human_time_description_raw (5); -$values[30] = human_time_description_raw (30); -$values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE); -$values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES); -$values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES); -$values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES); -$values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES); - -$table->data[$row][0] = __('Default interval for refresh on Visual Console') . ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); -$table->data[$row][1] = html_print_select ($values, 'vc_refr', $config["vc_refr"], '', 'N/A', 0, true, false, false); - -$row++; - -if (empty($config["vc_line_thickness"])) $config["vc_line_thickness"] = 2; -$table->data[$row][0] = __('Default line thickness for the Visual Console') . ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true); -$table->data[$row][1] = html_print_input_text ('vc_line_thickness', $config["vc_line_thickness"], '', 5, 5, true); - -$row++; - -$table->data[$row][0] = __('Agent size text') . ui_print_help_tip(__('When the agent name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); -$table->data[$row][1] = __('Small:') . html_print_input_text ('agent_size_text_small', $config["agent_size_text_small"], '', 3, 3, true); -$table->data[$row][1] .= ' ' . __('Normal:') . html_print_input_text ('agent_size_text_medium', $config["agent_size_text_medium"], '', 3, 3, true); - -$row++; - -$table->data[$row][0] = __('Module size text') . ui_print_help_tip(__('When the module name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); -$table->data[$row][1] = __('Small:') . html_print_input_text ('module_size_text_small', $config["module_size_text_small"], '', 3, 3, true); -$table->data[$row][1] .= ' ' . __('Normal:') . html_print_input_text ('module_size_text_medium', $config["module_size_text_medium"], '', 3, 3, true); - -$row++; - -$table->data[$row][0] = __('Description size text') . ui_print_help_tip(__('When the description name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); -$table->data[$row][1] = html_print_input_text ('description_size_text', $config["description_size_text"], '', 3, 3, true); - -$row++; - -$table->data[$row][0] = __('Item title size text') . - ui_print_help_tip(__('When the item title name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true); -$table->data[$row][1] = html_print_input_text('item_title_size_text', - $config["item_title_size_text"], '', 3, 3, true); - -$row++; - -$table->data[$row][0] = __('GIS Labels') . - ui_print_help_tip(__('This enabling this, you get a label with agent name in GIS maps. If you have lots of agents in the map, will be unreadable. Disabled by default.'), true); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('gis_label', 1, '', $config["gis_label"], true).'  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('gis_label', 0, '', $config["gis_label"], true); - -$row++; - -$listIcons = gis_get_array_list_icons(); - -$arraySelectIcon = array(); -foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index; - -$table->data[$row][0] = __('Default icon in GIS') . ui_print_help_tip(__('Agent icon for GIS Maps. If set to "none", group icon will be used'), true); -$table->data[$row][1] = html_print_select($arraySelectIcon, - "gis_default_icon", $config["gis_default_icon"], "", __('None'), - '', true); -$table->data[$row][1] .= " " . html_print_button(__("View"), 'gis_icon_preview', false, '', '', true); - -$row++; - -// For 5.1 Autohidden menu feature - -$table->data['autohidden'][0] = __('Autohidden menu'); -$table->data['autohidden'][1] = html_print_checkbox('autohidden_menu', - 1, $config['autohidden_menu'], true); - -// Juanma (07/05/2014) New feature: Table for custom front page for reports - -$table->data[$row][0] = __('Custom report front page') . - ui_print_help_tip(__('Custom report front page. It will be applied to all reports and templates by default.'), true); -$table->data[$row][1] = html_print_checkbox('custom_report_front', 1, - $config['custom_report_front'], true); - -$row++; - -$dirItems = scandir($config['homedir'] . '/images/custom_logo'); - -foreach ($dirItems as $entryDir) { - if (strstr($entryDir, '.jpg') !== false) { - $customLogos['images/custom_logo/' . $entryDir] = $entryDir; - } -} - -$_fonts = array(); -$dirFonts = scandir(_MPDF_TTFONTPATH); -foreach ($dirFonts as $entryDir) { - if (strstr($entryDir, '.ttf') !== false) { - $_fonts[$entryDir] = $entryDir; - } -} - -// Font -$table->data['custom_report_front-font'][0] = __('Custom report front') . ' - ' . __('Font family'); -$table->data['custom_report_front-font'][1] = html_print_select ($_fonts, - 'custom_report_front_font', $config['custom_report_front_font'], - false, __('Default'), '', true); - -// Logo -$table->data['custom_report_front-logo'][0] = __('Custom report front') . ' - ' . - __('Custom logo') . - ui_print_help_tip( - __("The dir of custom logos is in your www Pandora Console in \"images/custom_logo\". You can upload more files (ONLY JPEG) in upload tool in console."), true); -$table->data['custom_report_front-logo'][1] = html_print_select( - $customLogos, - 'custom_report_front_logo', - $config['custom_report_front_logo'], - 'showPreview()', - __('Default'), - '', - true); - -// Preview -$table->data['custom_report_front-preview'][0] = __('Custom report front') . ' - ' . 'Preview'; -if (empty($config['custom_report_front_logo'])) { - $config['custom_report_front_logo'] = 'images/pandora_logo_white.jpg'; -} -$table->data['custom_report_front-preview'][1] = '' . - html_print_image ($config['custom_report_front_logo'], true) . ''; - -// Header -$table->data['custom_report_front-header'][0] = __('Custom report front') . ' - ' . __('Header'); -$table->data['custom_report_front-header'][1] = html_print_textarea('custom_report_front_header', 5, 15, - $config['custom_report_front_header'], 'style="width: 38em;"', true); - -// First page -$table->data['custom_report_front-first_page'][0] = __('Custom report front') . ' - ' . __('First page'); -$table->data['custom_report_front-first_page'][1] = html_print_textarea('custom_report_front_firstpage', 15, 15, - $config['custom_report_front_firstpage'], 'style="width: 38em; height: 20em;"', true); - -// Footer -$table->data['custom_report_front-footer'][0] = __('Custom report front') . ' - ' . __('Footer'); -$table->data['custom_report_front-footer'][1] = html_print_textarea('custom_report_front_footer', 5, 15, - $config['custom_report_front_footer'], 'style="width: 38em;"', true); - - -$table->data[$row][0] = __('Paginate module view'); -$table->data[$row][1] = html_print_checkbox('paginate_module', 1, - $config['paginate_module'], true); - -$row++; - -$table->data[$row][0] = __('Show QR Code icon in the header'); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('show_qr_code_header', 1, '', - $config["show_qr_code_header"], true) . - '  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('show_qr_code_header', 0, '', - $config["show_qr_code_header"], true); - -$row++; - -$table->data[$row][0] = __('Custom graphviz directory') . - ui_print_help_tip (__("Custom directory where the graphviz binaries are stored."), true); -$table->data[$row][1] = html_print_input_text ('graphviz_bin_dir', - $config["graphviz_bin_dir"], '', 50, 255, true); - -$row++; - -$table->data[$row][0] = __('Networkmap max width'); -$table->data[$row][1] = html_print_input_text ('networkmap_max_width', - $config["networkmap_max_width"], '', 10, 20, true); - -$row++; - -$table->data[$row][0] = __('Fixed header'); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('fixed_header', 1, '', $config["fixed_header"], true) . - '  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('fixed_header', 0, '', $config["fixed_header"], true); - -$row++; - -$table->data[$row][0] = __('Fixed menu'); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('fixed_menu', 1, '', $config["fixed_menu"], true) . - '  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('fixed_menu', 0, '', $config["fixed_menu"], true); - -$row++; - -if (!isset($config["short_module_graph_data"])) - $config["short_module_graph_data"] = true; - -$table->data[$row][0] = __('Shortened module graph data'); -$table->data[$row][0] .= ui_print_help_tip(__('The data number of the module graphs will be rounded and shortened'), true); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('short_module_graph_data', 1, '', - $config["short_module_graph_data"], true) . - '  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('short_module_graph_data', 0, '', - $config["short_module_graph_data"], true); - -$row++; - - -$table->data[$row][0] = __('Show only the group name'); -$table->data[$row][0] .= ui_print_help_tip( - __('Show the group name instead the group icon.'), true); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('show_group_name', 1, '', - $config["show_group_name"], true) . - '  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('show_group_name', 0, '', - $config["show_group_name"], true); -$row++; - -$table->data[$row][0] = __('Default line thickness for the Custom Graph.'); -$table->data[$row][1] = html_print_input_text ('custom_graph_widht', - $config["custom_graph_widht"], '', 5, 5, true); - -$row++; - -$table->data[$row][0] = __('Render data of module type is proc.'); -$table->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('render_proc', 1, '', - $config["render_proc"], true) . - '  '; -$table->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('render_proc', 0, '', - $config["render_proc"], true); - $row++; diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 966de85031..74c80da41e 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -104,11 +104,11 @@ if ($save_alert || $modify_alert) { $max_alerts = (int) get_parameter_post ("max_alerts", 1); $min_alerts = (int) get_parameter_post ("min_alerts", 0); $priority = (int) get_parameter_post ("priority", 0); - $custom_oid_data_1 = (string) get_parameter ("custom_oid_data_1"); - $custom_oid_data_2 = (string) get_parameter ("custom_oid_data_2"); - $custom_oid_data_3 = (string) get_parameter ("custom_oid_data_3"); - $custom_oid_data_4 = (string) get_parameter ("custom_oid_data_4"); - $custom_oid_data_5 = (string) get_parameter ("custom_oid_data_5"); + $custom_oid_data_1 = (string) get_parameter ("custom_oid_data_1"); + $custom_oid_data_2 = (string) get_parameter ("custom_oid_data_2"); + $custom_oid_data_3 = (string) get_parameter ("custom_oid_data_3"); + $custom_oid_data_4 = (string) get_parameter ("custom_oid_data_4"); + $custom_oid_data_5 = (string) get_parameter ("custom_oid_data_5"); $custom_oid_data_6 = (string) get_parameter ("custom_oid_data_6"); $custom_oid_data_7 = (string) get_parameter ("custom_oid_data_7"); $custom_oid_data_8 = (string) get_parameter ("custom_oid_data_8"); @@ -146,9 +146,9 @@ if ($save_alert || $modify_alert) { $order_20 = (int) get_parameter ("order_20", 20); $trap_type = (int) get_parameter ("trap_type", -1); - $single_value = (string) get_parameter ("single_value"); - $position = (int) get_parameter ("position"); - $group = (int) get_parameter ("group"); + $single_value = (string) get_parameter ("single_value"); + $position = (int) get_parameter ("position"); + $group = (int) get_parameter ("group"); if ($time_threshold == -1) { $time_threshold = $time_other; @@ -354,7 +354,7 @@ if ($update_alert) { $order_19 = $alert["order_19"]; $order_20 = $alert["order_20"]; $trap_type = $alert["trap_type"]; - $single_value = $alert["single_value"]; + $single_value = $alert["single_value"]; $position = $alert["position"]; $group = $alert["id_group"]; } diff --git a/pandora_console/godmode/tag/edit_tag.php b/pandora_console/godmode/tag/edit_tag.php index aa00f29fa9..a2fe7e5bd8 100644 --- a/pandora_console/godmode/tag/edit_tag.php +++ b/pandora_console/godmode/tag/edit_tag.php @@ -69,7 +69,7 @@ else { if ($update_tag && $id_tag != 0) { // Erase comma characters on tag name - $name_tag = str_replace(',', '', $name_tag); + $name_tag = str_replace(',', '', $name_tag); $values = array(); $values['name'] = $name_tag; @@ -98,7 +98,7 @@ if ($create_tag) { $return_create = true; // Erase comma characters on tag name - $name_tag = str_replace(',', '', $name_tag); + $name_tag = str_replace(',', '', $name_tag); $data = array(); $data['name'] = $name_tag; @@ -130,7 +130,7 @@ if ($create_tag) { // Get results when update action is performed if ($action == "update" && $id_tag != 0) { $result_tag = tags_search_tag_id($id_tag); - $name_tag = $result_tag["name"]; + $name_tag = $result_tag["name"]; $description_tag = $result_tag["description"]; $url_tag = $result_tag["url"]; $email_tag = $result_tag["email"]; @@ -164,15 +164,15 @@ else } echo ""; echo ""; - echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; - html_print_label (__("Name"),'name'); + html_print_label (__("Name"), 'name'); echo ""; - html_print_input_text ('name_tag', $name_tag); + echo ""; + html_print_input_text ('name_tag', $name_tag); echo "
"; - html_print_label (__("Description"),'name'); + html_print_label (__("Description"), 'name'); echo ""; html_print_input_text ('description_tag', $description_tag); @@ -180,8 +180,9 @@ else echo "
"; - echo '' . __("Url") . ''; - echo ui_print_help_tip (__("Hyperlink to help information that has to exist previously."), true); + echo '' . __("Url") . ''; + echo ui_print_help_tip( + __("Hyperlink to help information that has to exist previously."), true); echo ""; html_print_input_text ('url_tag', $url_tag); @@ -189,8 +190,9 @@ else echo "
"; - echo '' . __("Email") . ''; - echo ui_print_help_tip (__("Associated Email direction to use later in alerts associated to Tags."), true); + echo '' . __("Email") . ''; + echo ui_print_help_tip( + __("Associated Email direction to use later in alerts associated to Tags."), true); echo ""; html_print_textarea('email_tag', 5, 20, $email_tag); @@ -198,8 +200,9 @@ else echo "
"; - echo '' . __("Phone") . ''; - echo ui_print_help_tip (__("Associated phone number to use later in alerts associated to Tags."), true); + echo '' . __("Phone") . ''; + echo ui_print_help_tip( + __("Associated phone number to use later in alerts associated to Tags."), true); echo ""; html_print_textarea('phone_tag', 5, 20, $phone_tag); diff --git a/pandora_console/godmode/tag/tag.php b/pandora_console/godmode/tag/tag.php index 0ac28b27ed..6a0ba26498 100644 --- a/pandora_console/godmode/tag/tag.php +++ b/pandora_console/godmode/tag/tag.php @@ -140,7 +140,8 @@ if (!defined('METACONSOLE')) { echo "
"; -}else{ +} +else { $filters = ''; $filters .= ""; @@ -243,7 +244,7 @@ if (!empty($result)) { html_print_table ($table); } -if(defined("METACONSOLE")){ +if (defined("METACONSOLE")) { echo "
"; echo ""; echo "
"; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 14f420a999..c45758fe3a 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -415,7 +415,7 @@ if ($delete_profile) { $table->id = 'user_configuration_table'; $table->width = '98%'; -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; if ($id) { @@ -511,7 +511,8 @@ if (!$meta) { $table->data[11][0] = __('Interactive charts'). ' ' .ui_print_help_tip(__('Whether to use Javascript or static PNG graphs'), true) ; $values = array(-1 => __('Use global conf'), 1 => __('Yes'), 0 => __('No')); -$table->data[11][1] = html_print_select($values, 'flash_charts', $user_info["flash_chart"], '', '', -1, true, false, false); +$table->data[11][1] = html_print_select($values, 'flash_charts', + $user_info["flash_chart"], '', '', -1, true, false, false); $table->data[12][0] = __('Block size for pagination'); $table->data[12][1] = html_print_input_text ('block_size', $user_info["block_size"], '', 5, 5, true); @@ -596,7 +597,7 @@ if (!empty ($id) && !$new_user) { echo '

'. __('Profiles/Groups assigned to this user') . '

'; $table->width = '98%'; - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { $table->head_colspan[0] = 0; $table->width = '100%'; $table->class = 'databox_tactical data'; @@ -606,7 +607,7 @@ if (!empty ($id) && !$new_user) { $table->head = array (); $table->align = array (); $table->style = array (); - if (!defined("METACONSOLE")){ + if (!defined("METACONSOLE")) { $table->style[0] = 'font-weight: bold'; $table->style[1] = 'font-weight: bold'; } diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index 94f30f6b1c..6290486047 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -335,10 +335,10 @@ if ($profiles === false) { $profiles = array(); } -$img = html_print_image ("images/ok.png", true, array ("border" => 0)); +$img = html_print_image ("images/ok.png", true, array ("border" => 0)); foreach ($profiles as $profile) { - $data['profiles'] = ''.$profile["name"].''; + $data['profiles'] = ''.$profile["name"].''; $data['IR'] = ($profile["incident_view"] ? $img : ''); $data['IW'] = ($profile["incident_edit"] ? $img : ''); $data['IM'] = ($profile["incident_management"] ? $img : ''); diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 089e9ea0f6..f6ce969dfa 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -235,13 +235,14 @@ $table->data[0][4] = html_print_submit_button(__('Search'), 'search', false, array('class' => 'sub search'), true); -if(defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->width = '96%'; $form_filter = ""; $form_filter .= html_print_table($table, true); $form_filter .= ""; ui_toggle($form_filter, __('Show Options')); -}else{ +} +else { $form_filter = "
"; $form_filter .= html_print_table($table, true); $form_filter .= "
"; @@ -250,13 +251,13 @@ if(defined('METACONSOLE')){ } $table = null; -if(defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->cellpadding = 0; $table->cellspacing = 0; $table->width = '100%'; $table->class = "databox"; } -else{ +else { $table->cellpadding = 4; $table->cellspacing = 4; $table->width = '99%'; @@ -430,7 +431,7 @@ foreach ($info as $user_id => $user_info) { $data[4] = ""; $result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $user_id); if ($result !== false) { - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { $data[4] .= "
"; foreach ($result as $row) { $data[4] .= "
"; @@ -444,7 +445,7 @@ foreach ($info as $user_id => $user_info) { } $data[4] .= "
"; } - else{ + else { $data[4] .= ""; foreach ($result as $row) { $data[4] .= ""; @@ -475,7 +476,7 @@ foreach ($info as $user_id => $user_info) { if ($config["admin_can_delete_user"] && $user_info['id_user'] != $config['id_user']) { $data[6] .= "".html_print_image('images/cross.png', true, array ('title' => __('Delete'), 'onclick' => "if (! confirm ('" .__('Deleting User'). " ". $user_info['id_user'] . ". " . __('Are you sure?') ."')) return false")).""; if (defined('METACONSOLE')) { - $data[6] .= "".html_print_image('images/cross_double.png', true, array ('title' => __('Delete from all consoles'), 'onclick' => "if (! confirm ('" .__('Deleting User %s from all consoles', $user_info['id_user']) . ". " . __('Are you sure?') ."')) return false")).""; + $data[6] .= "".html_print_image('images/cross_double.png', true, array ('title' => __('Delete from all consoles'), 'onclick' => "if (! confirm ('" .__('Deleting User %s from all consoles', $user_info['id_user']) . ". " . __('Are you sure?') ."')) return false")).""; } } else { diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 3e85086573..b1c951db4b 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -175,20 +175,21 @@ if ($get_module_detail) { "width" => "230px"), ); - if($config['prominent_time']=='comparation'){ + if($config['prominent_time']=='comparation') { $columns["Time"] = array( "utimestamp", "modules_format_time", "align" => "left", "width" => "50px"); - }else{ + } + else { $columns["Timestamp"] = array( "utimestamp", "modules_format_timestamp", "align" => "left", "width" => "50px"); } - + if ($selection_mode == "fromnow") { $date = get_system_time(); $period = $period; @@ -499,10 +500,10 @@ if ($list_modules) { $status_filter_sql = 'tagente_estado.estado = ' . $status_filter_monitor; } - if($status_module_group != -1){ + if ($status_module_group != -1) { $status_module_group_filter = 'id_module_group = ' . $status_module_group; } - else{ + else { $status_module_group_filter = 'id_module_group >= 0'; } @@ -886,8 +887,8 @@ if ($list_modules) { $salida = "$salida"; } else { - if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])){ - if ( $config["render_proc"] ){ + if (is_numeric($module["datos"]) && !modules_is_string_type($module['id_tipo_modulo'])) { + if ( $config["render_proc"] ) { switch($module["id_tipo_modulo"]) { case 2: case 6: @@ -900,15 +901,16 @@ if ($list_modules) { else $salida = 'FAIL'; break; - default: + default: $salida = format_numeric($module["datos"]); break; } - }else{ + } + else { $salida = format_numeric($module["datos"]); } // Show units ONLY in numeric data types - if (isset($module["unit"])){ + if (isset($module["unit"])) { $salida .= " " . ''. io_safe_output($module["unit"]) . ''; } } diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index f07f854fc6..a2ed7f78ae 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -1299,14 +1299,14 @@ class Tree { $module['serverID'] = $server['id']; $module['serverName'] = $server['server_name']; } - else{ + else { $module['serverName'] = false; $module['serverID'] = false; } if (!isset($module['value'])) $module['value'] = modules_get_last_value($module['id']); - + // Status switch ($module['status']) { case AGENT_MODULE_STATUS_CRITICAL_ALERT: diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index da57c157a3..09b0162102 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 = 'PC150602'; +$build_version = 'PC150618'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 2aa91ba506..3d83ce339c 100755 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -66,33 +66,33 @@ define ('EVENT_STATUS_INPROCESS', 2); define ('EVENT_STATUS_VALIDATED', 1); /* Seconds in a time unit constants */ -define('SECONDS_1MINUTE', 60); -define('SECONDS_2MINUTES', 120); -define('SECONDS_5MINUTES', 300); -define('SECONDS_10MINUTES', 600); -define('SECONDS_15MINUTES', 900); -define('SECONDS_30MINUTES', 1800); -define('SECONDS_1HOUR', 3600); -define('SECONDS_2HOUR', 7200); -define('SECONDS_3HOUR', 10800); -define('SECONDS_5HOUR', 18000); -define('SECONDS_6HOURS', 21600); -define('SECONDS_12HOURS', 43200); -define('SECONDS_1DAY', 86400); -define('SECONDS_2DAY', 172800); -define('SECONDS_4DAY', 345600); -define('SECONDS_5DAY', 432000); -define('SECONDS_1WEEK', 604800); -define('SECONDS_10DAY', 864000); -define('SECONDS_2WEEK', 1209600); -define('SECONDS_15DAYS', 1296000); -define('SECONDS_1MONTH', 2592000); -define('SECONDS_2MONTHS', 5184000); -define('SECONDS_3MONTHS', 7776000); -define('SECONDS_6MONTHS', 15552000); -define('SECONDS_1YEAR', 31104000); -define('SECONDS_2YEARS', 62208000); -define('SECONDS_3YEARS', 93312000); +define('SECONDS_1MINUTE', 60); +define('SECONDS_2MINUTES', 120); +define('SECONDS_5MINUTES', 300); +define('SECONDS_10MINUTES', 600); +define('SECONDS_15MINUTES', 900); +define('SECONDS_30MINUTES', 1800); +define('SECONDS_1HOUR', 3600); +define('SECONDS_2HOUR', 7200); +define('SECONDS_3HOUR', 10800); +define('SECONDS_5HOUR', 18000); +define('SECONDS_6HOURS', 21600); +define('SECONDS_12HOURS', 43200); +define('SECONDS_1DAY', 86400); +define('SECONDS_2DAY', 172800); +define('SECONDS_4DAY', 345600); +define('SECONDS_5DAY', 432000); +define('SECONDS_1WEEK', 604800); +define('SECONDS_10DAY', 864000); +define('SECONDS_2WEEK', 1209600); +define('SECONDS_15DAYS', 1296000); +define('SECONDS_1MONTH', 2592000); +define('SECONDS_2MONTHS', 5184000); +define('SECONDS_3MONTHS', 7776000); +define('SECONDS_6MONTHS', 15552000); +define('SECONDS_1YEAR', 31104000); +define('SECONDS_2YEARS', 62208000); +define('SECONDS_3YEARS', 93312000); @@ -205,7 +205,7 @@ define('PROCESS_VALUE_AVG', 3); //Status define('VISUAL_MAP_STATUS_CRITICAL_BAD', 1); define('VISUAL_MAP_STATUS_CRITICAL_ALERT', 4); -define('VISUAL_MAP_STATUS_NORMAL', 0); +define('VISUAL_MAP_STATUS_NORMAL', 0); define('VISUAL_MAP_STATUS_WARNING', 2); define('VISUAL_MAP_STATUS_UNKNOWN', 3); define('VISUAL_MAP_STATUS_WARNING_ALERT', 10); @@ -263,169 +263,174 @@ define ('STATUS_SERVER_DOWN', 'server_down.png'); /* Status images (ball) */ //For modules -define ('STATUS_MODULE_OK_BALL', 'module_ok_ball.png'); -define ('STATUS_MODULE_CRITICAL_BALL', 'module_critical_ball.png'); -define ('STATUS_MODULE_WARNING_BALL', 'module_warning_ball.png'); -define ('STATUS_MODULE_NO_DATA_BALL', 'module_no_data_ball.png'); -define ('STATUS_MODULE_UNKNOWN_BALL', 'module_unknown_ball.png'); +define ('STATUS_MODULE_OK_BALL', 'module_ok_ball.png'); +define ('STATUS_MODULE_CRITICAL_BALL', 'module_critical_ball.png'); +define ('STATUS_MODULE_WARNING_BALL', 'module_warning_ball.png'); +define ('STATUS_MODULE_NO_DATA_BALL', 'module_no_data_ball.png'); +define ('STATUS_MODULE_UNKNOWN_BALL', 'module_unknown_ball.png'); //For agents -define ('STATUS_AGENT_CRITICAL_BALL', 'agent_critical_ball.png'); -define ('STATUS_AGENT_WARNING_BALL', 'agent_warning_ball.png'); -define ('STATUS_AGENT_DOWN_BALL', 'agent_down_ball.png'); -define ('STATUS_AGENT_UNKNOWN_BALL', 'agent_unknown_ball.png'); -define ('STATUS_AGENT_OK_BALL', 'agent_ok_ball.png'); -define ('STATUS_AGENT_NO_DATA_BALL', 'agent_no_data_ball.png'); -define ('STATUS_AGENT_NO_MONITORS_BALL', 'agent_no_monitors_ball.png'); -define ('STATUS_AGENT_NOT_INIT_BALL', 'agent_notinit_ball.png'); +define ('STATUS_AGENT_CRITICAL_BALL', 'agent_critical_ball.png'); +define ('STATUS_AGENT_WARNING_BALL', 'agent_warning_ball.png'); +define ('STATUS_AGENT_DOWN_BALL', 'agent_down_ball.png'); +define ('STATUS_AGENT_UNKNOWN_BALL', 'agent_unknown_ball.png'); +define ('STATUS_AGENT_OK_BALL', 'agent_ok_ball.png'); +define ('STATUS_AGENT_NO_DATA_BALL', 'agent_no_data_ball.png'); +define ('STATUS_AGENT_NO_MONITORS_BALL', 'agent_no_monitors_ball.png'); +define ('STATUS_AGENT_NOT_INIT_BALL', 'agent_notinit_ball.png'); //For alerts -define ('STATUS_ALERT_FIRED_BALL', 'alert_fired_ball.png'); -define ('STATUS_ALERT_NOT_FIRED_BALL', 'alert_not_fired_ball.png'); -define ('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png'); +define ('STATUS_ALERT_FIRED_BALL', 'alert_fired_ball.png'); +define ('STATUS_ALERT_NOT_FIRED_BALL', 'alert_not_fired_ball.png'); +define ('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png'); //For servers -define ('STATUS_SERVER_OK_BALL', 'server_ok_ball.png'); -define ('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png'); +define ('STATUS_SERVER_OK_BALL', 'server_ok_ball.png'); +define ('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png'); /* Events criticity */ -define ('EVENT_CRIT_MAINTENANCE', 0); -define ('EVENT_CRIT_INFORMATIONAL', 1); -define ('EVENT_CRIT_NORMAL', 2); -define ('EVENT_CRIT_MINOR', 5); -define ('EVENT_CRIT_WARNING', 3); -define ('EVENT_CRIT_MAJOR', 6); -define ('EVENT_CRIT_CRITICAL', 4); -define ('EVENT_CRIT_WARNING_OR_CRITICAL', 34); -define ('EVENT_CRIT_NOT_NORMAL', 20); +define ('EVENT_CRIT_MAINTENANCE', 0); +define ('EVENT_CRIT_INFORMATIONAL', 1); +define ('EVENT_CRIT_NORMAL', 2); +define ('EVENT_CRIT_MINOR', 5); +define ('EVENT_CRIT_WARNING', 3); +define ('EVENT_CRIT_MAJOR', 6); +define ('EVENT_CRIT_CRITICAL', 4); +define ('EVENT_CRIT_WARNING_OR_CRITICAL', 34); +define ('EVENT_CRIT_NOT_NORMAL', 20); /* Id Module (more use in component)*/ -define ('MODULE_DATA', 1); -define ('MODULE_NETWORK', 2); -define ('MODULE_SNMP', 2); -define ('MODULE_PLUGIN', 4); -define ('MODULE_PREDICTION', 5); -define ('MODULE_WMI', 6); -define ('MODULE_WEB', 7); +define ('MODULE_DATA', 1); +define ('MODULE_NETWORK', 2); +define ('MODULE_SNMP', 2); +define ('MODULE_PLUGIN', 4); +define ('MODULE_PREDICTION', 5); +define ('MODULE_WMI', 6); +define ('MODULE_WEB', 7); /* Type of Modules of Prediction */ -define ('MODULE_PREDICTION_SERVICE', 2); -define ('MODULE_PREDICTION_SYNTHETIC', 3); -define ('MODULE_PREDICTION_NETFLOW', 4); +define ('MODULE_PREDICTION_SERVICE', 2); +define ('MODULE_PREDICTION_SYNTHETIC', 3); +define ('MODULE_PREDICTION_NETFLOW', 4); /* SNMP CONSTANTS */ -define('SNMP_DIR_MIBS', "attachment/mibs"); -define('SNMP_TRAP_TYPE_NONE', -1); -define('SNMP_TRAP_TYPE_COLD_START', 0); -define('SNMP_TRAP_TYPE_WARM_START', 1); -define('SNMP_TRAP_TYPE_LINK_DOWN', 2); -define('SNMP_TRAP_TYPE_LINK_UP', 3); -define('SNMP_TRAP_TYPE_AUTHENTICATION_FAILURE', 4); -define('SNMP_TRAP_TYPE_OTHER', 5); +define('SNMP_DIR_MIBS', "attachment/mibs"); + +define('SNMP_TRAP_TYPE_NONE', -1); +define('SNMP_TRAP_TYPE_COLD_START', 0); +define('SNMP_TRAP_TYPE_WARM_START', 1); +define('SNMP_TRAP_TYPE_LINK_DOWN', 2); +define('SNMP_TRAP_TYPE_LINK_UP', 3); +define('SNMP_TRAP_TYPE_AUTHENTICATION_FAILURE', 4); +define('SNMP_TRAP_TYPE_OTHER', 5); /* PASSWORD POLICIES */ -define('PASSSWORD_POLICIES_OK', 0); -define('PASSSWORD_POLICIES_FIRST_CHANGE', 1); -define('PASSSWORD_POLICIES_EXPIRED', 2); +define('PASSSWORD_POLICIES_OK', 0); +define('PASSSWORD_POLICIES_FIRST_CHANGE', 1); +define('PASSSWORD_POLICIES_EXPIRED', 2); /* SERVER TYPES */ -define('SERVER_TYPE_DATA', 0); -define('SERVER_TYPE_NETWORK', 1); -define('SERVER_TYPE_SNMP', 2); -define('SERVER_TYPE_RECON', 3); -define('SERVER_TYPE_PLUGIN', 4); -define('SERVER_TYPE_PREDICTION', 5); -define('SERVER_TYPE_WMI', 6); -define('SERVER_TYPE_EXPORT', 7); -define('SERVER_TYPE_INVENTORY', 8); -define('SERVER_TYPE_WEB', 9); -define('SERVER_TYPE_EVENT', 10); -define('SERVER_TYPE_ENTERPRISE_ICMP', 11); -define('SERVER_TYPE_ENTERPRISE_SNMP', 12); +define('SERVER_TYPE_DATA', 0); +define('SERVER_TYPE_NETWORK', 1); +define('SERVER_TYPE_SNMP', 2); +define('SERVER_TYPE_RECON', 3); +define('SERVER_TYPE_PLUGIN', 4); +define('SERVER_TYPE_PREDICTION', 5); +define('SERVER_TYPE_WMI', 6); +define('SERVER_TYPE_EXPORT', 7); +define('SERVER_TYPE_INVENTORY', 8); +define('SERVER_TYPE_WEB', 9); +define('SERVER_TYPE_EVENT', 10); +define('SERVER_TYPE_ENTERPRISE_ICMP', 11); +define('SERVER_TYPE_ENTERPRISE_SNMP', 12); /* REPORTS */ -define('REPORT_TOP_N_MAX', 1); -define('REPORT_TOP_N_MIN', 2); -define('REPORT_TOP_N_AVG', 0); +define('REPORT_TOP_N_MAX', 1); +define('REPORT_TOP_N_MIN', 2); +define('REPORT_TOP_N_AVG', 0); -define('REPORT_TOP_N_ONLY_GRAPHS', 2); -define('REPORT_TOP_N_SHOW_TABLE_GRAPS', 1); -define('REPORT_TOP_N_ONLY_TABLE', 0); +define('REPORT_TOP_N_ONLY_GRAPHS', 2); +define('REPORT_TOP_N_SHOW_TABLE_GRAPS', 1); +define('REPORT_TOP_N_ONLY_TABLE', 0); -define('REPORT_EXCEPTION_CONDITION_EVERYTHING', 0); -define('REPORT_EXCEPTION_CONDITION_GE', 1); -define('REPORT_EXCEPTION_CONDITION_LE', 5); -define('REPORT_EXCEPTION_CONDITION_L', 2); -define('REPORT_EXCEPTION_CONDITION_G', 6); -define('REPORT_EXCEPTION_CONDITION_E', 7); -define('REPORT_EXCEPTION_CONDITION_NE', 8); -define('REPORT_EXCEPTION_CONDITION_OK', 3); -define('REPORT_EXCEPTION_CONDITION_NOT_OK', 4); +define('REPORT_EXCEPTION_CONDITION_EVERYTHING', 0); +define('REPORT_EXCEPTION_CONDITION_GE', 1); +define('REPORT_EXCEPTION_CONDITION_LE', 5); +define('REPORT_EXCEPTION_CONDITION_L', 2); +define('REPORT_EXCEPTION_CONDITION_G', 6); +define('REPORT_EXCEPTION_CONDITION_E', 7); +define('REPORT_EXCEPTION_CONDITION_NE', 8); +define('REPORT_EXCEPTION_CONDITION_OK', 3); +define('REPORT_EXCEPTION_CONDITION_NOT_OK', 4); -define('REPORT_ITEM_ORDER_BY_AGENT_NAME', 3); -define('REPORT_ITEM_ORDER_BY_ASCENDING', 2); -define('REPORT_ITEM_ORDER_BY_DESCENDING', 1); -define('REPORT_ITEM_ORDER_BY_UNSORT', 0); +define('REPORT_ITEM_ORDER_BY_AGENT_NAME', 3); +define('REPORT_ITEM_ORDER_BY_ASCENDING', 2); +define('REPORT_ITEM_ORDER_BY_DESCENDING', 1); +define('REPORT_ITEM_ORDER_BY_UNSORT', 0); -define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1); -define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2); -define('REPORT_OLD_TYPE_SLA', 3); -define('REPORT_OLD_TYPE_MONITOR_REPORT', 6); -define('REPORT_OLD_TYPE_AVG_VALUE', 7); -define('REPORT_OLD_TYPE_MAX_VALUE', 8); -define('REPORT_OLD_TYPE_MIN_VALUE', 9); -define('REPORT_OLD_TYPE_SUMATORY', 10); +define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1); +define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2); +define('REPORT_OLD_TYPE_SLA', 3); +define('REPORT_OLD_TYPE_MONITOR_REPORT', 6); +define('REPORT_OLD_TYPE_AVG_VALUE', 7); +define('REPORT_OLD_TYPE_MAX_VALUE', 8); +define('REPORT_OLD_TYPE_MIN_VALUE', 9); +define('REPORT_OLD_TYPE_SUMATORY', 10); -define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0); -define('REPORT_GENERAL_GROUP_BY_AGENT', 1); +define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0); +define('REPORT_GENERAL_GROUP_BY_AGENT', 1); -define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15); +define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15); /* POLICIES */ -define("POLICY_UPDATED", 0); -define("POLICY_PENDING_DATABASE", 1); -define("POLICY_PENDING_ALL", 2); +define("POLICY_UPDATED", 0); +define("POLICY_PENDING_DATABASE", 1); +define("POLICY_PENDING_ALL", 2); -define("STATUS_IN_QUEUE_OUT", 0); -define("STATUS_IN_QUEUE_IN", 1); -define("STATUS_IN_QUEUE_APPLYING", 2); +define("STATUS_IN_QUEUE_OUT", 0); +define("STATUS_IN_QUEUE_IN", 1); +define("STATUS_IN_QUEUE_APPLYING", 2); -define("MODULE_UNLINKED", 0); -define("MODULE_LINKED", 1); -define("MODULE_PENDING_UNLINK", 10); -define("MODULE_PENDING_LINK", 11); +define("MODULE_UNLINKED", 0); +define("MODULE_LINKED", 1); +define("MODULE_PENDING_UNLINK", 10); +define("MODULE_PENDING_LINK", 11); /* EVENTS */ -define("EVENTS_GOING_UNKNOWN" , 'going_unknown'); -define("EVENTS_UNKNOWN", 'unknown'); -define("EVENTS_ALERT_FIRED", 'alert_fired'); -define("EVENTS_ALERT_RECOVERED", 'alert_recovered'); -define("EVENTS_ALERT_CEASED", 'alert_ceased'); -define("EVENTS_ALERT_MANUAL_VALIDATION", 'alert_manual_validation'); -define("EVENTS_RECON_HOST_DETECTED", 'recon_host_detected'); -define("EVENTS_SYSTEM", 'system'); -define("EVENTS_ERROR", 'error'); -define("EVENTS_NEW_AGENT", 'new_agent'); -define("EVENTS_GOING_UP_WARNING", 'going_up_warning'); -define("EVENTS_GOING_UP_CRITICAL", 'going_up_critical'); -define("EVENTS_GOING_DOWN_WARNING", 'going_down_warning'); -define("EVENTS_GOING_DOWN_NORMAL", 'going_down_normal'); -define("EVENTS_GOING_DOWN_CRITICAL", 'going_down_critical'); -define("EVENTS_GOING_UP_NORMAL", 'going_up_normal'); -define("EVENTS_CONFIGURATION_CHANGE", 'configuration_change'); +define("EVENTS_GOING_UNKNOWN" , 'going_unknown'); +define("EVENTS_UNKNOWN", 'unknown'); +define("EVENTS_ALERT_FIRED", 'alert_fired'); +define("EVENTS_ALERT_RECOVERED", 'alert_recovered'); +define("EVENTS_ALERT_CEASED", 'alert_ceased'); +define("EVENTS_ALERT_MANUAL_VALIDATION", 'alert_manual_validation'); +define("EVENTS_RECON_HOST_DETECTED", 'recon_host_detected'); +define("EVENTS_SYSTEM", 'system'); +define("EVENTS_ERROR", 'error'); +define("EVENTS_NEW_AGENT", 'new_agent'); +define("EVENTS_GOING_UP_WARNING", 'going_up_warning'); +define("EVENTS_GOING_UP_CRITICAL", 'going_up_critical'); +define("EVENTS_GOING_DOWN_WARNING", 'going_down_warning'); +define("EVENTS_GOING_DOWN_NORMAL", 'going_down_normal'); +define("EVENTS_GOING_DOWN_CRITICAL", 'going_down_critical'); +define("EVENTS_GOING_UP_NORMAL", 'going_up_normal'); +define("EVENTS_CONFIGURATION_CHANGE", 'configuration_change'); /* CUSTOM GRAPHS */ -define("CUSTOM_GRAPH_AREA", 0); -define("CUSTOM_GRAPH_STACKED_AREA", 1); -define("CUSTOM_GRAPH_LINE", 2); -define("CUSTOM_GRAPH_STACKED_LINE", 3); +define("CUSTOM_GRAPH_AREA", 0); +define("CUSTOM_GRAPH_STACKED_AREA", 1); +define("CUSTOM_GRAPH_LINE", 2); +define("CUSTOM_GRAPH_STACKED_LINE", 3); /* COLLECTIONS */ -define("COLLECTION_PENDING_APPLY", 0); -define("COLLECTION_CORRECT", 1); -define("COLLECTION_ERROR_LOST_DIRECTORY", 2); -define("COLLECTION_UNSAVED", 3); +define("COLLECTION_PENDING_APPLY", 0); +define("COLLECTION_CORRECT", 1); +define("COLLECTION_ERROR_LOST_DIRECTORY", 2); +define("COLLECTION_UNSAVED", 3); /* PAGINATION */ -define("PAGINATION_BLOCKS_LIMIT", 15); +define("PAGINATION_BLOCKS_LIMIT", 15); + +/* CHARTS */ +define("CHART_DEFAULT_WIDTH", 150); +define("CHART_DEFAULT_HEIGHT", 110); ?> diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index acb69eb6ea..5cc00771b2 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -223,7 +223,7 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection = if ($sql == '') return false; - $cache = false; + if ($cache && ! empty ($sql_cache[$sql])) { $retval = $sql_cache[$sql]; $sql_cache['saved']++; @@ -433,9 +433,6 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) { $query .= ' VALUES (' . $values_str . ')'; $status = ''; - - - return db_process_sql($query, 'insert_id', '', true, $status, $autocommit); } @@ -613,7 +610,7 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi if ($i == 1) { $query .= ' ( '; } - if ($field == '1' AND $value == '1'){ + if ($field == '1' AND $value == '1') { $query .= sprintf("'%s' = '%s'", $field, $value); if ($i < $max) { @@ -835,17 +832,17 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { $query .= sprintf ("%s IN ('%s')", $field, implode ("', '", $value)); } else { - if ($value[0] == ">"){ - $value = substr($value,1,strlen($value)-1); + if ($value[0] == ">") { + $value = substr($value,1,strlen($value) - 1); $query .= sprintf ("%s > '%s'", $field, $value); } - else if ($value[0] == "<"){ - if ($value[1] == ">"){ - $value = substr($value,2,strlen($value)-2); + else if ($value[0] == "<") { + if ($value[1] == ">") { + $value = substr($value,2,strlen($value) - 2); $query .= sprintf ("%s <> '%s'", $field, $value); } else { - $value = substr($value,1,strlen($value)-1); + $value = substr($value,1,strlen($value) - 1); $query .= sprintf ("%s < '%s'", $field, $value); } } @@ -1156,7 +1153,7 @@ function oracle_db_format_array_to_update_sql ($values) { if (isset ($value[0]) && $value[0] == '`') /* Don't round with quotes if it references a field */ $sql = sprintf ("%s = %s", $field, str_replace('`', '', $value)); - else if (substr($value, 0,1) == '#'){ + else if (substr($value, 0,1) == '#') { $sql = sprintf ("%s = %s", $field, substr($value,1)); } else { @@ -1209,10 +1206,6 @@ function oracle_db_process_sql_update($table, $values, $where = false, $where_jo } $status = ''; - - - - return db_process_sql ($query, "affected_rows", '', true, $status, $autocommit); } @@ -1265,7 +1258,7 @@ function oracle_db_process_sql_delete($table, $where, $where_join = 'AND') { return db_process_sql ($query); } -function oracle_db_process_sql_delete_temp ($table, $where, $where_join = 'AND'){ +function oracle_db_process_sql_delete_temp ($table, $where, $where_join = 'AND') { if (empty ($where)) /* Should avoid any mistake that lead to deleting all data */ return false; @@ -1451,7 +1444,7 @@ function oracle_db_get_type_field_table($table, $field) { * * @return mixed Return an array/string of table fields or false if something goes wrong. */ -function oracle_list_all_field_table($table_name, $return_mode = 'array'){ +function oracle_list_all_field_table($table_name, $return_mode = 'array') { if (empty($table_name)) { return false; } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 1e13ac48f3..f863a99631 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2240,13 +2240,17 @@ function print_audit_csv ($data) { header("Pragma: no-cache"); header("Expires: 0"); - if ($data){ - echo __('User') . ';' . __('Action') . ';' . __('Date') . ';' . __('Source ID') . ';'. __('Comments') ."\n"; + if ($data) { + echo __('User') . ';' . + __('Action') . ';' . + __('Date') . ';' . + __('Source ID') . ';' . + __('Comments') ."\n"; foreach ($data as $line) { echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n"; } } - else{ + else { echo __('No data found to export'); } } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 99eeb7f833..69fa041dc9 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1548,7 +1548,7 @@ function agents_get_status($id_agent = 0, $noACLs = false) { $result_modules = array(); // Skip non init modules foreach ($all_modules as $module) { - if (modules_get_agentmodule_is_init($module['id_agente_modulo'])){ + if (modules_get_agentmodule_is_init($module['id_agente_modulo'])) { $modules[] = $module['id_agente_modulo']; } } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index f6eaa8a269..9d1e6052cb 100755 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1310,14 +1310,14 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) { $result_modules = array(); // Skip non init modules foreach ($modules as $module) { - if (modules_get_agentmodule_is_init($module['id_agente_modulo'])){ + if (modules_get_agentmodule_is_init($module['id_agente_modulo'])) { $result_modules[] = $module; } } // Without modules NO_MODULES - if ($other['data'][2] == 'no_modules'){ - if (empty($result_modules) and $other['data'][2] == 'no_modules'){ + if ($other['data'][2] == 'no_modules') { + if (empty($result_modules) and $other['data'][2] == 'no_modules') { $result_agents[] = $agent; } } @@ -1508,7 +1508,7 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3) { $where = ''; if ($other['data'][0] == "") { - returnError('error_policy_modules', 'Error retrieving policy modules. Id_policy cannot be left blank.'); + returnError('error_policy_modules', 'Error retrieving policy modules. Id_policy cannot be left blank.'); return; } @@ -1516,11 +1516,11 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3) { array($other['data'][0], $other['data'][1])); if ($policies === ENTERPRISE_NOT_HOOK) { - returnError('error_policy_modules', 'Error retrieving policy modules.'); - return; + returnError('error_policy_modules', 'Error retrieving policy modules.'); + return; } - if (count($policies) > 0 and $policies !== false){ + if (count($policies) > 0 and $policies !== false) { $data = array('type' => 'array', 'data' => $policies); returnData('csv', $data, ';'); @@ -1637,21 +1637,23 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) { * * @param $thrash3 Don't use */ -function api_set_update_network_module($id_module, $thrash1, $other, $thrash3){ +function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) { if (defined ('METACONSOLE')) { return; } if ($id_module == "") { - returnError('error_update_network_module', __('Error updating network module. Module name cannot be left blank.')); + returnError('error_update_network_module', + __('Error updating network module. Module name cannot be left blank.')); return; } $check_id_module = db_get_value ('id_agente_modulo', 'tagente_modulo', 'id_agente_modulo', $id_module); if (!$check_id_module) { - returnError('error_update_network_module', __('Error updating network module. Id_module doesn\'t exists.')); + returnError('error_update_network_module', + __('Error updating network module. Id_module doesn\'t exists.')); return; } @@ -1660,9 +1662,11 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3){ $id_agent_old = db_get_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_module); if ($id_agent_old != $other['data'][0]) { - $id_module_exists = db_get_value_filter ('id_agente_modulo', 'tagente_modulo', array('nombre' => $module_name, 'id_agente' => $other['data'][0])); + $id_module_exists = db_get_value_filter ('id_agente_modulo', + 'tagente_modulo', + array('nombre' => $module_name, 'id_agente' => $other['data'][0])); - if ($id_module_exists){ + if ($id_module_exists) { returnError('error_update_network_module', __('Error updating network module. Id_module exists in the new agent.')); return; @@ -1825,7 +1829,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) { * * @param $thrash3 Don't use */ -function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3){ +function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) { if (defined ('METACONSOLE')) { return; } @@ -2012,7 +2016,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) { * * @param $thrash3 Don't use */ -function api_set_update_data_module($id_module, $thrash1, $other, $thrash3){ +function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) { if (defined ('METACONSOLE')) { return; } @@ -2070,7 +2074,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3){ $values = array(); $cont = 0; foreach ($data_module_fields as $field) { - if ($other['data'][$cont] != ""){ + if ($other['data'][$cont] != "") { $values[$field] = $other['data'][$cont]; } @@ -2298,21 +2302,28 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) { if ($other['data'][13] == "3") { if ($other['data'][22] != "AES" and $other['data'][22] != "DES") { - returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exists. Set it to \'AES\' or \'DES\'. ')); + returnError('error_create_snmp_module', + __('Error in creation SNMP module. snmp3_priv_method doesn\'t exists. Set it to \'AES\' or \'DES\'. ')); return; } - if ($other['data'][24] != "authNoPriv" and $other['data'][24] != "authPriv" and $other['data'][24] != "noAuthNoPriv"){ - returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + if ($other['data'][24] != "authNoPriv" + and $other['data'][24] != "authPriv" + and $other['data'][24] != "noAuthNoPriv") { + + returnError('error_create_snmp_module', + __('Error in creation SNMP module. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); return; } if ($other['data'][25] != "MD5" and $other['data'][25] != "SHA") { - returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); + returnError('error_create_snmp_module', + __('Error in creation SNMP module. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); return; } - $snmp_module_fields = array('id_agente', + $snmp_module_fields = array( + 'id_agente', 'disabled', 'id_module_group', 'min_warning', @@ -2347,7 +2358,8 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) { 'min_ff_event_critical'); } else { - $snmp_module_fields = array('id_agente', + $snmp_module_fields = array( + 'id_agente', 'disabled', 'id_module_group', 'min_warning', @@ -2378,8 +2390,8 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) { $values = array(); $cont = 0; - foreach ($snmp_module_fields as $field){ - if ($other['data'][$cont] != ""){ + foreach ($snmp_module_fields as $field) { + if ($other['data'][$cont] != "") { $values[$field] = $other['data'][$cont]; } @@ -2618,13 +2630,18 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) { return; } - if ($other['data'][25] != "authNoPriv" and $other['data'][25] != "authPriv" and $other['data'][25] != "noAuthNoPriv"){ - returnError('error_set_new_snmp_component', __('Error creating SNMP component. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + if ($other['data'][25] != "authNoPriv" + and $other['data'][25] != "authPriv" + and $other['data'][25] != "noAuthNoPriv") { + + returnError('error_set_new_snmp_component', + __('Error creating SNMP component. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); return; } if ($other['data'][24] != "MD5" and $other['data'][24] != "SHA") { - returnError('error_set_new_snmp_component', __('Error creating SNMP component. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); + returnError('error_set_new_snmp_component', + __('Error creating SNMP component. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); return; } @@ -3104,7 +3121,7 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) { if ($id_template != "") { $result_template = alerts_get_alert_template_name($id_template); - if (!$result_template){ + if (!$result_template) { returnError('error_get_alert_template', __('Error getting alert template. Id_template doesn\'t exists.')); return; @@ -3275,24 +3292,28 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) { } if ($id == "") { - returnError('error_module_to_template', __('Error assigning module to template. Id_template cannot be left blank.')); + returnError('error_module_to_template', + __('Error assigning module to template. Id_template cannot be left blank.')); return; } - if ($other['data'][0] == ""){ - returnError('error_module_to_template', __('Error assigning module to template. Id_module cannot be left blank.')); + if ($other['data'][0] == "") { + returnError('error_module_to_template', + __('Error assigning module to template. Id_module cannot be left blank.')); return; } if ($other['data'][1] == "") { - returnError('error_module_to_template', __('Error assigning module to template. Id_agent cannot be left blank.')); + returnError('error_module_to_template', + __('Error assigning module to template. Id_agent cannot be left blank.')); return; } $result_template = alerts_get_alert_template($id); - if (!$result_template){ - returnError('error_module_to_template', __('Error assigning module to template. Id_template doensn\'t exists.')); + if (!$result_template) { + returnError('error_module_to_template', + __('Error assigning module to template. Id_template doensn\'t exists.')); return; } @@ -3466,13 +3487,14 @@ function api_set_validate_all_alerts($id, $thrash1, $other, $thrash3) { $id_agents = db_get_all_rows_sql($sql); - foreach ($id_agents as $id_agent){ + foreach ($id_agents as $id_agent) { $result_agents[] = $id_agent['id_agente']; } $agents_string = implode(',', $result_agents); - $sql = sprintf ("SELECT talert_template_modules.id + $sql = sprintf (" + SELECT talert_template_modules.id FROM talert_template_modules INNER JOIN tagente_modulo t2 ON talert_template_modules.id_agent_module = t2.id_agente_modulo @@ -3480,7 +3502,7 @@ function api_set_validate_all_alerts($id, $thrash1, $other, $thrash3) { ON t2.id_agente = t3.id_agente INNER JOIN talert_templates t4 ON talert_template_modules.id_alert_template = t4.id - WHERE id_agent_module in (%s)", $agents_string); + WHERE id_agent_module in (%s)", $agents_string); $alerts = db_get_all_rows_sql($sql); @@ -3541,14 +3563,14 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) { // Number of alerts in this policy - if ($policy_alerts != false){ + if ($policy_alerts != false) { $partial_alerts = count($policy_alerts); // Added alerts of this policy to the total $total_alerts = $total_alerts + $partial_alerts; } $result_pol_alerts = array(); - foreach ($policy_alerts as $policy_alert){ + foreach ($policy_alerts as $policy_alert) { $result_pol_alerts[] = $policy_alert['id']; } @@ -3556,7 +3578,8 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) { // If the policy has alerts if (count($result_pol_alerts) != 0) { - $sql = sprintf ("SELECT id + $sql = sprintf (" + SELECT id FROM talert_template_modules WHERE id_policy_alerts IN (%s)", $id_pol_alerts); @@ -3827,9 +3850,9 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) { $values['min_critical'] = $other['data'][11]; $values['max_critical'] = $other['data'][12]; $values['str_critical'] = $other['data'][13]; - $values['history_data'] = $other['data'][14]; - $values['configuration_data'] = $other['data'][15]; - $values['disabled_types_event'] = $disabled_types_event; + $values['history_data'] = $other['data'][14]; + $values['configuration_data'] = $other['data'][15]; + $values['disabled_types_event'] = $disabled_types_event; $values['module_macros'] = $other['data'][17]; $values['min_ff_event'] = $other['data'][18]; $values['each_ff'] = $other['data'][19]; @@ -3837,8 +3860,8 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) { $values['min_ff_event_warning'] = $other['data'][21]; $values['min_ff_event_critical'] = $other['data'][22]; $values['ff_timeout'] = $other['data'][23]; - - if ($name_module_policy !== false) { + + if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { returnError('error_add_data_module_policy', __('Error adding data module to policy. The module is already in the policy.')); @@ -3899,31 +3922,37 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) { } if ($module_policy[0]['id_module'] != 1) { - returnError('error_update_data_module_policy', __('Error updating data module in policy. Module type is not network type.')); + returnError('error_update_data_module_policy', + __('Error updating data module in policy. Module type is not network type.')); return; } - $fields_data_module = array('id','description', 'id_module_group', 'min', 'max', 'post_process', 'module_interval', - 'min_warning', 'max_warning', 'str_warning', 'min_critical', 'max_critical', 'str_critical', - 'history_data', 'configuration_data', 'disabled_types_event', 'module_macros'); + $fields_data_module = array( + 'id','description', 'id_module_group', 'min', 'max', + 'post_process', 'module_interval', 'min_warning', 'max_warning', + 'str_warning', 'min_critical', 'max_critical', 'str_critical', + 'history_data', 'configuration_data', 'disabled_types_event', + 'module_macros'); $cont = 0; - foreach ($fields_data_module as $field){ - if ($other['data'][$cont] != "" and $field != 'id'){ + foreach ($fields_data_module as $field) { + if ($other['data'][$cont] != "" and $field != 'id') { $values[$field] = $other['data'][$cont]; } $cont++; } - - - $result_update = enterprise_hook('policies_update_module', array($other['data'][0], $values, false)); + + + $result_update = enterprise_hook('policies_update_module', + array($other['data'][0], $values, false)); if ($result_update < 0) returnError('error_update_data_module_policy', 'Error updating policy module.'); else - returnData('string', array('type' => 'string', 'data' => __('Data policy module updated.'))); + returnData('string', + array('type' => 'string', 'data' => __('Data policy module updated.'))); } /** @@ -4629,33 +4658,46 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { # SNMP version 3 if ($other['data'][12] == "3") { - if ($other['data'][21] != "AES" and $other['data'][21] != "DES"){ - returnError('error_update_snmp_module_policy', __('Error updating SNMP module. snmp3_priv_method doesn\'t exists. Set it to \'AES\' or \'DES\'. ')); + if ($other['data'][21] != "AES" and $other['data'][21] != "DES") { + returnError('error_update_snmp_module_policy', + __('Error updating SNMP module. snmp3_priv_method doesn\'t exists. Set it to \'AES\' or \'DES\'. ')); return; } - if ($other['data'][23] != "authNoPriv" and $other['data'][23] != "authPriv" and $other['data'][23] != "noAuthNoPriv"){ - returnError('error_update_snmp_module_policy', __('Error updating SNMP module. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + if ($other['data'][23] != "authNoPriv" + and $other['data'][23] != "authPriv" + and $other['data'][23] != "noAuthNoPriv") { + + returnError('error_update_snmp_module_policy', + __('Error updating SNMP module. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); return; } - if ($other['data'][24] != "MD5" and $other['data'][24] != "SHA"){ - returnError('error_update_snmp_module_policy', __('Error updating SNMP module. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); + if ($other['data'][24] != "MD5" and $other['data'][24] != "SHA") { + returnError('error_update_snmp_module_policy', + __('Error updating SNMP module. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); return; } - $fields_snmp_module = array('id','disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', 'min_critical', - 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', - 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description', 'custom_string_1', - 'custom_string_2', 'custom_string_3', 'plugin_parameter', 'plugin_user', 'plugin_pass'); + $fields_snmp_module = array('id','disabled', 'id_module_group', + 'min_warning', 'max_warning', 'str_warning', 'min_critical', + 'max_critical', 'str_critical', 'min_ff_event', + 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', + 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', + 'custom_id', 'description', 'custom_string_1', + 'custom_string_2', 'custom_string_3', 'plugin_parameter', + 'plugin_user', 'plugin_pass'); } else { - $fields_snmp_module = array('id','disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', 'min_critical', - 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', - 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description'); + $fields_snmp_module = array('id','disabled', 'id_module_group', + 'min_warning', 'max_warning', 'str_warning', 'min_critical', + 'max_critical', 'str_critical', 'min_ff_event', + 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', + 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', + 'custom_id', 'description'); } $cont = 0; @@ -4667,13 +4709,15 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { $cont++; } - $result_update = enterprise_hook('policies_update_module', array($other['data'][0], $values, false)); + $result_update = enterprise_hook('policies_update_module', + array($other['data'][0], $values, false)); if ($result_update < 0) returnError('error_update_snmp_module_policy', 'Error updating policy module.'); else - returnData('string', array('type' => 'string', 'data' => __('SNMP policy module updated.'))); + returnData('string', + array('type' => 'string', 'data' => __('SNMP policy module updated.'))); } @@ -4714,13 +4758,14 @@ function api_set_apply_policy($id, $thrash1, $other, $thrash3) { } } - if ($duplicated == STATUS_IN_QUEUE_APPLYING or $duplicated == STATUS_IN_QUEUE_IN){ + if ($duplicated == STATUS_IN_QUEUE_APPLYING or $duplicated == STATUS_IN_QUEUE_IN) { // We want to return a value if ($other == "return") { return -1; } else { - returnError('error_apply_policy', __('Error applying policy. This policy is already pending to apply.')); + returnError('error_apply_policy', + __('Error applying policy. This policy is already pending to apply.')); return; } } @@ -5235,19 +5280,22 @@ function api_set_enable_disable_user ($id, $thrash2, $other, $thrash3) { return; } - if ($id == ""){ - returnError('error_enable_disable_user', 'Error enable/disable user. Id_user cannot be left blank.'); + if ($id == "") { + returnError('error_enable_disable_user', + __('Error enable/disable user. Id_user cannot be left blank.')); return; } - if ($other['data'][0] != "0" and $other['data'][0] != "1"){ - returnError('error_enable_disable_user', 'Error enable/disable user. Enable/disable value cannot be left blank.'); + if ($other['data'][0] != "0" and $other['data'][0] != "1") { + returnError('error_enable_disable_user', + __('Error enable/disable user. Enable/disable value cannot be left blank.')); return; } - if (users_get_user_by_id($id) == false){ - returnError('error_enable_disable_user', 'Error enable/disable user. The user doesn\'t exists.'); + if (users_get_user_by_id($id) == false) { + returnError('error_enable_disable_user', + __('Error enable/disable user. The user doesn\'t exists.')); return; } @@ -5255,14 +5303,17 @@ function api_set_enable_disable_user ($id, $thrash2, $other, $thrash3) { if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_enable_disable_user', __('Error in user enabling/disabling.')); + returnError('error_enable_disable_user', + __('Error in user enabling/disabling.')); } else { - if ($other['data'][0] == "0"){ - returnData('string', array('type' => 'string', 'data' => __('Enabled user.'))); + if ($other['data'][0] == "0") { + returnData('string', + array('type' => 'string', 'data' => __('Enabled user.'))); } else { - returnData('string', array('type' => 'string', 'data' => __('Disabled user.'))); + returnData('string', + array('type' => 'string', 'data' => __('Disabled user.'))); } } } @@ -7696,36 +7747,44 @@ function api_set_enable_disable_agent ($id, $thrash2, $other, $thrash3) { return; } - if ($id == ""){ - returnError('error_enable_disable_agent', 'Error enable/disable agent. Id_agent cannot be left blank.'); + if ($id == "") { + returnError('error_enable_disable_agent', + __('Error enable/disable agent. Id_agent cannot be left blank.')); return; } - if ($other['data'][0] != "0" and $other['data'][0] != "1"){ - returnError('error_enable_disable_agent', 'Error enable/disable agent. Enable/disable value cannot be left blank.'); + if ($other['data'][0] != "0" and $other['data'][0] != "1") { + returnError('error_enable_disable_agent', + __('Error enable/disable agent. Enable/disable value cannot be left blank.')); return; } - if (agents_get_name($id) == false){ - returnError('error_enable_disable_agent', 'Error enable/disable agent. The agent doesn\'t exists.'); + if (agents_get_name($id) == false) { + returnError('error_enable_disable_agent', + __('Error enable/disable agent. The agent doesn\'t exists.')); return; } - + $disabled = ( $other['data'][0] ? 0 : 1 ); - $result = db_process_sql_update('tagente', array('disabled' => $disabled), array('id_agente' => $id)); + $result = db_process_sql_update('tagente', + array('disabled' => $disabled), array('id_agente' => $id)); if (is_error($result)) { // TODO: Improve the error returning more info returnError('error_enable_disable_agent', __('Error in agent enabling/disabling.')); } else { - if ($disabled == 0){ - returnData('string', array('type' => 'string', 'data' => __('Enabled agent.'))); + if ($disabled == 0) { + returnData('string', + array('type' => 'string', + 'data' => __('Enabled agent.'))); } else { - returnData('string', array('type' => 'string', 'data' => __('Disabled agent.'))); + returnData('string', + array('type' => 'string', + 'data' => __('Disabled agent.'))); } } } @@ -7900,37 +7959,38 @@ function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3) return; } - $special_day = $other['data'][0]; - $same_day = $other['data'][1]; - $description = $other['data'][2]; - $idGroup = $other['data'][3]; - + $special_day = $other['data'][0]; + $same_day = $other['data'][1]; + $description = $other['data'][2]; + $idGroup = $other['data'][3]; + if ($id_special_day == "") { returnError('error_update_special_day', __('Error updating special day. Id cannot be left blank.')); return; - } - + } + $check_id_special_day = db_get_value ('id', 'talert_special_days', 'id', $id_special_day); - - if (!$check_id_special_day) { + + if (!$check_id_special_day) { returnError('error_update_special_day', __('Error updating special day. Id doesn\'t exists.')); return; } - + if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $special_day)) { returnError('error_update_special_day', __('Error updating special day. Invalid date format.')); return; } - - $return = db_process_sql_update('talert_special_days', - array('date' => $special_day, - 'same_day' => $same_day, - 'description' => $description, - 'id_group' => $idGroup), - array('id' => $id_special_day)); - - returnData('string', - array('type' => 'string', 'data' => (int)((bool)$return))); + + $return = db_process_sql_update('talert_special_days', + array( + 'date' => $special_day, + 'same_day' => $same_day, + 'description' => $description, + 'id_group' => $idGroup), + array('id' => $id_special_day)); + + returnData('string', + array('type' => 'string', 'data' => (int)((bool)$return))); } /** diff --git a/pandora_console/include/functions_clippy.php b/pandora_console/include/functions_clippy.php index f2fa9ed859..a68a1e65aa 100644 --- a/pandora_console/include/functions_clippy.php +++ b/pandora_console/include/functions_clippy.php @@ -277,7 +277,7 @@ function clippy_context_help($help = null) { } $(document).ready(function() { - (function pulse_' . $id . '(){ + (function pulse_' . $id . '() { $("#' . $id . ' img") .delay(100) .animate({\'opacity\': 1}) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 81e212f4cc..9ebd5b8746 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -365,8 +365,6 @@ function config_update_config () { $error_update[] = __('Batch statistics period (secs)'); if (!config_update_value ('agentaccess', (int) get_parameter ('agentaccess'))) $error_update[] = __('Use agent access graph'); - if (!config_update_value ('compact_header', (bool) get_parameter ('compact_header'))) - $error_update[] = 'Deprecated compact_header'; if (!config_update_value ('num_files_attachment', (int) get_parameter ('num_files_attachment'))) $error_update[] = __('Max. recommended number of files in attachment directory'); if (!config_update_value ('delete_notinit', get_parameter ('delete_notinit'))) @@ -461,8 +459,10 @@ function config_update_config () { $error_update[] = __('Shortened module graph data'); if (!config_update_value ('show_group_name', get_parameter('show_group_name'))) $error_update[] = __('Show the group name instead the group icon.'); - if (!config_update_value ('custom_graph_widht', (int) get_parameter('custom_graph_widht', 1))) + if (!config_update_value ('custom_graph_width', (int) get_parameter('custom_graph_width', 1))) $error_update[] = __('Default line thickness for the Custom Graph.'); + if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area'))) + $error_update[] = __('Default type of module charts.'); if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false))) $error_update[] = __('Render data of module type is proc.'); @@ -692,10 +692,6 @@ function config_process_config () { config_update_value ('https', false); } - if (!isset ($config["compact_header"])) { - config_update_value ('compact_header', false); - } - if (!isset ($config["num_files_attachment"])) { config_update_value ('num_files_attachment', 100); } @@ -854,7 +850,7 @@ function config_process_config () { // the first time make a conenction and disable itself // Not Managed here ! - // if (!isset ($config["autoupdate"])){ + // if (!isset ($config["autoupdate"])) { // config_update_value ('autoupdate', true); // } @@ -1260,9 +1256,14 @@ function config_process_config () { config_update_value ('show_group_name', 0); } - if (!isset($config['custom_graph_widht'])) { - config_update_value ('custom_graph_widht', 1); + if (!isset($config['custom_graph_width'])) { + config_update_value ('custom_graph_width', 1); } + + if (!isset($config['type_module_charts'])) { + config_update_value ('type_module_charts', 'area'); + } + if (!isset($config['render_proc'])) { config_update_value ('render_proc', 0); } diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 6ea8e9f07b..d5e236f5df 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -119,7 +119,7 @@ function custom_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGr continue; if ($graph["id_group"] > 0) - if (!isset($groups[$graph["id_group"]])){ + if (!isset($groups[$graph["id_group"]])) { continue; } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 09e7fa73a8..810e70e213 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -420,7 +420,7 @@ function db_get_sql ($sql, $field = 0, $search_history_db = false) { return false; $ax = 0; - foreach ($result[0] as $f){ + foreach ($result[0] as $f) { if ($field == $ax) return $f; $ax++; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index fa870fc6b3..67dbeef716 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1382,12 +1382,12 @@ function events_get_module ($id_agent_module, $period, $date = 0) { * * @return string Type description. */ -function events_get_event_types ($type_id){ +function events_get_event_types ($type_id) { $diferent_types = get_event_types (); $type_desc = ''; - switch($type_id) { + switch ($type_id) { case 'unknown': $type_desc = __('Unknown'); break; @@ -1430,7 +1430,7 @@ function events_get_event_types ($type_id){ default: if (isset($config['text_char_long'])) { foreach ($diferent_types as $key => $type) { - if ($key == $type_id){ + if ($key == $type_id) { $type_desc = ui_print_truncate_text($type, $config['text_char_long'], false, true, false); } } @@ -1449,7 +1449,7 @@ function events_get_event_types ($type_id){ * * @return string Severity description. */ -function events_get_severity_types ($severity_id){ +function events_get_severity_types ($severity_id) { $diferent_types = get_priorities (); @@ -1473,8 +1473,9 @@ function events_get_severity_types ($severity_id){ default: if (isset($config['text_char_long'])) { foreach ($diferent_types as $key => $type) { - if ($key == $severity_id){ - $severity_desc = ui_print_truncate_text($type, $config['text_char_long'], false, true, false); + if ($key == $severity_id) { + $severity_desc = ui_print_truncate_text($type, + $config['text_char_long'], false, true, false); } } } @@ -1630,7 +1631,7 @@ function events_get_event_filter_select($manage = true) { } else { $result = array(); - foreach ($event_filters as $event_filter){ + foreach ($event_filters as $event_filter) { $result[$event_filter['id_filter']] = $event_filter['id_name']; } } @@ -2121,7 +2122,7 @@ function events_page_details ($event, $server = "") { $data[1] .= html_print_image('images/chart_curve.png',true); $data[1] .= ''; $table_details->data[] = $data; - } + } } $data = array(); @@ -2872,11 +2873,12 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")'; } - $sql = sprintf ('SELECT estado, COUNT(*) AS count - FROM tevento - WHERE 1=1 %s %s %s - GROUP BY estado', - $date_filter, $sql_filter, $sql_where); + $sql = sprintf ('SELECT estado, + COUNT(*) AS count + FROM tevento WHERE + %s ' . $sql_where . ' + GROUP BY estado', + $sql_filter); $rows = db_get_all_rows_sql ($sql); diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 92bac4ac35..c6df6d7d77 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -430,9 +430,9 @@ function filemanager_delete_directory($dir) { * * @return array The files in the dirs, empty array for empty dir of files. */ -function filemanager_read_recursive_dir($dir, $relative_path = '') { +function filemanager_read_recursive_dir($dir, $relative_path = '', $add_empty_dirs = false) { $return = array(); - + // Windows compatibility $dir = str_replace("\\", "/", $dir); $relative_path = str_replace("\\", "/", $relative_path); @@ -442,10 +442,21 @@ function filemanager_read_recursive_dir($dir, $relative_path = '') { while (false !== ($entry = readdir($handle))) { if (($entry != ".") && ($entry != "..")) { if (is_dir($dir . $entry)) { - $return = array_merge($return, filemanager_read_recursive_dir($dir . $entry . '/', $relative_path . $entry . '/' )); + $return[] = array( + 'relative' => $relative_path . $entry, + 'absolute' => $dir . $entry, + 'dir' => true); + + $return = array_merge($return, + filemanager_read_recursive_dir( + $dir . $entry . '/', $relative_path . $entry . '/', + '', $add_empty_dirs)); } else { - $return[] = array('relative' => $relative_path . $entry, 'absolute' => $dir . $entry); + $return[] = array( + 'relative' => $relative_path . $entry, + 'absolute' => $dir . $entry, + 'dir' => false); } } } @@ -540,13 +551,15 @@ function filemanager_file_explorer($real_directory, $relative_directory, $files = filemanager_list_dir ($real_directory); + $table = new stdClass(); + $table->width = '98%'; $table->id = 'table_filemanager'; if (!defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; $table->title = '' . __('Index of %s', $relative_directory) . ''; } - if (defined('METACONSOLE')){ + if (defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox_tactical'; $table->title = '' . __('Index of images') . ''; diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 0b8c2f4cce..00e40693b2 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -31,26 +31,29 @@ * * @return array Void array or prediction of the module data. */ -function forecast_projection_graph($module_id, $period = 5184000, $prediction_period, $max_value = false, $min_value = false, $csv = false){ +function forecast_projection_graph($module_id, + $period = SECONDS_2MONTHS, $prediction_period, $max_value = false, + $min_value = false, $csv = false) { + global $config; - + $max_exec_time = ini_get('max_execution_time'); - + if ($max_exec_time !== false) { - + $max_exec_time = (int)$max_exec_time; - + } - + $begin_time = time(); - + $module_data=grafico_modulo_sparse ($module_id, $period, 0, - 300, 300 , '', null, - false, 0, false, - 0, '', 0, 1, false, - true, '', 1, true); - - if (empty($module_data)){ + 300, 300 , '', null, + false, 0, false, + 0, '', 0, 1, false, + true, '', 1, true); + + if (empty($module_data)) { return array(); } // Prevents bad behaviour over image error @@ -245,7 +248,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe //html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]); // Found it - if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){ + if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]) { return $current_ts; } } @@ -269,7 +272,8 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe * * @return mixed timestamp with the prediction date or false */ -function forecast_prediction_date ($module_id, $period = 5184000, $max_value = 0, $min_value = 0){ +function forecast_prediction_date ($module_id, + $period = SECONDS_2MONTHS, $max_value = 0, $min_value = 0) { // Checks interval if ($min_value > $max_value) { return false; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index ac2eb7e4c8..dd61e70c2c 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -374,7 +374,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $timestamp_short = date($time_format, $timestamp); $long_index[$timestamp_short] = date( html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp); - if (!$projection){ + if (!$projection) { $timestamp = $timestamp_short; } @@ -742,12 +742,12 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $series_suffix_str = ' (' . __('Previous') . ')'; // Build the data of the previous period - grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, - $width, $height, $title, $unit_name, - $show_alerts, $avg_only, - $date-$period, $unit, $baseline, $return_data, $show_title, - $projection, $adapt_key, $compare, - $series_suffix, $series_suffix_str, $show_unknown); + grafico_modulo_sparse_data ($agent_module_id, $period, + $show_events, $width, $height, $title, $unit_name, + $show_alerts, $avg_only, $date-$period, $unit, $baseline, + $return_data, $show_title, $projection, $adapt_key, + $compare, $series_suffix, $series_suffix_str, + $show_unknown); switch ($compare) { case 'separated': @@ -759,7 +759,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $color_prev = $color; break; case 'overlapped': - // Store the chart calculated deleting index, because will be over the current period + // Store the chart calculated deleting index, + // because will be over the current period $chart_prev = array_values($chart); $legend_prev = $legend; $series_type_prev = $series_type; @@ -806,26 +807,64 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); - if ($compare === 'separated') { - return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, - $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, - $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, - $series_suffix_str, $menu, $backgroundColor). - '
'. - area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev, - $long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, - $series_type_prev, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, - $series_suffix_str, $menu, $backgroundColor); + if ($config['type_module_charts'] === 'area') { + if ($compare === 'separated') { + return + area_graph($flash_chart, $chart, $width, $height/2, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $homeurl, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $series_type, + $chart_extra_data, $warning_min, $critical_min, + $adapt_key, false, $series_suffix_str, $menu, + $backgroundColor). + '
'. + area_graph($flash_chart, $chart_prev, $width, $height/2, + $color_prev, $legend_prev, $long_index_prev, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $homeurl, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $series_type_prev, + $chart_extra_data, $warning_min, $critical_min, + $adapt_key, false, $series_suffix_str, $menu, + $backgroundColor); + } + else { + // Color commented not to restrict serie colors + return + area_graph($flash_chart, $chart, $width, $height, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $homeurl, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $series_type, + $chart_extra_data, $warning_min, $critical_min, + $adapt_key, false, $series_suffix_str, $menu, + $backgroundColor); + } } - else { - // Color commented not to restrict serie colors - return area_graph($flash_chart, $chart, $width, $height, $color, $legend, - $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, - $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false, - $series_suffix_str, $menu, $backgroundColor); + elseif ($config['type_module_charts'] === 'line') { + if ($compare === 'separated') { + return + line_graph($flash_chart, $chart, $width, $height/2, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor). + '
'. + line_graph($flash_chart, $chart_prev, $width, $height/2, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); + } + else { + // Color commented not to restrict serie colors + return + line_graph($flash_chart, $chart, $width, $height, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); + } } } @@ -924,13 +963,13 @@ function graphic_combined_module ($module_list, $weight_list, $period, if ($projection != false) { $j = $datelimit; $in_range = true; - while ($in_range){ + while ($in_range) { $timestamp_f = graph_get_formatted_date($j, $time_format, $time_format_2); //$timestamp_f = date('d M Y H:i:s', $j); $before_projection[$timestamp_f] = 0; - if ($j > $date){ + if ($j > $date) { $in_range = false; } $j = $j + $interval; @@ -944,7 +983,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, else { $module_number = count ($module_list); } - + $names_number = count($name_list); $units_number = count($unit_list); @@ -1008,7 +1047,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, modules_get_agentmodule_name ($agent_module_id)); $module_name = sprintf(__("projection for %s"), $module_name); $module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false); - + $module_name_list[$i] = $agent_name ." / ". $module_name; } @@ -1035,10 +1074,10 @@ function graphic_combined_module ($module_list, $weight_list, $period, $module_name = io_safe_output( modules_get_agentmodule_name ($agent_module_id)); $module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false); - + $module_name_list[$i] = $agent_name . " / " . $module_name; } - + $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); @@ -1228,7 +1267,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $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; @@ -1242,17 +1281,17 @@ function graphic_combined_module ($module_list, $weight_list, $period, $min = sprintf("%sM", number_format($min / 1000000, 2)); else if ($min > 1000) $min = sprintf("%sK", number_format($min / 1000, 2)); - + if ($max > 1000000) $max = sprintf("%sM", number_format($max / 1000000, 2)); else if ($max > 1000) $max = sprintf("%sK", number_format($max / 1000, 2)); - + if ($avg > 1000000) $avg = sprintf("%sM", number_format($avg / 1000000, 2)); else if ($avg > 1000) $avg = sprintf("%sK", number_format($avg / 1000, 2)); - + if ($last > 1000000) $last = sprintf("%sM", number_format($last / 1000000, 2)); else if ($last > 1000) @@ -1265,7 +1304,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $last = number_format($graph_stats['last'], 2); } - + if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) { $unit = $unit_list[$i]; } @@ -1965,17 +2004,19 @@ function graph_db_agentes_modulos($width, $height) { $data = array (); - switch ($config['dbtype']){ + switch ($config['dbtype']) { case "mysql": case "postgresql": - $modules = db_get_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente + $modules = db_get_all_rows_sql (' + SELECT COUNT(id_agente_modulo), id_agente FROM tagente_modulo WHERE delete_pending = 0 GROUP BY id_agente ORDER BY 1 DESC LIMIT 10'); break; case "oracle": - $modules = db_get_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente + $modules = db_get_all_rows_sql (' + SELECT COUNT(id_agente_modulo), id_agente FROM tagente_modulo WHERE rownum <= 10 AND delete_pending = 0 @@ -1993,7 +2034,7 @@ function graph_db_agentes_modulos($width, $height) { if (empty($agent_name)) { continue; } - switch ($config['dbtype']){ + switch ($config['dbtype']) { case "mysql": case "postgresql": $data[$agent_name]['g'] = $module['COUNT(id_agente_modulo)']; @@ -2641,7 +2682,7 @@ function graph_custom_sql_graph ($id, $width, $height, global $config; $report_content = db_get_row ('treport_content', 'id_rc', $id); - if ($report_content["external_source"] != ""){ + if ($report_content["external_source"] != "") { $sql = io_safe_output ($report_content["external_source"]); } else { @@ -3306,25 +3347,52 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png", false, false, false)); - if ($compare === 'separated') { - return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, - $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], $unit, 1, $series_type, - $chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu). - '
'. - area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev, - $long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], $unit, 1, $series_type_prev, - $chart_extra_data_prev, 0, 0, $adapt_key, false, $series_suffix_str, $menu); + if ($config['type_module_charts'] === 'area') { + if ($compare === 'separated') { + return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, + $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $homeurl, $water_mark, + $config['fontpath'], $config['font_size'], $unit, 1, $series_type, + $chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu). + '
'. + area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev, + $long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $homeurl, $water_mark, + $config['fontpath'], $config['font_size'], $unit, 1, $series_type_prev, + $chart_extra_data_prev, 0, 0, $adapt_key, false, $series_suffix_str, $menu); + } + else { + return area_graph($flash_chart, $chart, $width, $height, $color, $legend, + $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $homeurl, $water_mark, + $config['fontpath'], $config['font_size'], $unit, 1, $series_type, + $chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu); + } } - else { - return area_graph($flash_chart, $chart, $width, $height, $color, $legend, - $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", $unit, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], $unit, 1, $series_type, - $chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu); + elseif ($config['type_module_charts'] === 'line') { + if ($compare === 'separated') { + return + line_graph($flash_chart, $chart, $width, $height/2, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor). + '
'. + line_graph($flash_chart, $chart_prev, $width, $height/2, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); + } + else { + // Color commented not to restrict serie colors + return + line_graph($flash_chart, $chart, $width, $height, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); + } } } @@ -3827,10 +3895,20 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); - return area_graph($flash_chart, $chart, $width, $height, $color, - $legend, array(), '', "", $unit, $homeurl, - $water_mark, $config['fontpath'], $config['font_size'], $unit, - 1, array(), array(), 0, 0, $adapt_key, true, '', $menu); + if ($config['type_module_charts'] === 'area') { + return area_graph($flash_chart, $chart, $width, $height, $color, + $legend, array(), '', "", $unit, $homeurl, + $water_mark, $config['fontpath'], $config['font_size'], $unit, + 1, array(), array(), 0, 0, $adapt_key, true, '', $menu); + } + else { + return + line_graph($flash_chart, $chart, $width, $height, $color, + $legend, $long_index, + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", $unit, $water_mark, $config['fontpath'], + $config['font_size'], $unit, $ttl, $homeurl, $backgroundColor); + } } /** @@ -4030,7 +4108,7 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, $rows = 0; $first = true; - while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)){ + while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)) { $first = false; $rows++; @@ -4109,7 +4187,7 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, grafico_modulo_log4x_trace(__LINE__); - if ($pure == 0){ + if ($pure == 0) { $Graph->add( Image_Graph::horizontal( Image_Graph::vertical( @@ -4153,7 +4231,7 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, $dataset[$i] = Image_Graph::factory('dataset'); $dataset[$i]->setName($severity); - if (isset($valores[$severity])){ + if (isset($valores[$severity])) { $data =& $valores[$severity]; while (list($index, $data2) = each($data)) { $count = $data2['count']; @@ -4249,7 +4327,7 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, //$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); // Show events ! - if ($show_event == 1){ + if ($show_event == 1) { $Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event)); $Plot->setLineColor( 'red' ); $Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross'); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 36be416258..db1cb6ade0 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1118,7 +1118,7 @@ function groups_get_group_by_id($id_group) { * @return mixed Return group_id or false if something goes wrong * */ -function groups_create_group($group_name, $rest_values){ +function groups_create_group($group_name, $rest_values) { if ($group_name == "") { return false; @@ -1992,7 +1992,7 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr return 0; } - else if (!is_array ($group_array)){ + else if (!is_array ($group_array)) { $group_array = array($group_array); } @@ -2069,7 +2069,7 @@ function groups_agent_disabled ($group_array) { return 0; } - else if (!is_array ($group_array)){ + else if (!is_array ($group_array)) { $group_array = array($group_array); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 1940d8ec3a..4d87133f5c 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -118,8 +118,8 @@ function html_print_side_layer ($params) { // Check mandatory values, if any of them is missed, return '' $mandatory = array('icon_closed', 'body_text'); - foreach($mandatory as $man) { - if(!isset($params[$man])) { + foreach ($mandatory as $man) { + if (!isset($params[$man])) { return ''; } } @@ -141,15 +141,15 @@ function html_print_side_layer ($params) { 'icon_open' => $params['icon_closed'] ); - foreach($defaults as $token => $value) { - if(!isset($params[$token])) { + foreach ($defaults as $token => $value) { + if (!isset($params[$token])) { $params[$token] = $value; } } //z-index is 1 because 2 made the calendar show under the side_layer - switch($params['position']) { + switch ($params['position']) { case 'left': $round_class = 'menu_sidebar_radius_right'; $body_float = 'left'; @@ -166,29 +166,36 @@ function html_print_side_layer ($params) { $button_float = 'left'; break; } - + $out_html = ''; - + $out_js = ""); diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index 6e37d652b9..e70dd5e073 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -214,7 +214,7 @@ class Agent { $ui->contentAddLinkListener('list_agent_Modules'); $ui->contentAddHtml(" diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 041cd09697..0e342f210d 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -91,7 +91,7 @@ if ($id_module) { enterprise_hook('open_meta_frame'); -if (!defined('METACONSOLE')){ +if (!defined('METACONSOLE')) { $filters = ''; @@ -100,7 +100,8 @@ if (!defined('METACONSOLE')){ $table->cellspacing = 0; $table->cellpadding = 0; $table->class = "databox filters"; -}else{ +} +else { $filters = ''; @@ -156,7 +157,7 @@ else { if (defined('METACONSOLE')) { if ($modulegroup != '-1') $sql_conditions .= sprintf (" AND tagente_modulo.id_module_group IN (SELECT id_mg - FROM tmodule_group WHERE name = '%s')", $modulegroup); + FROM tmodule_group WHERE name = '%s')", $modulegroup); } else if ($modulegroup > -1) { $sql_conditions .= sprintf (" AND tagente_modulo.id_module_group = '%d'", $modulegroup); @@ -186,7 +187,7 @@ elseif ($status == AGENT_MODULE_STATUS_CRITICAL_BAD) { //Critical $sql_conditions .= " AND tagente_estado.estado = 1 AND utimestamp > 0"; } elseif ($status == AGENT_MODULE_STATUS_WARNING) { //Warning - $sql_conditions .= " AND tagente_estado.estado = 2 AND utimestamp > 0"; + $sql_conditions .= " AND tagente_estado.estado = 2 AND utimestamp > 0"; } elseif ($status == AGENT_MODULE_STATUS_NOT_NORMAL) { //Not normal $sql_conditions .= " AND tagente_estado.estado <> 0"; @@ -242,9 +243,14 @@ if ($tag_filter !== 0) { $groups = users_get_groups($config["id_user"]); if ($ag_group !== 0) { - $sql_conditions_tags = tags_get_acl_tags($config['id_user'], $ag_group, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); + $sql_conditions_tags = tags_get_acl_tags($config['id_user'], + $ag_group, 'AR', 'module_condition', 'AND', 'tagente_modulo', + true, array(), true); } else { - $sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); + $sql_conditions_tags = tags_get_acl_tags( + $config['id_user'], array_keys($groups), 'AR', + 'module_condition', 'AND', 'tagente_modulo', true, array(), + true); } if (is_numeric($sql_conditions_tags)) { @@ -402,14 +408,14 @@ if (defined('METACONSOLE')) { if ($key_group_all !== false) unset($groups_select[$key_group_all]); } -if(defined("METACONSOLE")){ +if(defined("METACONSOLE")) { $table->style[0] = 'vertical-align:middle; font-weight: bold;'; $table->style[1] = 'vertical-align:middle; font-weight: bold;'; $table->style[2] = 'vertical-align:middle; font-weight: bold;'; $table->style[3] = 'vertical-align:middle; font-weight: bold;'; $table->style[4] = 'vertical-align:middle; font-weight: bold;'; } -else{ +else { $table->style[0] = 'font-weight: bold;'; $table->style[1] = 'font-weight: bold;'; $table->style[2] = 'font-weight: bold;'; @@ -427,7 +433,7 @@ $table->data[0][2] = __('Monitor status'); $fields = array (); -$fields[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); +$fields[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); $fields[AGENT_MODULE_STATUS_WARNING] = __('Warning'); $fields[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); $fields[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); @@ -494,7 +500,7 @@ else { $table_custom_fields = new stdClass(); $table_custom_fields->class = 'filters'; $table_custom_fields->width = '100%'; -if(defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table_custom_fields->width = '100%'; $table_custom_fields->class = 'filters'; $table_custom_fields->styleTable = 'margin-left:0px; margin-top:15px;'; @@ -528,15 +534,17 @@ foreach ($custom_fields as $custom_field) { $table_custom_fields->data[] = $row; } -if(defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $table->colspan[2][0] = 7; - $table->data[2][0] = ui_toggle(html_print_table($table_custom_fields, true), __('Advanced Options'),'',true,true); + $table->data[2][0] = ui_toggle( + html_print_table($table_custom_fields, true), + __('Advanced Options'), '', true, true); $filters .= html_print_table($table, true); $filters .= ""; ui_toggle($filters, __('Show Options')); } -else{ +else { $table->colspan[2][0] = 7; $table->data[2][0] = ui_toggle(html_print_table($table_custom_fields, true), __('Agent custom fields'),'',true,true); @@ -903,7 +911,7 @@ $table->cellpadding = 0; $table->cellspacing = 0; $table->width = "100%"; $table->class = "databox data"; -if(defined('METACONSOLE')){ +if(defined('METACONSOLE')) { $table->width = "100%"; $table->cellpadding = '0'; $table->cellspacing = '0'; @@ -917,7 +925,7 @@ $table->align = array (); if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) $table->head[0] = "" . __('P.') . ""; -$table->head[1] = __('Agent'); +$table->head[1] = __('Agent'); if (! defined ('METACONSOLE')) { $table->head[1] .=' ' . html_print_image("images/sort_up.png", true, array("style" => $selectAgentNameUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectAgentNameDown, "alt" => "down")) . ''; @@ -930,7 +938,7 @@ if (! defined ('METACONSOLE')) { } $table->align[2] = "left"; -$table->head[3] = __('Module name'); +$table->head[3] = __('Module name'); if (! defined ('METACONSOLE')) { $table->head[3] .= ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectModuleNameUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . ''; @@ -940,7 +948,7 @@ if (! defined ('METACONSOLE')) { $table->head[4] = __('Tags'); */ -$table->head[5] = __('Interval'); +$table->head[5] = __('Interval'); if (! defined ('METACONSOLE')) { $table->head[5] .= ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . ''; @@ -1059,7 +1067,7 @@ foreach ($result as $row) { 'id_agente='. $row["id_agent"] . '&' . 'loginhash=auto&' . 'loginhash_data=' . $row["hashdata"] . '&' . - 'loginhash_user=' . str_rot13($row["user"]) . '">'; + 'loginhash_user=' . str_rot13($row["user"]) . '">'; $agent_name = ui_print_truncate_text($row["agent_name"], 'agent_small', false, true, false, '[…]', 'font-size:7.5pt;'); @@ -1229,7 +1237,7 @@ foreach ($result as $row) { $row['min_critical'], $row['str_critical']); if (is_numeric($row["datos"])) { - if ( $config["render_proc"] ){ + if ( $config["render_proc"] ) { switch($row["module_type"]) { case 2: case 6: @@ -1247,7 +1255,8 @@ foreach ($result as $row) { $salida = format_numeric($row["datos"]); break; } - }else{ + } + else { $salida = format_numeric($row["datos"]); } @@ -1277,7 +1286,7 @@ foreach ($result as $row) { $link = "winopeng_var('operation/agentes/snapshot_view.php?" . "id=" . $row["id_agente_modulo"] . "&refr=" . $row["current_interval"] . - "&label=" . rawurlencode(urlencode(io_safe_output($row["module_name"]))) . "','" . $win_handle . "', 700,480)"; + "&label=" . rawurlencode(urlencode(io_safe_output($row["module_name"]))) . "','" . $win_handle . "', 700,480)"; $salida = '' . html_print_image("images/default_list.png", true, @@ -1377,9 +1386,9 @@ ui_require_javascript_file('pandora_modules'); } }); - $('#ag_group').change (function (){ + $('#ag_group').change (function () { strict_user = $("#text-strict_user_hidden").val(); - + if (($("#ag_group").val() != 0) && (strict_user != 0)) { $("#tag_filter").css('display', 'none'); $("#tag_td").css('display', 'none'); diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 1e3786c721..0597f26659 100755 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -42,7 +42,7 @@ if ($force_refresh == 1) { if ($config["realtimestats"] == 0) { $updated_time =""; $updated_time .= __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); - $updated_time .= ""; + $updated_time .= ""; } else { $updated_time = __("Updated at realtime"); diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 5b98f9b9a9..dd3198c8ad 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -541,7 +541,7 @@ foreach ($result as $event) { } if (in_array('ack_utimestamp',$show_fields)) { - if($event["ack_utimestamp"] == 0){ + if ($event["ack_utimestamp"] == 0) { $data[$i] = ''; } else { @@ -650,7 +650,7 @@ if (!empty ($table->data)) { } if ($allow_action) { - echo ''; + echo ''; echo ""; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 3bcf492b3b..e0e2b1b5a0 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -693,10 +693,10 @@ $(document).ready( function() { // Remove row due to new state if (($("#status").val() == 0) || ($("#status").val() == 1)) { - $.each($tr, function(index, value){ + $.each($tr, function(index, value) { row = value; - if ($(row).attr('id') != ''){ + if ($(row).attr('id') != '') { row_id_name = $(row).attr('id').split('-').shift(); row_id_number = $(row).attr('id').split('-').pop() - 1; diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index e7520ba4d1..0e39b47c9f 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -182,7 +182,7 @@ if (!defined("METACONSOLE")) { $table->data[0][1] = '' . html_print_image('images/chart_curve.png', true, array('title' => __('Show events graph'))) . ''; $table->cellstyle[0][1] = 'background: #ECECEC;'; - if(defined('METACONSOLE')){ + if(defined('METACONSOLE')) { $table->width = '100%'; $table->class='events_list'; } @@ -210,14 +210,14 @@ if (check_acl ($config["id_user"], 0, "EW") || check_acl ($config["id_user"], 0, $table->cellspacing = 4; $table->cellpadding = 4; $table->class = 'databox'; - if(defined('METACONSOLE')){ + if (defined('METACONSOLE')) { $table->width = '100%'; $table->class = 'databox data'; $table->cellspacing = 0; $table->cellpadding = 0; } $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; - if(!defined("METACONSOLE")) + if (!defined("METACONSOLE")) $table->style[0] = 'width: 50%; width:50%;'; $data = array(); diff --git a/pandora_console/operation/extensions.php b/pandora_console/operation/extensions.php index 7c505cf82d..2411d65d54 100644 --- a/pandora_console/operation/extensions.php +++ b/pandora_console/operation/extensions.php @@ -34,7 +34,7 @@ if (sizeof ($config['extensions']) == 0) { $delete = get_parameter ("delete", ""); $name = get_parameter ("name", ""); -if ($delete != ""){ +if ($delete != "") { if (!file_exists($config["homedir"]."/extensions/ext_backup")) mkdir($config["homedir"]."/extensions/ext_backup"); $source = $config["homedir"]."/$delete.php"; diff --git a/pandora_console/operation/gis_maps/ajax.php b/pandora_console/operation/gis_maps/ajax.php index 33e5de8aa3..74f669cd96 100644 --- a/pandora_console/operation/gis_maps/ajax.php +++ b/pandora_console/operation/gis_maps/ajax.php @@ -217,9 +217,9 @@ switch ($opt) { $returnJSON['content'] .= __('Position (Lat, Long, Alt)') . ': (' . $row['latitude'] . ', ' . $row['longitude'] . ', ' . $row['altitude'] . ')
'; $returnJSON['content'] .= __('Start contact') . ': ' . $row['start_timestamp'] . '
'; $returnJSON['content'] .= __('Last contact') . ': ' . $row['end_timestamp'] . '
'; - $returnJSON['content'] .= __('Num reports') . ': '.$row['number_of_packages'].'
'; + $returnJSON['content'] .= __('Num reports') . ': '.$row['number_of_packages'].'
'; if ($row['manual_placemen']) - $returnJSON['content'] .= '
' . __('Manual placement') . '
'; + $returnJSON['content'] .= '
' . __('Manual placement') . '
'; echo json_encode($returnJSON); diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 094ae128ee..03ec5a5d5f 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -193,7 +193,7 @@ if ($layers != false) { // Resize GIS map on fullscreen ?> '; echo "
"; - if (defined("METACONSOLE")){ + if (defined("METACONSOLE")) { echo " - "; + "; } if (defined ('METACONSOLE')) { $list_servers = array(); diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index 5b6048d6c2..329d191ef3 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -103,7 +103,7 @@ if ($view_graph) { include ("general/noaccess.php"); exit; } - html_print_input_hidden ('lineWidhtGraph', $config['custom_graph_widht']); + html_print_input_hidden ('lineWidhtGraph', $config['custom_graph_width']); $url = "index.php?" . "sec=reporting&" . "sec2=operation/reporting/graph_viewer&" . diff --git a/pandora_console/operation/search_alerts.getdata.php b/pandora_console/operation/search_alerts.getdata.php index c03d26ad0a..7a0e230a5c 100644 --- a/pandora_console/operation/search_alerts.getdata.php +++ b/pandora_console/operation/search_alerts.getdata.php @@ -167,13 +167,17 @@ if($searchAlerts) { )'; break; } - - $alertsraw = agents_get_alerts_simple ($agents, "all_enabled", array('offset' => get_parameter ('offset',0), 'limit' => $config['block_size'], 'order' => $order['field'] . " " . $order['order']), $whereAlerts); - + + $alertsraw = agents_get_alerts_simple($agents, "all_enabled", + array('offset' => get_parameter ('offset', 0), + 'limit' => $config['block_size'], + 'order' => $order['field'] . " " . $order['order']), + $whereAlerts); + $stringSearchPHP = substr($stringSearchSQL,1,strlen($stringSearchSQL)-2); - + $alerts = array(); - foreach($alertsraw as $key => $alert){ + foreach ($alertsraw as $key => $alert) { $finded = false; $alerts[$key]['disabled'] = $alert['disabled']; $alerts[$key]['id_agente'] = modules_get_agentmodule_agent($alert['id_agent_module']); @@ -189,7 +193,7 @@ if($searchAlerts) { $alerts[$key]['actions'] = implode(',',$actions_name); } - + $totalAlerts = count($alerts); if ($only_count) { diff --git a/pandora_console/operation/search_reports.getdata.php b/pandora_console/operation/search_reports.getdata.php index 48518d4dcb..9596a45482 100644 --- a/pandora_console/operation/search_reports.getdata.php +++ b/pandora_console/operation/search_reports.getdata.php @@ -35,13 +35,13 @@ foreach($userreports as $userreport) { $userreports_id[] = $userreport['id_report']; } -if(!$userreports_id){ +if (!$userreports_id) { $reports_condition = " AND 1<>1"; } else { $reports_condition = " AND id_report IN (".implode(',',$userreports_id).")"; } - + $reports = false; if($searchReports) { diff --git a/pandora_console/operation/servers/recon_view.php b/pandora_console/operation/servers/recon_view.php index 70627ec81b..1a4f9cf0a1 100644 --- a/pandora_console/operation/servers/recon_view.php +++ b/pandora_console/operation/servers/recon_view.php @@ -30,30 +30,30 @@ if ($servers === false) { $servers = array (); return; } -else{ +else { $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); if ($recon_task === false) { ui_print_page_header (__('Recon View'), "images/op_recon.png", false, "", false); require_once ($config['homedir'] . "/general/firts_task/recon_view.php"); return; } - else{ + else { require_once ($config["homedir"] . '/include/functions_graph.php'); require_once ($config["homedir"] . '/include/functions_servers.php'); require_once ($config['homedir'] . "/include/functions_network_profiles.php"); - + if (check_acl ($config['id_user'], 0, "AW")) { $options['manage']['text'] = "" . html_print_image("images/setup.png", true, array('title' => __('Manage'))) . ""; } - + $options[]['text'] = "" . html_print_image("images/refresh_mc.png", true, array('title' => __('Refresh'))) . ""; - + ui_print_page_header (__('Recon View'), "images/op_recon.png", false, "", false, $options); - + $modules_server = 0; $total_modules = 0; $total_modules_data = 0; - + // -------------------------------- // FORCE A RECON TASK // -------------------------------- @@ -63,12 +63,12 @@ else{ servers_force_recon_task($id); } } - + foreach ($servers as $serverItem) { $id_server = $serverItem["id_server"]; $server_name = servers_get_name ($id_server); $recon_tasks = db_get_all_rows_field_filter ("trecon_task", "id_recon_server", $id_server); - + // Show network tasks for Recon Server if ($recon_tasks === false) { $recon_tasks = array (); @@ -82,34 +82,34 @@ else{ $table->head = array (); $table->data = array (); $table->align = array (); - + $table->head[0] = __('Force'); $table->align[0] = "center"; - + $table->head[1] = __('Task name'); $table->align[1] = "center"; - + $table->head[2] = __('Interval'); $table->align[2] = "center"; - + $table->head[3] = __('Network'); $table->align[3] = "center"; - + $table->head[4] = __('Status'); $table->align[4] = "center"; - + $table->head[5] = __('Template'); $table->align[5] = "center"; - + $table->head[6] = __('Progress'); $table->align[6] = "center"; - + $table->head[7] = __('Updated at'); $table->align[7] = "center"; - + $table->head[8] = __('Edit'); $table->align[8] = "center"; - + foreach ($recon_tasks as $task) { $data = array (); @@ -123,10 +123,10 @@ else{ } $data[1] = ''. $task["name"].''; - + $data[2] = human_time_description_raw ($task["interval_sweep"]); - - if ($task["id_recon_script"] == 0){ + + if ($task["id_recon_script"] == 0) { $data[3] = $task["subnet"]; } else { @@ -139,8 +139,8 @@ else{ else { $data[4] = __('Pending'); } - - if ($task["id_recon_script"] == 0){ + + if ($task["id_recon_script"] == 0) { // Network recon task $data[5] = html_print_image ("images/network.png", true, array ("title" => __('Network recon task')))."  "; $data[5] .= network_profiles_get_name ($task["id_network_profile"]); @@ -150,7 +150,7 @@ else{ $data[5] = html_print_image ("images/plugin.png", true). "  "; $data[5] .= db_get_sql (sprintf("SELECT name FROM trecon_script WHERE id_recon_script = %d", $task["id_recon_script"])); } - + if ($task["status"] <= 0 || $task["status"] > 100) { $data[6] = "-"; } @@ -159,7 +159,7 @@ else{ } $data[7] = ui_print_timestamp ($task["utimestamp"], true); - + if (check_acl ($config["id_user"], $task["id_group"], "PM")) { $data[8] = ''.html_print_image ("images/wrench_orange.png", true).''; } @@ -168,7 +168,7 @@ else{ } array_push ($table->data, $data); } - + if (empty ($table->data)) { echo '
'.__("Server") . " " . $server_name . " " . __("has no recon tasks assigned").'
'; } diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 5c54a5ae07..958f8b0400 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -266,9 +266,9 @@ if ($filter_status != -1) $whereSubquery .= ' AND status = ' . $filter_status; if ($trap_type == 5) { - $whereSubquery .= ' AND type NOT IN (0, 1, 2, 3, 4)'; + $whereSubquery .= ' AND type NOT IN (0, 1, 2, 3, 4)'; } -else if ($trap_type != -1){ +else if ($trap_type != -1) { $whereSubquery .= ' AND type = ' . $trap_type; } @@ -457,7 +457,7 @@ if ($traps !== false) { foreach ($traps as $trap) { $data = array (); - if (empty($trap["description"])){ + if (empty($trap["description"])) { $trap["description"]=""; } $severity = enterprise_hook ('get_severity', array ($trap)); diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index ee8fe5b622..6bea6e55f4 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -128,7 +128,7 @@ $table->style[2] = 'font-weight: bold;'; // Agent filter $agent_status_arr = array(); $agent_status_arr[AGENT_STATUS_ALL] = __('All'); //default -$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal'); +$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal'); $agent_status_arr[AGENT_STATUS_WARNING] = __('Warning'); $agent_status_arr[AGENT_STATUS_CRITICAL] = __('Critical'); $agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); @@ -153,7 +153,7 @@ if (!defined('METACONSOLE')) { // Module filter $module_status_arr = array(); $module_status_arr[-1] = __('All'); //default - $module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); + $module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); $module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning'); $module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); $module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); @@ -183,7 +183,8 @@ if (defined('METACONSOLE')) { echo "
"; ui_toggle($form_html, __('Show Options')); echo "
"; -}else{ +} +else { //echo "
"; ui_toggle($form_html, __('Tree search')); } @@ -328,15 +329,29 @@ enterprise_hook('close_meta_frame'); period = $('#period').val(); params.selection_mode = $('input[name=selection_mode]:checked').val(); - if(!params.selection_mode){params.selection_mode='fromnow';} + if (!params.selection_mode) { + params.selection_mode='fromnow'; + } + params.date_from = $('#text-date_from').val(); - if(!params.date_from){params.date_from = f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate();} + if (!params.date_from) { + params.date_from = f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate(); + } + params.time_from = $('#text-time_from').val(); - if(!params.time_from){params.time_from = f.getHours() + ":" + f.getMinutes();} + if (!params.time_from) { + params.time_from = f.getHours() + ":" + f.getMinutes(); + } + params.date_to = $('#text-date_to').val(); - if(!params.date_to){params.date_to =f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate();} + if (!params.date_to) { + params.date_to =f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate(); + } + params.time_to = $('#text-time_to').val(); - if(!params.time_to){params.time_to = f.getHours() + ":" + f.getMinutes();} + if (!params.time_to) { + params.time_to = f.getHours() + ":" + f.getMinutes(); + } params.page = "include/ajax/module"; params.get_module_detail = 1; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index c825246fc6..b7df07dfe2 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -53,11 +53,11 @@ else { $view_mode = true; } -if (is_ajax ()){ +if (is_ajax ()) { $shortcut_update = get_parameter("shortcut_update", 0); - // Update of user to show/don't show shortcut bar + // Update of user to show/don't show shortcut bar if ($shortcut_update) { // First we get the actual state @@ -184,7 +184,7 @@ $table->width = '98%'; $table->cellspacing = 4; $table->cellpadding = 4; $table->class = 'vertical_fields'; -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { $jump = "  "; $table->width = '100%'; $table->class = 'databox data'; @@ -397,7 +397,7 @@ if (!defined('METACONSOLE')) echo '

'.__('Profiles/Groups assigned to this user').'

'; $table->width = '98%'; -if (defined('METACONSOLE')){ +if (defined('METACONSOLE')) { echo '
'; $table->width = '100%'; $table->class = 'databox_tactical data'; @@ -409,7 +409,7 @@ $table->data = array (); $table->head = array (); $table->align = array (); $table->style = array (); -if (!defined('METACONSOLE')){ +if (!defined('METACONSOLE')) { $table->style[0] = 'font-weight: bold'; $table->style[1] = 'font-weight: bold'; } diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index c29fed8b26..4ad3816e5d 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 6.0dev -%define release 150602 +%define release 150618 # 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 0914099423..673b57b47e 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 6.0dev -%define release 150602 +%define release 150618 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index 71f6d3a6ec..3f6f1af553 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -193,7 +193,7 @@ INSERT INTO "tlanguage" VALUES ('ru','Русский'); INSERT INTO "tlanguage" VALUES ('sk','Slovenčina'); INSERT INTO "tlanguage" VALUES ('tr','Türkçe'); INSERT INTO "tlanguage" VALUES ('zh_CN','简化字'); -INSERT INTO "tlanguage" VALUES ('ca','Čatalan'); +INSERT INTO "tlanguage" VALUES ('ca','Catalan'); COMMIT WORK; -- @@ -346,10 +346,10 @@ INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "t INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (201,'Free RAM','Available RAM memory in bytes',16,1,0,0,300,0,'','','','SELECT AvailableBytes from Win32_PerfRawData_PerfOS_Memory',1,6,0,'Administrator',NULL,NULL,10,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (202,'Windows version','Operating system version',16,3,0,0,300,1,'','','','SELECT Caption FROM Win32_OperatingSystem',1,6,0,'Administrator',NULL,NULL,10,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (203,'Free RAM','Available RAM memory in bytes',16,1,0,0,300,0,'','','','SELECT AvailableBytes from Win32_PerfRawData_PerfOS_Memory',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (204,'Hostname','The hostname of the machine.',16,3,0,0,300,0,'','','','ServerName FROM Win32_WindowsProductActivation',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (204,'Hostname','The hostname of the machine.',16,3,0,0,300,0,'','','','SELECT DNSHostName FROM Win32_ComputerSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (205,'Computer number of CPUs','Displays the number of CPUs present in the system',17,1,0,0,300,1,'','','','SELECT NumberOfProcessors FROM Win32_ComputerSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (206,'Server Domain','Display the Domain the machine belongs to.',16,3,0,0,300,0,'','','','SELECT Domain FROM Win32_ComputerSystem',2,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (207,'Number of Processes','Displays the number of processes running in the system',16,1,0,0,300,3,'','','','SELECT NumberOfProcesses FROM Win32_OperatingSystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (207,'Number of Processes','Displays the number of processes running in the system',16,1,0,0,300,0,'','','','SELECT NumberOfProcesses FROM Win32_OperatingSystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (208,'Serial Number','Serial Number of the machine',16,3,0,0,300,3,'','','','SELECT SerialNumber FROM Win32_OperatingSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (209,'CPU Model','Displays the CPU model',17,3,0,0,300,1,'','','','SELECT Name FROM Win32_Processor',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (210,'Service Pack','Service Pack Version Installed',16,1,0,0,300,3,'','','','SELECT ServicePackMajorVersion FROM Win32_OperatingSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -361,7 +361,7 @@ INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "t INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (216,'Total Visible Memory Size','Total Visible Memory Size',16,1,0,0,300,3,'','','','SELECT TotalVisibleMemorySize from win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (217,'Free Space In Paging Files','Gets the free space in paging files',16,1,0,0,300,0,'','','','Select FreeSpaceInPagingFiles from Win32_operatingsystem',4,6,0,'none','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (218,'Free Space In Paging Files','Gets the free space in paging files',16,1,0,0,300,0,'','','','Select FreeSpaceInPagingFiles from Win32_operatingsystem',4,6,0,'none','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (219,'Number of Users','Displays the number of users',16,1,0,0,300,3,'','','','SELECT NumberOfUsers FROM Win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (219,'Number of Users','Displays the number of users',16,1,0,0,300,0,'','','','SELECT NumberOfUsers FROM Win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (220,'Last BootUp Time','Displays the Last BootUp Time',16,3,0,0,300,0,'','','','SELECT LastBootUpTime FROM Win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (221,'BIOS Name','Displays the BIOS Name',17,3,0,0,300,1,'','','','SELECT BiosCharacteristics FROM Win32_BIOS',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO "tnetwork_component" ("id_nc", "name", "description", "id_group", "type", "max", "min", "module_interval", "tcp_port", "tcp_send", "tcp_rcv", "snmp_community", "snmp_oid", "id_module_group", "id_modulo", "id_plugin", "plugin_user", "plugin_pass", "plugin_parameter", "max_timeout", "history_data", "min_warning", "max_warning", "str_warning", "min_critical", "max_critical", "str_critical", "min_ff_event", "custom_string_1", "custom_string_2", "custom_string_3", "custom_integer_1", "custom_integer_2", "post_process", "wizard_level", "critical_instructions", "warning_instructions", "unknown_instructions", "tags", "disabled_types_event", "module_macros") VALUES (222,'BIOS Version','Displays the BIOS version',17,3,0,0,300,5,'','','','SELECT BIOSVersion FROM Win32_BIOS',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -1000,9 +1000,9 @@ SELECT setval('tgis_map_layer_id_tmap_layer_seq', (SELECT (SELECT MAX(id_tmap_la INSERT INTO "talert_commands" ("id", "name", "command", "description", "internal", "fields_descriptions", "fields_values") VALUES (12,'Remote agent control','/usr/share/pandora_server/util/udp_client.pl _address_ 41122 "_field1_"','This command is used to send commands to the Pandora FMS agents with the UDP server enabled. The UDP server is used to order agents (Windows and UNIX) to "refresh" the agent execution: that means, to force the agent to execute and send data',0,'[\"Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); SELECT setval('talert_commands_id_seq', (SELECT (SELECT MAX(id) FROM talert_commands))); -INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "id_group", "action_threshold") VALUES (1,'Mail to XXX',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','',0,0); -INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "id_group", "action_threshold") VALUES (2,'Restart agent',12,'REFRESH AGENT *','','',0,0); -INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "id_group", "action_threshold") VALUES (3,'Pandora FMS Event',3,'_agent_ _module_ generated an event alert (_data_)','alert_fired','pandora','','4','','','','','',0,0,'RECOVERED: _agent_ _module_ generated event alert (_data_)','alert_ceased','pandora','','4','','','','',''); +INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10", "id_group", "action_threshold", "field1_recovery", "field2_recovery", "field3_recovery", "field4_recovery", "field5_recovery", "field6_recovery", "field7_recovery", "field8_recovery", "field9_recovery", "field10_recovery") VALUES (1,'Mail to XXX',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','','','','','','','','',0,0,'','','','','','','','','',''); +INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10", "id_group", "action_threshold", "field1_recovery", "field2_recovery", "field3_recovery", "field4_recovery", "field5_recovery", "field6_recovery", "field7_recovery", "field8_recovery", "field9_recovery", "field10_recovery") VALUES (2,'Restart agent',12,'REFRESH AGENT *','','','','','','','','','',0,0,'','','','','','','','','',''); +INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10", "id_group", "action_threshold", "field1_recovery", "field2_recovery", "field3_recovery", "field4_recovery", "field5_recovery", "field6_recovery", "field7_recovery", "field8_recovery", "field9_recovery", "field10_recovery") VALUES (3,'Pandora FMS Event',3,'_agent_ _module_ generated an event alert (_data_)','alert_fired','pandora','','4','','','','','',0,0,'RECOVERED: _agent_ _module_ generated event alert (_data_)','alert_ceased','pandora','','4','','','','',''); INSERT INTO "talert_actions" ("id", "name", "id_alert_command", "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10", "id_group", "action_threshold", "field1_recovery", "field2_recovery", "field3_recovery", "field4_recovery", "field5_recovery", "field6_recovery", "field7_recovery", "field8_recovery", "field9_recovery", "field10_recovery") VALUES (4,'Create a ticket in Integria IMS',11,'http://localhost/integria/include/api.php','1234','admin','_agent_: _alert_name_','1','3','_alert_description_','','','',0,0,'','','','','','','','','',''); SELECT setval('talert_actions_id_seq', (SELECT (SELECT MAX(id) FROM talert_actions))); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index 1b49687696..95872fe493 100755 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -27,7 +27,7 @@ --\c "pandora" -- For previous PostgreSQL version 9.0 -CREATE LANGUAGE plpgsql; +CREATE OR REPLACE LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION unix_timestamp(TIMESTAMP without time zone = CURRENT_TIMESTAMP) RETURNS double precision AS 'SELECT ceil(date_part(''epoch'', $1)); ' LANGUAGE SQL; @@ -1118,8 +1118,8 @@ CREATE TABLE "tlayout_data" ( "id_group" INTEGER NOT NULL default 0, "id_custom_graph" INTEGER NOT NULL default 0, "border_width" INTEGER NOT NULL default 0, - "border_color" varchar(200) DEFAULT "", - "fill_color" varchar(200) DEFAULT "" + "border_color" varchar(200) DEFAULT '', + "fill_color" varchar(200) DEFAULT '' ); -- --------------------------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index d0a838ccfb..a15df658eb 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('graph_res','5'), ('step_compact','1'), ('db_scheme_version','6.0dev'), -('db_scheme_build','PD150602'), +('db_scheme_build','PD150618'), ('show_unknown','0'), ('show_lastalerts','1'), ('style','pandora'), @@ -327,10 +327,10 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (201,'Free RAM','Available RAM memory in bytes',16,1,0,0,300,0,'','','','SELECT AvailableBytes from Win32_PerfRawData_PerfOS_Memory',1,6,0,'Administrator',NULL,NULL,10,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (202,'Windows version','Operating system version',16,3,0,0,300,1,'','','','SELECT Caption FROM Win32_OperatingSystem',1,6,0,'Administrator',NULL,NULL,10,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (203,'Free RAM','Available RAM memory in bytes',16,1,0,0,300,0,'','','','SELECT AvailableBytes from Win32_PerfRawData_PerfOS_Memory',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (204,'Hostname','The hostname of the machine.',16,3,0,0,300,0,'','','','ServerName FROM Win32_WindowsProductActivation',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (204,'Hostname','The hostname of the machine.',16,3,0,0,300,0,'','','','SELECT DNSHostName FROM Win32_ComputerSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (205,'Computer number of CPUs','Displays the number of CPUs present in the system',17,1,0,0,300,1,'','','','SELECT NumberOfProcessors FROM Win32_ComputerSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (206,'Server Domain','Display the Domain the machine belongs to.',16,3,0,0,300,0,'','','','SELECT Domain FROM Win32_ComputerSystem',2,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (207,'Number of Processes','Displays the number of processes running in the system',16,1,0,0,300,3,'','','','SELECT NumberOfProcesses FROM Win32_OperatingSystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (207,'Number of Processes','Displays the number of processes running in the system',16,1,0,0,300,0,'','','','SELECT NumberOfProcesses FROM Win32_OperatingSystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (208,'Serial Number','Serial Number of the machine',16,3,0,0,300,3,'','','','SELECT SerialNumber FROM Win32_OperatingSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (209,'CPU Model','Displays the CPU model',17,3,0,0,300,1,'','','','SELECT Name FROM Win32_Processor',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (210,'Service Pack','Service Pack Version Installed',16,1,0,0,300,3,'','','','SELECT ServicePackMajorVersion FROM Win32_OperatingSystem',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -342,7 +342,7 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (216,'Total Visible Memory Size','Total Visible Memory Size',16,1,0,0,300,3,'','','','SELECT TotalVisibleMemorySize from win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (217,'Free Space In Paging Files','Gets the free space in paging files',16,1,0,0,300,0,'','','','Select FreeSpaceInPagingFiles from Win32_operatingsystem',4,6,0,'none','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (218,'Free Space In Paging Files','Gets the free space in paging files',16,1,0,0,300,0,'','','','Select FreeSpaceInPagingFiles from Win32_operatingsystem',4,6,0,'none','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (219,'Number of Users','Displays the number of users',16,1,0,0,300,3,'','','','SELECT NumberOfUsers FROM Win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (219,'Number of Users','Displays the number of users',16,1,0,0,300,0,'','','','SELECT NumberOfUsers FROM Win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (220,'Last BootUp Time','Displays the Last BootUp Time',16,3,0,0,300,0,'','','','SELECT LastBootUpTime FROM Win32_operatingsystem',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (221,'BIOS Name','Displays the BIOS Name',17,3,0,0,300,1,'','','','SELECT BiosCharacteristics FROM Win32_BIOS',4,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (222,'BIOS Version','Displays the BIOS version',17,3,0,0,300,5,'','','','SELECT BIOSVersion FROM Win32_BIOS',1,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 614c0c8dc6..f9fb789fcd 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 6.0dev-150602 +Version: 6.0dev-150618 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 a5559b7b34..c7e2e6a370 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="6.0dev-150602" +pandora_version="6.0dev-150618" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index da391bf64c..133cf401f7 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 = "6.0dev"; -my $pandora_build = "150602"; +my $pandora_build = "150618"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 6be6306742..3125396799 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 6.0dev -%define release 150602 +%define release 150618 Summary: Pandora FMS Server Name: %{name} @@ -83,7 +83,7 @@ install -m 0640 conf/pandora_server.conf.new $RPM_BUILD_ROOT%{_sysconfdir}/pando mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d chmod 0750 $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d cat < $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d/pandora -Defaults:pandora !requiretty +Defaults:root !requiretty EOF chmod 0440 $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d/pandora diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 8e60889b56..102fc13de8 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 6.0dev -%define release 150602 +%define release 150618 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 147307eff7..91be0064dc 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 = "6.0dev PS150602"; +my $version = "6.0dev PS150618"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 2d86b2b458..c6db34aeeb 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -35,7 +35,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "6.0dev PS150602"; +my $version = "6.0dev PS150618"; # save program name for logging my $progname = basename($0); diff --git a/pandora_server/util/recon_scripts/snmp-recon.pl b/pandora_server/util/recon_scripts/snmp-recon.pl index 89e933018f..83bf8d424f 100755 --- a/pandora_server/util/recon_scripts/snmp-recon.pl +++ b/pandora_server/util/recon_scripts/snmp-recon.pl @@ -27,6 +27,9 @@ my $ALLIFACES = ''; # Keep our own ARP cache to connect hosts to switches/routers. my %ARP_CACHE; +# IP address of a host given the MAC of one of its interfaces. +my %IF_CACHE; + # Default configuration values. my $OSNAME = $^O; my %CONF; @@ -36,6 +39,7 @@ if ($OSNAME eq "freebsd") { 'nmap' => '/usr/local/bin/nmap', 'pandora_path' => '/usr/local/etc/pandora/pandora_server.conf', 'icmp_checks' => 1, + 'icmp_packets' => 1, 'networktimeout' => 2, 'snmp_checks' => 2, 'snmp_timeout' => 2, @@ -48,6 +52,7 @@ if ($OSNAME eq "freebsd") { 'nmap' => '/usr/bin/nmap', 'pandora_path' => '/etc/pandora/pandora_server.conf', 'icmp_checks' => 1, + 'icmp_packets' => 1, 'networktimeout' => 2, 'snmp_timeout' => 2, 'recon_timing_template' => 3, @@ -72,10 +77,15 @@ my $DBH; my $GROUP_ID; # Devices by type. -my %HOSTS; +my @HOSTS; my @ROUTERS; my @SWITCHES; +# Switch to switch connections. Used to properly connect hosts +# that are connected to a switch wich is in turn connected to another switch, +# since the hosts will show up in the latter's switch AFT too. +my %SWITCH_TO_SWITCH; + # MAC addresses. my %MAC; @@ -145,7 +155,7 @@ sub mac_to_dec($) { my $mac = shift; my $dec_mac = ''; - my @elements = split(/ /, $mac); + my @elements = split(/:/, $mac); foreach my $element (@elements) { $dec_mac .= unpack('s', pack 's', hex($element)) . '.' } @@ -154,6 +164,42 @@ sub mac_to_dec($) { return $dec_mac; } +######################################################################################## +# Make sure all MAC addresses are in the same format (00 11 22 33 44 55 66). +######################################################################################## +sub parse_mac($) { + my ($mac) = @_; + + # Remove leading and trailing whitespaces. + $mac =~ s/(^\s+)|(\s+$)//g; + + # Replace whitespaces and dots with colons. + $mac =~ s/\s+|\./:/g; + + # Convert hex digits to uppercase. + $mac =~ s/([a-f])/\U$1/g; + + # Add a leading 0 to single digits. + $mac =~ s/^([0-9A-F]):/0$1:/g; + $mac =~ s/:([0-9A-F]):/:0$1:/g; + $mac =~ s/:([0-9A-F])$/:0$1/g; + + return $mac; +} + +######################################################################################## +# Returns 1 if the two given MAC addresses are the same. +######################################################################################## +sub mac_matches($$) { + my ($mac_1, $mac_2) = @_; + + if (parse_mac($mac_1) eq parse_mac($mac_2)) { + return 1; + } + + return 0; +} + ######################################################################################## # Returns 1 if the device belongs to one of the scanned subnets. ######################################################################################## @@ -280,8 +326,9 @@ sub get_if_from_mac($$$) { my @output = snmp_get($device, $community, $IFPHYSADDRESS); foreach my $line (@output) { chomp($line); - next unless $line =~ /^$IFPHYSADDRESS.(\S+)\s+=\s+\S+:\s+$mac$/; - my $if_index = $1; + next unless $line =~ /^$IFPHYSADDRESS.(\S+)\s+=\s+\S+:\s+(.*)$/; + my ($if_index, $if_mac) = ($1, $2); + next unless (mac_matches($mac, $if_mac) == 1); # Get the name of the interface associated to the port. my $if_name = snmp_get_value($device, $community, "$IFNAME.$if_index"); @@ -310,7 +357,7 @@ sub get_if_from_aft($$$) { # Get the interface name. my $if_name = snmp_get_value($switch, $COMMUNITIES{$switch}, "$IFNAME.$if_index"); - return '' unless defined($if_name); + return "if$if_index" unless defined($if_name); $if_name =~ s/"//g; return $if_name; @@ -342,8 +389,7 @@ sub get_if_mac($$$) { return '' unless defined($mac); # Clean-up the MAC address. - $mac =~ s/ /:/g; - chop($mac); + $mac = parse_mac($mac); return $mac; } @@ -415,6 +461,7 @@ sub arp_cache_discovery { foreach my $line (@output) { next unless ($line =~ /^$IPNETTOMEDIAPHYSADDRESS.\d+.(\S+)\s+=\s+\S+:\s+(.*)$/); my ($ip_addr, $mac_addr) = ($1, $2); + $mac_addr = parse_mac($mac_addr); # Save the mac to connect hosts to switches/routers. $ARP_CACHE{$mac_addr} = $ip_addr; @@ -428,7 +475,7 @@ sub arp_cache_discovery { if ($device_type eq 'host' || $device_type eq 'printer') { # Hosts are indexed to help find router/switch to host connectivity. - $HOSTS{$device} = ''; + push(@HOSTS, $device); } elsif ($device_type eq 'switch') { push(@SWITCHES, $device); @@ -457,7 +504,7 @@ sub find_synonyms($$$) { # There is no need to access switches or routers from different IP addresses. if ($device_type eq 'host' || $device_type eq 'printer') { - $HOSTS{$ip_address} = ''; + push(@HOSTS, $device); } } } @@ -534,17 +581,34 @@ sub guess_device_type($$) { ######################################################################################## sub switch_to_switch_connectivity($$) { my ($switch_1, $switch_2) = @_; + my (%mac_temp, @aft_temp); # Make sure both switches respond to SNMP. return unless defined($COMMUNITIES{$switch_1} && $COMMUNITIES{$switch_2}); # Get the list of MAC addresses of each switch. - my %mac_1 = snmp_get_value_hash($switch_1, $COMMUNITIES{$switch_1}, $IFPHYSADDRESS); - my %mac_2 = snmp_get_value_hash($switch_2, $COMMUNITIES{$switch_2}, $IFPHYSADDRESS); + my %mac_1; + %mac_temp = snmp_get_value_hash($switch_1, $COMMUNITIES{$switch_1}, $IFPHYSADDRESS); + foreach my $mac (keys(%mac_temp)) { + $mac_1{parse_mac($mac)} = ''; + } + my %mac_2; + %mac_temp = snmp_get_value_hash($switch_2, $COMMUNITIES{$switch_2}, $IFPHYSADDRESS); + foreach my $mac (keys(%mac_temp)) { + $mac_2{parse_mac($mac)} = ''; + } # Get the address forwarding table (AFT) of each switch. - my @aft_1 = snmp_get_value_array($switch_1, $COMMUNITIES{$switch_1}, $DOT1DTPFDBADDRESS); - my @aft_2 = snmp_get_value_array($switch_2, $COMMUNITIES{$switch_2}, $DOT1DTPFDBADDRESS); + my @aft_1; + @aft_temp = snmp_get_value_array($switch_1, $COMMUNITIES{$switch_1}, $DOT1DTPFDBADDRESS); + foreach my $mac (@aft_temp) { + push(@aft_1, parse_mac($mac)); + } + my @aft_2; + @aft_temp = snmp_get_value_array($switch_2, $COMMUNITIES{$switch_2}, $DOT1DTPFDBADDRESS); + foreach my $mac (@aft_temp) { + push(@aft_2, parse_mac($mac)); + } # Search for matching entries. foreach my $aft_mac_1 (@aft_1) { @@ -552,9 +616,15 @@ sub switch_to_switch_connectivity($$) { foreach my $aft_mac_2 (@aft_2) { if (defined($mac_1{$aft_mac_2})) { my $if_name_1 = get_if_from_aft($switch_1, $COMMUNITIES{$switch_1}, $aft_mac_1); + next unless ($if_name_1) ne ''; my $if_name_2 = get_if_from_aft($switch_2, $COMMUNITIES{$switch_2}, $aft_mac_2); + next unless ($if_name_2) ne ''; message("Switch $switch_1 (if $if_name_1) is connected to switch $switch_2 (if $if_name_2)."); connect_pandora_agents($switch_1, $if_name_1, $switch_2, $if_name_2); + + # Mark switch to switch connections. + $SWITCH_TO_SWITCH{"$switch_1$if_name_1"} = 1; + $SWITCH_TO_SWITCH{"$switch_2$if_name_2"} = 1; return; } } @@ -567,15 +637,24 @@ sub switch_to_switch_connectivity($$) { ######################################################################################## sub router_to_switch_connectivity($$) { my ($router, $switch) = @_; + my (%mac_temp, @aft_temp); # Make sure both routers respond to SNMP. return unless defined($COMMUNITIES{$router} && $COMMUNITIES{$switch}); # Get the list of MAC addresses of the router. - my %mac_router = snmp_get_value_hash($router, $COMMUNITIES{$router}, $IFPHYSADDRESS); + my %mac_router; + %mac_temp = snmp_get_value_hash($router, $COMMUNITIES{$router}, $IFPHYSADDRESS); + foreach my $mac (keys(%mac_temp)) { + $mac_router{parse_mac($mac)} = ''; + } # Get the address forwarding table (AFT) of the switch. - my @aft = snmp_get_value_array($switch, $COMMUNITIES{$switch}, $DOT1DTPFDBADDRESS); + my @aft; + @aft_temp = snmp_get_value_array($switch, $COMMUNITIES{$switch}, $DOT1DTPFDBADDRESS); + foreach my $mac (@aft_temp) { + push(@aft, parse_mac($mac)); + } # Search for matching entries in the AFT. foreach my $aft_mac (@aft) { @@ -586,9 +665,14 @@ sub router_to_switch_connectivity($$) { # Get the switch interface. my $switch_if_name = get_if_from_aft($switch, $COMMUNITIES{$switch}, $aft_mac); + next unless ($switch_if_name ne ''); message("Router $router (if $router_if_name) is connected to switch $switch (if $switch_if_name)."); connect_pandora_agents($router, $router_if_name, $switch, $switch_if_name); + + # Mark connections in case the routers are switches too. + $SWITCH_TO_SWITCH{"$switch$switch_if_name"} = 1; + $SWITCH_TO_SWITCH{"$router$router_if_name"} = 1; return; } } @@ -616,6 +700,10 @@ sub router_to_router_connectivity($$) { my $if_2 = get_if_from_ip($router_2, $COMMUNITIES{$router_2}, $ip_addr_1); message("Router $ip_addr_1 (if $if_2) is connected to router $ip_addr_2 (if $if_2)."); connect_pandora_agents($router_1, $if_1, $router_2, $if_2); + + # Mark connections in case the routers are switches too. + $SWITCH_TO_SWITCH{"$router_1$if_1"} = 1; + $SWITCH_TO_SWITCH{"$router_2$if_2"} = 1; return; } } @@ -635,15 +723,25 @@ sub host_connectivity($) { # Get the address forwarding table (AFT) of the device. my @aft = snmp_get_value_array($device, $COMMUNITIES{$device}, $DOT1DTPFDBADDRESS); foreach my $mac (@aft) { - next unless defined ($ARP_CACHE{$mac}); - my $host = $ARP_CACHE{$mac}; - next unless defined ($HOSTS{$host}); + $mac = parse_mac($mac); + my $host; + if (defined ($ARP_CACHE{$mac})) { + $host = $ARP_CACHE{$mac}; + } elsif (defined ($IF_CACHE{$mac})) { + $host = $IF_CACHE{$mac}; + } else { + next; + } + next unless defined ($VISITED_DEVICES{$host}); my $device_if_name = get_if_from_aft($device, $COMMUNITIES{$device}, $mac); + next unless ($device_if_name ne ''); my $host_if_name = defined($COMMUNITIES{$host}) ? get_if_from_mac($host, $COMMUNITIES{$host}, $mac) : ''; if ($VISITED_DEVICES{$device}->{'type'} eq 'router') { + next if defined ($SWITCH_TO_SWITCH{"$device$device_if_name"}); # The switch is probably connected to another router/switch. message("Host $host " . ($host_if_name ne '' ? "(if $host_if_name)" : '') . " is connected to router $device (if $device_if_name)."); } elsif ($VISITED_DEVICES{$device}->{'type'} eq 'switch') { + next if defined ($SWITCH_TO_SWITCH{"$device$device_if_name"}); # The switch is probably connected to another switch. message("Host $host " . ($host_if_name ne '' ? "(if $host_if_name)" : '') . " is connected to switch $device (if $device_if_name)."); } else { @@ -722,16 +820,19 @@ sub create_pandora_agent($) { next unless $if_status == 1; } - # Get the name of the network interface. - my $if_name = snmp_get_value($device, $COMMUNITIES{$device}, "$IFNAME.$if_index"); - next unless defined($if_name); - $if_name =~ s/"//g; - # Fill the module description with the IP and MAC addresses. my $mac = get_if_mac($device, $COMMUNITIES{$device}, $if_index); my $ip = get_if_ip($device, $COMMUNITIES{$device}, $if_index); my $if_desc = ($mac ne '' ? "MAC $mac " : '') . ($ip ne '' ? "IP $ip" : ''); + # Fill the interface cache. + $IF_CACHE{$mac} = $ip; + + # Get the name of the network interface. + my $if_name = snmp_get_value($device, $COMMUNITIES{$device}, "$IFNAME.$if_index"); + $if_name = "if$if_index" unless defined ($if_name); + $if_name =~ s/"//g; + # Check whether the module already exists. my $module_id = get_agent_module_id($DBH, "ifOperStatus_${if_name}", $agent_id); next if ($module_id > 0); @@ -833,9 +934,8 @@ sub connect_pandora_agents($$$$) { db_do($DBH, 'INSERT INTO tmodule_relationship (`module_a`, `module_b`, `id_rt`) VALUES(?, ?, ?)', $module_id_1, $module_id_2, $TASK_ID); } - # Unset parents (otherwise the map will look broken). - db_do($DBH, 'UPDATE tagente SET id_parent=0 WHERE id_agente=?', $agent_1->{'id_agente'}); - db_do($DBH, 'UPDATE tagente SET id_parent=0 WHERE id_agente=?', $agent_2->{'id_agente'}); + # Update parents. + db_do($DBH, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $agent_1->{'id_agente'}, $agent_2->{'id_agente'}); } @@ -990,6 +1090,10 @@ else { my @scanned_hosts = $np->all_hosts(); foreach my $host (@scanned_hosts) { next unless defined($host->addr()) and defined($host->status()) and ($host->status() eq 'up'); + + # Make sure the host is up (nmap gives false positives!). + next if (pandora_ping(\%CONF, $host->addr(), 1, 1) == 0); + arp_cache_discovery($host->addr()); } } @@ -1028,10 +1132,10 @@ update_recon_task($DBH, $TASK_ID, 75); # Find switch/router to host connections. message("[6/6] Finding switch/router to end host connectivity..."); -foreach my $device ((@ROUTERS, @SWITCHES)) { +foreach my $device (@ROUTERS, @SWITCHES, @HOSTS) { host_connectivity($device); } -foreach my $host (keys(%HOSTS)) { +foreach my $host (@HOSTS) { next unless (ref($VISITED_DEVICES{$host}) eq 'HASH'); # Skip aliases. next if ($VISITED_DEVICES{$host}->{'connected'} == 1); # Skip already connected hosts. traceroute_connectivity($host);
" . __('Draw live filter') . "