diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 17af72510d..520eaff838 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, AIX version +# Version 7.0NG.727, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 5ddcfbf6d9..c81ad7428b 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, FreeBSD Version +# Version 7.0NG.727, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index a1c9b17c55..50fc5ba4be 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, HP-UX Version +# Version 7.0NG.727, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index d62e268b24..82830cf957 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 1450b7dc3b..ea633488e4 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 909148bd3d..c8a2153376 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, Solaris Version +# Version 7.0NG.727, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 5e3194a8cc..6a01d22b4b 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.724 +# Version 7.0NG.727 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 3b9fe9a7a7..27cbee7dfb 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.724, AIX version +# Version 7.0NG.727, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 79d8968952..6eaf0415c2 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.724 +# Version 7.0NG.727 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index e3dfd27731..906269e8bb 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.724, HPUX Version +# Version 7.0NG.727, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 8acf764a5b..b2cdc0e920 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724 +# Version 7.0NG.727 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index a2019f25da..82363fdb43 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724 +# Version 7.0NG.727 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 7bd610392f..2b4f58566b 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724 +# Version 7.0NG.727 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 010e99f76b..a1c4130f17 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.724, Solaris version +# Version 7.0NG.727, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index babed637b9..0d640badaa 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, AIX version +# Version 7.0NG.727, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -87,6 +87,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) # remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 56053d64da..5b682cd793 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.724-180718 +Version: 7.0NG.727-181001 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 7e51d04d93..0651f8af81 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.724-180718" +pandora_version="7.0NG.727-181001" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 3b3ca87c5b..53dd20cf4f 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -117,6 +117,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) #remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 3b103eab67..3590ee6551 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, FreeBSD Version +# Version 7.0NG.727, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -130,6 +130,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) remote_config 0 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode #proxy_mode 1 diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index e8473cc321..aa1dcb1592 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, HP-UX Version +# Version 7.0NG.727, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -89,6 +89,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) # remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index a3dd4cccac..fc55d1d872 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -136,6 +136,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) remote_config 0 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode # proxy_mode 1 diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 19b8c551e1..7a47602abc 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -41,9 +41,9 @@ udp_server_auth_address 0.0.0.0 # Group assigned for this agent (descriptive, p.e: Servers) #group Servers - -# Group password (if defined). -#group_password + +# Group password (if defined). +#group_password # Autotime: Enforce to server to ignore timestamp coming from this # agent, used when agents has no timer or it's inestable. 1 to enable @@ -102,6 +102,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) remote_config 0 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # Number of threads to execute modules in parallel #agent_threads 1 diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index cf1aaf60b7..42d8c19a25 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, NetBSD Version +# Version 7.0NG.727, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -98,6 +98,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) #remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode #proxy_mode 1 diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index dcd12cda47..625bc89848 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.724, Solaris Version +# Version 7.0NG.727, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -92,6 +92,9 @@ transfer_mode tentacle # If set to 1 allows the agent to be configured via the web console (Only Enterprise version) #remote_config 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # If set to 1 start Drone Agent's Proxy Mode #proxy_mode 1 diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 86e75acc44..8f86156cb3 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,8 +41,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.724'; -use constant AGENT_BUILD => '180718'; +use constant AGENT_VERSION => '7.0NG.727'; +use constant AGENT_BUILD => '181001'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -186,6 +186,7 @@ my %DefaultConf = ( 'xml_buffer' => 0, 'custom_id' => '', 'url_address' => '', + 'standby' => 0, ); my %Conf = %DefaultConf; @@ -1333,6 +1334,41 @@ sub check_collections () { } } +################################################################################ +# Sleep function +################################################################################ +sub sleep_agent { + my ($main_agent, $iter_base_time) = @_; + + # Sleep if main agent + if ($main_agent != 0) { + foreach my $broker_pid (@BrokerPid) { + waitpid ($broker_pid, 0); + } + + # Cron mode + exit (0) if ($Conf{'cron_mode'} == 1); + + $iter_base_time += $Conf{'intensive_interval'}; + my $now = time(); + + my $interval_remain = $iter_base_time - $now; + + if ($interval_remain >= 0) { + sleep ($interval_remain); + } else { + # don't sleep if iteraion took more than "intensive_interval" seconds + $iter_base_time = $now; # use current time as base time + } + } + # Finish if broker agent + else { + exit (0); + } + + return $iter_base_time; +} + ############################################################################### # Return the MD5 checksum of the given string as a hex string. # Pseudocode from: http://en.wikipedia.org/wiki/MD5#Pseudocode @@ -2959,6 +2995,12 @@ while (1) { } } + # Do not report to server if standby mode is enabled + if ($Conf{'standby'} eq '1' && $Conf{'debug'} ne '1') { + $iter_base_time = sleep_agent($main_agent, $iter_base_time); + next; + } + my $address; if(defined($Conf{'address'})) { @@ -3161,31 +3203,8 @@ while (1) { $SIG{'INT'} = \&udp_server_signal; } - # Sleep if main agent - if ($main_agent != 0) { - foreach my $broker_pid (@BrokerPid) { - waitpid ($broker_pid, 0); - } - - # Cron mode - last if ($Conf{'cron_mode'} == 1); - - $iter_base_time += $Conf{'intensive_interval'}; - my $now = time(); - - my $interval_remain = $iter_base_time - $now; - - if ($interval_remain >= 0) { - sleep ($interval_remain); - } else { - # don't sleep if iteraion took more than "intensive_interval" seconds - $iter_base_time = $now; # use current time as base time - } - } - # Finish if broker agent - else { - exit (0); - } + # Sleep agent function + $iter_base_time = sleep_agent($main_agent, $iter_base_time); } __END__ diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index ab7b41ed14..5c1495e65b 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.724 -%define release 180718 +%define version 7.0NG.727 +%define release 181001 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel Requires: fileutils textutils unzip Requires: util-linux procps grep Requires: /sbin/ip /bin/awk -Requires: perl perl(Sys::Syslog) +Requires: perl perl(Sys::Syslog) perl(IO::Compress::Zip) # Required by plugins #Requires: sh-utils sed passwd net-tools rpm AutoReq: 0 diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 563258c9c5..2866f56ab5 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.724 -%define release 180718 +%define version 7.0NG.727 +%define release 181001 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index e55d4edd26..155129ebb1 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,8 +9,8 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.724" -PI_BUILD="180718" +PI_VERSION="7.0NG.727" +PI_BUILD="181001" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/grep_log b/pandora_agents/unix/plugins/grep_log index ad45ab2943..2e17210a51 100755 --- a/pandora_agents/unix/plugins/grep_log +++ b/pandora_agents/unix/plugins/grep_log @@ -325,7 +325,9 @@ sub print_log ($) { $output .= "\n"; $output .= "{$line}; + my $processed_line = $line; + $processed_line =~ s/\]\]/]]]]>"; $output .= "\n"; @@ -343,7 +345,9 @@ sub print_log ($) { foreach my $line (@kdata) { $output .= "{$line}}) { - $output .= $content; + my $processed_line = $content; + $processed_line =~ s/\]\]/]]]]>\n"; } diff --git a/pandora_agents/unix/plugins/grep_snmptrapd b/pandora_agents/unix/plugins/grep_snmptrapd new file mode 100755 index 0000000000..8909f8f328 --- /dev/null +++ b/pandora_agents/unix/plugins/grep_snmptrapd @@ -0,0 +1,250 @@ +#!/usr/bin/perl +############################################################################### +# +# Copyright (c) 2018 Artica Soluciones Tecnologicas S.L. +# +# grep_log Perl script to search log files for a matching pattern. The last +# searched position is saved in an index file so that consecutive +# runs do not return the same results. The log file inode number is +# also saved to detect log rotation. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +############################################################################### +use strict; +use File::Basename; +use IO::Compress::Zip qw(zip $ZipError); +use MIME::Base64; + +# Be verbose +my $Verbose = 0; + +# Index file storage directory, with a trailing '/' +my $Idx_dir=($^O =~ /win/i)?'.\\':'/tmp/'; + +# Log file +my $Log_file = ''; + +# Index file +my $Idx_file = ''; + +# Log file position index +my $Idx_pos = 0; + +# Log file inode number +my $Idx_ino = ''; + +# Log file size +my $Idx_size = 0; + +############################################################################### +# SUB error_msg +# Print an error message and exit. +############################################################################### +sub error_msg ($) { + my $err_msg = $_[0]; + + if (! -z $err_msg) { + print(STDERR "[error] $err_msg.\n"); + } + + exit 1; +} + +############################################################################### +# SUB print_help +# Print a help message. +############################################################################### +sub print_help () { + print "Usage: $0 \n"; +} + +############################################################################### +# SUB log_msg +# Print a log message. +############################################################################### +sub log_msg ($) { + my $log_msg = $_[0]; + + if (! -z $log_msg && $Verbose == 1) { + print(STDOUT "[log] $log_msg.\n"); + } +} + +############################################################################### +# SUB load_idx +# Load index file. +############################################################################### +sub load_idx () { + my $line; + my $current_ino; + my $current_size; + + log_msg("Loading index file $Idx_file"); + + open(IDXFILE, $Idx_file) || error_msg("Error opening file $Idx_file: " . + $!); + + # Read position and date + $line = ; + ($Idx_pos, $Idx_ino, $Idx_size) = split(' ', $line); + + close(IDXFILE); + + # Reset the file index if the file has changed + $current_ino = (stat($Log_file))[1]; + $current_size = -s "$Log_file"; + if ($current_ino != $Idx_ino || $current_size < $Idx_size) { + log_msg("File changed, resetting index"); + + $Idx_pos = 0; + $Idx_ino = $current_ino; + } + $Idx_size = $current_size; + + return; +} + +############################################################################### +# SUB save_idx +# Save index file. +############################################################################### +sub save_idx () { + + log_msg("Saving index file $Idx_file"); + + open(IDXFILE, "> $Idx_file") || error_msg("Error opening file $Idx_file: " + . $!); + print (IDXFILE $Idx_pos . " " . $Idx_ino . " " . $Idx_size); + close(IDXFILE); + + return; +} + +############################################################################### +# SUB create_idx +# Create index file. +############################################################################### +sub create_idx () { + my $first_line; + + log_msg("Creating index file $Idx_file"); + + open(LOGFILE, $Log_file) || error_msg("Error opening file $Log_file: " . + $!); + + # Go to EOF and save the position + seek(LOGFILE, 0, 2); + $Idx_pos = tell(LOGFILE); + + close(LOGFILE); + + # Save the file inode number + $Idx_ino = (stat($Log_file))[1]; + + # Save the index file + save_idx(); + + return; +} + +############################################################################### +# SUB parse_log +# Parse log file starting from position $Idx_pos. +############################################################################### +sub parse_log () { + my $line; + + log_msg("Parsing log file $Log_file"); + + # Open log file for reading + open(LOGFILE, $Log_file) || error_msg("Error opening file $Log_file: " . + $!); + + # Go to starting position. + seek(LOGFILE, $Idx_pos, 0); + + # Parse log file + my $data; + + # Matched line id + my $matched_line = 0; + + $/ = undef; + $data = ; + + $Idx_pos = tell(LOGFILE); + close(LOGFILE); + + # Save the index file + save_idx(); + + return \$data; +} + +############################################################################### +# SUB parse_log +# Print log data to STDOUT. +############################################################################### +sub print_log ($) { + my $data = shift; + my $zdata; + + return unless defined($data) and $$data ne ''; + + if (!zip($data => \$zdata)) { + error_msg("Compression error: $ZipError"); + return; + } + + print STDOUT "\n"; +} + +############################################################################### +############################################################################### +## Main +############################################################################### +############################################################################### + +# Check command line parameters +if ($#ARGV < 0) { + print_help(); + exit 1; +} + +$Log_file = $ARGV[0]; +# Create index file storage directory +if ( ! -d $Idx_dir) { + mkdir($Idx_dir) || error_msg("Error creating directory $Idx_dir: " + . $!); +} + +# Check that log file exists +if (! -e $Log_file) { + error_msg("File $Log_file does not exist"); +} + +# Create index file if it does not exist +$Idx_file=$Idx_dir . basename($Log_file) . ".idx"; +if (! -e $Idx_file) { + create_idx(); + exit 0; +} + +# Load index file +load_idx(); + +# Parse log file +my $data = parse_log(); + +# Print output to STDOUT +print_log ($data); + +exit 0; diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index fc179e93d7..0901ac5234 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.724 +# Version 7.0NG.727 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -82,6 +82,9 @@ server_port 41121 # Debug mode renames XML in the temp folder and continues running # debug 1 +# Default 0, set to 1 to avoid module executions and report to server +# standby 1 + # XML encoding (ISO-8859-1 by default). Most windows servers experience problems when you set to UTF-8. Other special codepages may be specified here. #encoding ISO-8859-1 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 4a75133eab..68f7962de6 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.724} +{Pandora FMS Windows Agent v7.0NG.727} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180718} +{181001} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_data.cc b/pandora_agents/win32/modules/pandora_data.cc index 6b9390f3f7..be891414ba 100644 --- a/pandora_agents/win32/modules/pandora_data.cc +++ b/pandora_agents/win32/modules/pandora_data.cc @@ -32,7 +32,7 @@ using namespace Pandora; */ Pandora_Data::Pandora_Data (string value) { this->value = value; - GetSystemTime (&(this->timestamp)); + GetLocalTime (&(this->timestamp)); this->data_origin = pandora_data_unknown_source; } @@ -68,7 +68,7 @@ Pandora_Data::Pandora_Data (string value, SYSTEMTIME *system_time) { */ Pandora_Data::Pandora_Data (string value, string data_origin) { this->value = value; - GetSystemTime (&(this->timestamp)); + GetLocalTime (&(this->timestamp)); this->data_origin = data_origin; } @@ -99,7 +99,7 @@ Pandora_Data::Pandora_Data (string value, SYSTEMTIME *system_time, string data_o */ Pandora_Data::Pandora_Data () { this->value = ""; - GetSystemTime (&(this->timestamp)); + GetLocalTime (&(this->timestamp)); this->data_origin = ""; } diff --git a/pandora_agents/win32/modules/pandora_module_logchannel.cc b/pandora_agents/win32/modules/pandora_module_logchannel.cc index 2c7c056565..4ec72df63c 100755 --- a/pandora_agents/win32/modules/pandora_module_logchannel.cc +++ b/pandora_agents/win32/modules/pandora_module_logchannel.cc @@ -67,16 +67,16 @@ Pandora_Module_Logchannel::Pandora_Module_Logchannel (string name, string source // Set the type filter int type_number = -1; - if (upper_type.compare("ERROR") == 0) { - type_number = EVENTLOG_ERROR_TYPE; + if (upper_type.compare("CRITICAL") == 0) { + type_number = WINEVENT_LEVEL_CRITICAL; + } else if (upper_type.compare("ERROR") == 0) { + type_number = WINEVENT_LEVEL_ERROR; } else if (upper_type.compare("WARNING") == 0) { - type_number = EVENTLOG_WARNING_TYPE; - } else if (upper_type.compare("INFORMATION") == 0) { - type_number = EVENTLOG_INFORMATION_TYPE; - } else if (upper_type.compare("AUDIT SUCCESS") == 0) { - type_number = EVENTLOG_AUDIT_SUCCESS; - } else if (upper_type.compare("AUDIT FAILURE") == 0) { - type_number = EVENTLOG_AUDIT_FAILURE; + type_number = WINEVENT_LEVEL_WARNING; + } else if (upper_type.compare("INFO") == 0) { + type_number = WINEVENT_LEVEL_INFO; + } else if (upper_type.compare("VERBOSE") == 0) { + type_number = WINEVENT_LEVEL_VERBOSE; } // Append type to log query if (type_number != -1) { diff --git a/pandora_agents/win32/modules/pandora_module_logchannel.h b/pandora_agents/win32/modules/pandora_module_logchannel.h index 14617037c6..19cde78b93 100755 --- a/pandora_agents/win32/modules/pandora_module_logchannel.h +++ b/pandora_agents/win32/modules/pandora_module_logchannel.h @@ -29,6 +29,13 @@ // Log event read buffer size #define BUFFER_SIZE 1024 +// WINEVENT consts +#define WINEVENT_LEVEL_CRITICAL 1 +#define WINEVENT_LEVEL_ERROR 2 +#define WINEVENT_LEVEL_WARNING 3 +#define WINEVENT_LEVEL_INFO 4 +#define WINEVENT_LEVEL_VERBOSE 5 + // Types for pointers to Wevtapi.dll functions typedef EVT_HANDLE WINAPI (*EvtQueryT) (EVT_HANDLE Session, LPCWSTR Path, LPCWSTR Query, DWORD Flags); typedef WINBOOL WINAPI (*EvtNextT) (EVT_HANDLE ResultSet, DWORD EventArraySize, EVT_HANDLE* EventArray, DWORD Timeout, DWORD Flags, PDWORD Returned); diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index bdd5902406..f327f6eed2 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.724(Build 180718)") +#define PANDORA_VERSION ("7.0NG.727(Build 181001)") 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 e843cdbc05..275ee60724 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -1869,7 +1869,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { server_addr = conf->getValue ("server_ip"); - if (this->broker_modules != NULL) { + if (this->broker_modules != NULL && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { this->broker_modules->goFirst (); while (! this->broker_modules->isLast ()) { @@ -1937,7 +1937,7 @@ Pandora_Windows_Service::pandora_run_broker (string config) { } } - if (data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) { + if ((data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { // Send the XML if (!server_addr.empty ()) { @@ -1997,7 +1997,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { execution_number++; - if (this->modules != NULL) { + if (this->modules != NULL && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { this->modules->goFirst (); while (! this->modules->isLast ()) { @@ -2057,7 +2057,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) { } } - if (forced_run == 1 || data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) { + if ((forced_run == 1 || data_flag == 1 || this->timestamp + this->interval_sec <= this->run_time) && !(conf->getValue ("standby") == "1" && !getPandoraDebug())) { // Send the XML if (!server_addr.empty ()) { diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5b57428e8b..a58170949b 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.724(Build 180718))" + VALUE "ProductVersion", "(7.0NG.727(Build 181001))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fecf948b81..3538caa4bf 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.724-180718 +Version: 7.0NG.727-181001 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 85427d48d4..41b517b407 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.724-180718" +pandora_version="7.0NG.727-181001" package_pear=0 package_pandora=1 diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index b8b7481786..6947bfcc3a 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -77,15 +77,6 @@ $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) $config["relative_path"] = enterprise_hook('skins_set_image_skin_path',array($config['id_user'])); -// Load user language -$user_language = get_user_language ($config['id_user']); - -$l10n = NULL; -if (file_exists ('./include/languages/'.$user_language.'.mo')) { - $l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$user_language.'.mo')); - $l10n->load_tables(); -} - if (isset($config['metaconsole'])) { // Not cool way of know if we are executing from metaconsole or normal console if ($config['metaconsole']) diff --git a/pandora_console/attachment/.htaccess b/pandora_console/attachment/.htaccess new file mode 100644 index 0000000000..d6a661a7f8 --- /dev/null +++ b/pandora_console/attachment/.htaccess @@ -0,0 +1,3 @@ +Order deny,allow +Deny from All +Allow from localhost \ No newline at end of file diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 69838c9fb5..c617d6425e 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -17,103 +17,21 @@ global $config; -if (is_ajax ()) { - check_login (); - - require_once('include/functions_agents.php'); - - $get_info_alert_module_group = (bool)get_parameter('get_info_alert_module_group'); - $module_group = (int)get_parameter('module_group'); - $id_agent_group = (int)get_parameter('id_agent_group'); - - $data = false; - 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)); - 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']) { - if ($alert["times_fired"] > 0) { - $data = true; - echo '' . __('Number fired of alerts').': ' . $alert["times_fired"] . '
'; - $agent = db_get_row('tagente', 'id_agente', $module['id_agente']); - echo '' . __('Agent').': '; - echo io_safe_output($agent['nombre']) . '
'; - echo '' . __('Module') . ': '; - echo io_safe_output($module['nombre']) . '
'; - $template = db_get_row('talert_templates', 'id' , $alert['id_alert_template']); - echo '' . __('Alert template') . ': '; - echo io_safe_output($template['name']) . '
'; - - // This prevent from templates without predefined actions - if (empty($template['id_alert_action'])) - $template_id_alert_action = "''"; - else - $template_id_alert_action = $template['id_alert_action']; - - // True if the alert only has the default template action - $default_action = false; - // Try to get actions for the current alert - $sql = 'SELECT t2.name - FROM talert_template_module_actions t1 - INNER JOIN talert_actions t2 - INNER JOIN talert_template_modules t3 - ON t3.id = t1.id_alert_template_module - AND t1.id_alert_action = t2.id - WHERE (t3.id_alert_template = ' . $template['id'] . ' AND - t3.id_agent_module = ' . $module['id_agente_modulo'] . ');'; - - $actions = db_get_all_rows_sql($sql); - - // If this alert doesn't have actions try to get default action from template - if ($actions === false) { - $sql = 'SELECT name - FROM talert_actions - WHERE (id = ' . $template_id_alert_action . ');'; - - $default_action = true; - - $actions = db_get_all_rows_sql($sql); - } - - if ($actions === false) { - $actions = array(); - } - - echo '' . __('Actions') . ': ' . '
'; - echo '
    '; - foreach ($actions as $action) { - echo '
  • '; - if ($default_action) - echo 'Default: '; - echo $action['name'] . '
  • '; - } - echo '
'; - if ($alert != end($alerts)) { - echo '
'; - } - } - } - } - if (!$data) { - echo 'These module/s have no alerts or alert/s are not fired'; - } - } - else { - echo 'No available data'; - } - } - else { - echo 'No available data'; - } -} +check_login (); -/** - * Translate the array texts using gettext - */ -function translate(&$item, $key) { - $item = __($item); +if (is_ajax ()) { + $get_info_alert_module_group = (bool)get_parameter('get_info_alert_module_group'); + + if ($get_info_alert_module_group) { + $send_tooltip = json_decode(io_safe_output(get_parameter('send_tooltip')), true); + echo "

    " . __('Counters Module') . "

    "; + echo "
  • " . __('Alerts_Fired') . ": " . $send_tooltip['alerts_module_count'] . "
  • "; + echo "
  • " . __('Critical') . ": " . $send_tooltip['critical_module_count'] . "
  • "; + echo "
  • " . __('warning') . ": " . $send_tooltip['warning_module_count'] . "
  • "; + echo "
  • " . __('Unknown') . ": " . $send_tooltip['unknown_module_count'] . "
  • "; + echo "
  • " . __('OK') . ": " . $send_tooltip['normal_module_count'] . "
  • "; + echo "
  • " . __('Not_init') . ": " . $send_tooltip['notInit_module_count'] . "
"; + } } /** @@ -121,192 +39,229 @@ function translate(&$item, $key) { * execute the code. */ function mainModuleGroups() { - global $config; //the useful global var of Pandora Console, it has many data can you use - - require_once ('include/functions_reporting.php'); - require_once($config['homedir'] . "/include/functions_agents.php"); - require_once($config['homedir'] . "/include/functions_users.php"); - - //The big query - switch ($config["dbtype"]) { - case "mysql": - $sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado - FROM tagente_estado - WHERE id_agente IN - (SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE) - AND id_agente_modulo IN - (SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE) - GROUP BY estado"; - break; - case "postgresql": - $sql = "SELECT COUNT(id_agente) AS count, - case utimestamp when 0 then 5 else estado end as estado - FROM tagente_estado - WHERE id_agente IN - (SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0) - AND id_agente_modulo IN - (SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_module_group = %d AND disabled = 0 AND delete_pending = 0) - GROUP BY estado, utimestamp"; - break; - case "oracle": - $sql = "SELECT COUNT(id_agente) AS count, (case when utimestamp = 0 then 5 else estado end) AS estado - FROM tagente_estado - WHERE id_agente IN - (SELECT id_agente FROM tagente WHERE id_grupo = %d AND (disabled IS NOT NULL AND disabled <> 0)) - AND id_agente_modulo IN - (SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_module_group = %d AND (disabled IS NOT NULL AND disabled <> 0) AND (delete_pending IS NOT NULL AND delete_pending <> 0)) - GROUP BY (case when utimestamp = 0 then 5 else estado end)"; - break; - } - - ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, ''); - - ui_print_info_message ( array('no_close'=>true, 'message'=> - __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") ) - ); - - - $agentGroups = users_get_groups ($config['id_user'], "AR", false); - $modelGroups = users_get_all_model_groups(); - - if (!empty($agentGroups) && !empty($modelGroups)) { - array_walk($modelGroups, 'translate'); //Translate all head titles to language is set - - $table = null; - $table->headstyle[] = "width: 20%"; - foreach ($modelGroups as $i => $n) { - $table->headstyle[] = "min-width: 60px;max-width: 5%;text-align:center;"; - $modelGroups[$i] = ui_print_truncate_text($n, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); - } - - $head = $modelGroups; - array_unshift($head, ' '); - - //Metaobject use in html_print_table - $table->align[0] = 'left'; //Align to left the first column. - $table->style[0] = 'color: #ffffff; '. - 'background-color: #373737; font-weight: bolder; padding-right: 10px; width:20%; '; - $table->head = $head; - $table->width = '100%'; - - //The content of table - $tableData = array(); - - //Create rows and cells - foreach ($agentGroups as $idAgentGroup => $name) { - $fired = false; - $row = array(); - - array_push($row, ui_print_truncate_text($name, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF')); - - foreach ($modelGroups as $idModelGroup => $modelGroup) { - $fired = false; - $query = sprintf($sql, $idAgentGroup, $idModelGroup); - - $rowsDB = db_get_all_rows_sql ($query); - - $agents = agents_get_group_agents($idAgentGroup); - - if (!empty($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 ($idModelGroup == $module['id_module_group']) { - if ($alert["times_fired"] > 0) { - $fired = true; - } - } - } - } - - $states = array(); - if ($rowsDB !== false) { - foreach ($rowsDB as $rowDB) { - $states[$rowDB['estado']] = $rowDB['count']; - } - } - - $count = 0; - foreach ($states as $idState => $state) { - $count += $state; - } - - $color = 'transparent'; //Defaut color for cell - $font_color = '#000000'; //Default font color for cell - if ($count == 0) { - $color = '#eeeeee'; //Soft grey when the cell for this model group and agent group hasn't modules. - $alinkStart = ''; - $alinkEnd = ''; - } - else { - - if ($fired) { - $color = '#FFA631'; //Orange when the cell for this model group and agent has at least one alert fired. - } - else if (array_key_exists(1, $states)) { - $color = '#FC4444'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. - $font_color = '#ffffff'; - } - elseif (array_key_exists(2, $states)) { - $color = '#FAD403'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. - } - elseif (array_key_exists(3, $states)) { - $color = '#B2B2B2 '; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. - } - elseif (array_key_exists(0, $states)) { - $color = '#80BA27'; //Green when the cell for this model group and agent has OK state all modules. - } - elseif (array_key_exists(5, $states)) { - $color = '#5BB6E5'; // Blue when the cell for this module group and all modules have not init value. - } - - - $alinkStart = ''; - $alinkEnd = ''; - } - - array_push($row, - '
- ' . $alinkStart . $count . $alinkEnd . '
'); - } - array_push($tableData,$row); - } - $table->data = $tableData; - echo "
"; - html_print_table($table); - echo "
"; - - echo "
"; + global $config; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
" . __('Legend') . "
" . __("Orange cell when the module group and agent have at least one alarm fired.") . "
" . __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . "
" . __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . "
" . __("Green cell when the module group and agent have all modules in OK status") . "
" . __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . "
" .__("Blue cell when the module group and agent have all modules in not init status.") . "
"; + require_once($config['homedir'] . "/include/class/TreeGroup.class.php"); + require_once($config['homedir'] . "/include/functions_groupview.php"); + + $tree_group = new TreeGroup("group", "group"); + $tree_group->setPropagateCounters(false); + $tree_group->setDisplayAllGroups(true); + $tree_group->setFilter( array( + 'searchAgent' => '', + 'statusAgent' => AGENT_STATUS_ALL, + 'searchModule' => '', + 'statusModule' => -1, + 'groupID' => 0, + 'tagID' => 0, + 'show_not_init_agents' => 1, + 'show_not_init_modules' => 1 + )); + $info = $tree_group->getArray(); + $info = groupview_plain_groups($info); + $counter = count($info); + $offset = get_parameter('offset', 0); + $groups_view = $is_not_paginated + ? $info + : array_slice($info, $offset, $config['block_size']); + $agents_counters = array_reduce($groups_view, function($carry, $item){ + $carry[$item['id']] = $item; + return $carry; + }, array()); + + $ids_array = array_keys($agents_counters); + + $ids_group = implode(',', $ids_array); + + $condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT); + $condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT); + $condition_unknown = modules_get_state_condition(AGENT_MODULE_STATUS_UNKNOWN); + $condition_not_init = modules_get_state_condition(AGENT_MODULE_STATUS_NO_DATA); + $condition_normal = modules_get_state_condition(AGENT_MODULE_STATUS_NORMAL); + + $array_for_defect = array(); + $array_module_group = array(); + $array_data = array(); + + $sql = "SELECT id_mg, `name` FROM tmodule_group"; + $array_mod= db_get_all_rows_sql($sql); + + foreach ($array_mod as $key => $value) { + $array_module_group[$value['id_mg']] = $value['name']; + } + $array_module_group[0] = 'Nothing'; + foreach ($agents_counters as $key => $value) { + $array_for_defect[$key]['gm'] = $array_module_group; + $array_for_defect[$key]['data']['name'] = $value['name']; + $array_for_defect[$key]['data']['parent'] = $value['parent']; + $array_for_defect[$key]['data']['icon'] = $value['icon']; + } + +$sql = + "SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count, + SUM(IF($condition_warning, 1, 0)) AS warning_module_count, + SUM(IF($condition_unknown, 1, 0)) AS unknown_module_count, + SUM(IF($condition_not_init, 1, 0)) AS notInit_module_count, + SUM(IF($condition_critical, 1, 0)) AS critical_module_count, + SUM(IF($condition_normal, 1, 0)) AS normal_module_count, + COUNT(tae.id_agente_modulo) AS total_count, + tmg.id_mg, + tmg.name as n, + tg.id_grupo + FROM ( + SELECT tam.id_agente_modulo, + tam.id_module_group, + ta.id_grupo AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND ta.id_grupo IN ($ids_group) + GROUP BY tam.id_agente_modulo + UNION ALL + SELECT tam.id_agente_modulo, + tam.id_module_group, + tasg.id_group AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + INNER JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND tasg.id_group IN ($ids_group) + GROUP BY tam.id_agente_modulo, tasg.id_group + ) AS tae + RIGHT JOIN tgrupo tg + ON tg.id_grupo = tae.g + INNER JOIN ( + SELECT * FROM tmodule_group + UNION ALL + SELECT 0 AS 'id_mg', 'Nothing' AS 'name' + ) AS tmg + ON tae.id_module_group = tmg.id_mg + GROUP BY tae.g, tmg.id_mg"; + + $array_data_prev = db_get_all_rows_sql($sql); + + foreach ($array_data_prev as $key => $value) { + $array_data[$value['id_grupo']][$value['id_mg']] = $value; + } + + ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, ''); + + if(count($array_for_defect) > 0){ + $table = new StdClass(); + $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; + $table->width = '100%'; + + $head[0] = __('Groups'); + $headstyle[0] = "width: 20%; font-weight: bolder;"; + foreach ($array_module_group as $key => $value) { + $headstyle[] = "min-width: 60px;max-width: 5%;text-align:center; color: #ffffff; background-color: #373737; font-weight: bolder;"; + $head[] = ui_print_truncate_text($value, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + } + + $i = 0; + foreach ($array_for_defect as $key => $value) { + $deep = groups_get_group_deep($key); + $data[$i][0] = $deep . ui_print_truncate_text($value['data']['name'], GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + $j = 1; + if(isset($array_data[$key])){ + foreach ($value['gm'] as $k => $v) { + if(isset($array_data[$key][$k])){ + $send_tooltip = json_encode($array_data[$key][$k]); + $rel = "ajax.php?page=extensions/module_groups&get_info_alert_module_group=1&send_tooltip=" . $send_tooltip; + $url = "index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=" . $key . "&modulegroup=" . $k; + + if ($array_data[$key][$k]['alerts_module_count'] != 0) { + $color = '#FFA631'; //Orange when the cell for this model group and agent has at least one alert fired. + } + else if ($array_data[$key][$k]['critical_module_count'] != 0) { + $color = '#FC4444'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. + } + elseif ($array_data[$key][$k]['warning_module_count'] != 0) { + $color = '#FAD403'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. + } + elseif ($array_data[$key][$k]['unknown_module_count'] != 0) { + $color = '#B2B2B2 '; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. + } + elseif ($array_data[$key][$k]['normal_module_count'] != 0) { + $color = '#80BA27'; //Green when the cell for this model group and agent has OK state all modules. + } + elseif ($array_data[$key][$k]['notInit_module_count'] != 0) { + $color = '#5BB6E5'; // Blue when the cell for this module group and all modules have not init value. + } + + $data[$i][$j] ="
"; + $data[$i][$j] .= ""; + $data[$i][$j] .= $array_data[$key][$k]['total_count']; + $data[$i][$j] .= "
"; + } + else{ + $data[$i][$j] ="
"; + $data[$i][$j] .= 0; + $data[$i][$j] .= "
"; + } + $j++; + } + } + else{ + foreach ($value['gm'] as $k => $v) { + $data[$i][$j] ="
"; + $data[$i][$j] .= 0; + $data[$i][$j] .= "
"; + $j++; + } + } + $i++; + } + + $table->head = $head; + $table->headstyle = $headstyle; + $table->data = $data; + + ui_pagination($counter); + + echo "
"; + html_print_table($table); echo "
"; + + ui_pagination($counter); + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
" . __('Legend') . "
" . __("Orange cell when the module group and agent have at least one alarm fired.") . "
" . __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . "
" . __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . "
" . __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . "
" . __("Green cell when the module group and agent have all modules in OK status") . "
" .__("Blue cell when the module group and agent have all modules in not init status.") . "
"; + echo "
"; + } else { - echo "
".__('There are no defined groups or module groups')."
"; + ui_print_info_message ( array('no_close'=>true, 'message'=> __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") )); + ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups or module groups') )); } - + ui_require_css_file('cluetip'); ui_require_jquery_file('cluetip'); ?> @@ -315,7 +270,8 @@ function mainModuleGroups() { $("a.info_cell").cluetip ({ arrows: true, attribute: 'rel', - cluetipClass: 'default' + cluetipClass: 'default', + width: '200px' }); }); diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index 1a8e17965d..5f6bca2c93 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -125,7 +125,7 @@ function pandora_realtime_graphs () { if ($graph != 'snmp_module') { $data['incremental'] = __('Incremental') . '  ' . html_print_checkbox ('incremental', 1, 0, true); } - $data['reset'] = html_print_button(__('Clear graph'), 'reset', false, 'clearGraph()', 'class="sub delete" style="margin-top:0px;"', true); + $data['reset'] = html_print_button(__('Clear graph'), 'reset', false, 'javascript:realtimeGraphs.clearGraph();', 'class="sub delete" style="margin-top:0px;"', true); $table->data[] = $data; if ($graph == 'snmp_interface' || $graph == 'snmp_module') { @@ -154,7 +154,7 @@ function pandora_realtime_graphs () { $table->colspan[2]['snmp_oid'] = 2; $data['snmp_ver'] = __('Version') . '  ' . html_print_select ($snmp_versions, 'snmp_version', $snmp_ver, '', '', 0, true); - $data['snmp_ver'] .= '  ' . html_print_button (__('SNMP walk'), 'snmp_walk', false, 'snmpBrowserWindow()', 'class="sub next"', true); + $data['snmp_ver'] .= '  ' . html_print_button (__('SNMP walk'), 'snmp_walk', false, 'javascript:realtimeGraphs.snmpBrowserWindow();', 'class="sub next"', true); $table->colspan[2]['snmp_ver'] = 2; $table->data[] = $data; @@ -176,7 +176,7 @@ function pandora_realtime_graphs () { echo ''; // Define a custom action to save the OID selected in the SNMP browser to the form - html_print_input_hidden ('custom_action', urlencode (base64_encode(' ')), false); + html_print_input_hidden ('custom_action', urlencode (base64_encode(' ')), false); html_print_input_hidden ('incremental_base', '0'); echo ''; diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.js b/pandora_console/extensions/realtime_graphs/realtime_graphs.js index 6c535f2e5d..34da7b1704 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.js +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.js @@ -1,192 +1,207 @@ -var max_data_plot = 100; +(function () { + var numberOfPoints = 100; + var refresh = parseInt($('#refresh').val()); + var incremental = $('#checkbox-incremental').is(':checked') || $('#hidden-incremental').val() == 1; + var lastIncVal = null; + var intervalRef = null; + var currentXHR = null; -var options = { - legend: { container: $("#chartLegend") }, - xaxis: { - tickFormatter: function (timestamp, axis) { - var date = new Date(timestamp * 1000); - - var server_timezone_offset = get_php_value('timezone_offset'); - var local_timezone_offset = date.getTimezoneOffset()*60*-1; - - if (server_timezone_offset != local_timezone_offset) { - // If timezone of server and client is different, adjust the time to the server - date = new Date((timestamp + (server_timezone_offset - local_timezone_offset)) * 1000); + var plot; + var plotOptions = { + legend: { container: $("#chartLegend") }, + xaxis: { + tickFormatter: function (timestamp, axis) { + var date = new Date(timestamp * 1000); + + var server_timezone_offset = get_php_value('timezone_offset'); + var local_timezone_offset = date.getTimezoneOffset()*60*-1; + + if (server_timezone_offset != local_timezone_offset) { + // If timezone of server and client is different, adjust the time to the server + date = new Date((timestamp + (server_timezone_offset - local_timezone_offset)) * 1000); + } + + var hours = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()); + var minutes = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()); + var seconds = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()); + var formattedTime = hours + ':' + minutes + ':' + seconds; + return formattedTime; + } + }, + yaxis: { + tickFormatter: function (value, axis) { + return shortNumber(value); + } + }, + series: { + lines: { + lineWidth: 2, + fill: true + } + }, + colors: ['#6db431'] + }; + + function updatePlot (data) { + plot = $.plot($('.graph'), data, plotOptions); + } + + function requestData () { + var rel_path = $("#hidden-rel_path").val(); + + currentXHR = $.ajax({ + url: rel_path + "extensions/realtime_graphs/ajax.php", + type: "POST", + dataType: "json", + data: { + graph: $('#graph :selected').val(), + graph_title: $('#graph :selected').html(), + snmp_community: $('#text-snmp_community').val(), + snmp_oid: $('#text-snmp_oid').val(), + snmp_ver: $('#snmp_version :selected').val(), + snmp_address: $('#text-ip_target').val(), + refresh: refresh + }, + success: function (serie) { + var timestamp = serie.data[0][0]; + var data = plot.getData(); + + if (incremental) { + var currentVal = serie.data[0][1]; + // Try to avoid the first value, cause we need at least two values to get the increment + serie.data[0][1] = lastIncVal == null ? 0 : currentVal - lastIncVal; + // Incremental is always positive + if (serie.data[0][1] < 0) serie.data[0][1] = 0; + // Store the current value to use it into the next request + lastIncVal = currentVal; + } + + if (data.length === 0) { + for (i = 0; i < numberOfPoints; i++) { + var step = i * (refresh / 1000); + serie.data.unshift([timestamp - step, 0]); } - var hours = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()); - var minutes = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()); - var seconds = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()); - var formattedTime = hours + ':' + minutes + ':' + seconds; - return formattedTime; + serie = [serie]; + updatePlot(serie); + return; } + + data[0].label = serie.label; + if (data[0].data.length >= numberOfPoints) { + data[0].data.shift(); + } + + data[0].data.push(serie.data[0]); + updatePlot(data); + } + }); + } + + function startDataPooling () { + intervalRef = window.setInterval(requestData, refresh); + } + + function resetDataPooling () { + if (currentXHR !== null) currentXHR.abort(); + // Stop and start the interval + window.clearInterval(intervalRef); + startDataPooling(); + } + + function clearGraph () { + var data = plot.getData(); + if (data.length === 0) return; + + for (i = 0; i < data[0].data.length; i ++) { + data[0].data[i][1] = 0; + } + if (incremental) lastIncVal = null; + + updatePlot(data); + + resetDataPooling(); + } + + // Set the form OID to the value selected in the SNMP browser + function setOID () { + if ($('#snmp_browser_version').val() == '3') { + $('#text-snmp_oid').val($('#table1-0-1').text()); + } else { + $('#text-snmp_oid').val($('#snmp_selected_oid').text()); + } + + // Close the SNMP browser + $('.ui-dialog-titlebar-close').trigger('click'); + } + + // Show the SNMP browser window + function snmpBrowserWindow () { + + // Keep elements in the form and the SNMP browser synced + $('#text-target_ip').val($('#text-ip_target').val()); + $('#text-community').val($('#text-snmp_community').val()); + $('#snmp_browser_version').val($('#snmp_version').val()); + $('#snmp3_browser_auth_user').val($('#snmp3_auth_user').val()); + $('#snmp3_browser_security_level').val($('#snmp3_security_level').val()); + $('#snmp3_browser_auth_method').val($('#snmp3_auth_method').val()); + $('#snmp3_browser_auth_pass').val($('#snmp3_auth_pass').val()); + $('#snmp3_browser_privacy_method').val($('#snmp3_privacy_method').val()); + $('#snmp3_browser_privacy_pass').val($('#snmp3_privacy_pass').val()); + + $("#snmp_browser_container").show().dialog ({ + title: '', + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" }, - series: { - lines: { - lineWidth: 2, - fill: true - } - }, - colors: ['#6db431'] + width: 920, + height: 500 + }); + } + + function shortNumber (number) { + if (Math.round(number) != number) return number; + number = Number.parseInt(number); + if (Number.isNaN(number)) return number; + + var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"]; + var pos = 0; + + while (number >= 1000 || number <= -1000) { + pos++; + number = number / 1000; } -var data = []; + return number + " " + shorts[pos]; + } -var id = $('.graph').attr('id'); -var plot = $.plot("#" + id, data, options); - - -var refresh = parseInt($('#refresh').val()); -var incremental = $('#checkbox-incremental').is(':checked') || $('#hidden-incremental').val() == 1; -var incremental_base = 0; -var last_inc = 0; -var to; - -refresh_graph(); - -function refresh_graph () { - var refresh = parseInt($('#refresh').val()); - - var postvars = new Array(); - var postvars = {}; - postvars['graph'] = $('#graph :selected').val(); - postvars['graph_title'] = $('#graph :selected').html(); - - postvars['snmp_community'] = $('#text-snmp_community').val(); - postvars['snmp_oid'] = $('#text-snmp_oid').val(); - postvars['snmp_ver'] = $('#snmp_version :selected').val(); - postvars['snmp_address'] = $('#text-ip_target').val(); - - postvars['refresh'] = refresh; - - var rel_path = $("#hidden-rel_path").val(); - - $.ajax({ - url: rel_path + "extensions/realtime_graphs/ajax.php", - type: "POST", - dataType: "json", - data: postvars, - success: function(serie) { - var timestamp = serie.data[0][0]; - data = plot.getData(); - if (data.length == 0) { - for(i = 0; i < max_data_plot; i ++) { - step = i * (refresh/1000); - serie.data.unshift([timestamp-step, 0]); - } - - serie = [serie]; - plot = $.plot("#" + id, serie, options); - return; - } - data[0].label = serie.label; - if (data[0].data.length >= max_data_plot) { - data[0].data.shift(); - } - - if (incremental) { - var last_item = parseInt(data[0].data.length)-1; - var last_value = data[0].data[last_item][1]; - - var current_value = serie.data[0][1]; - - serie.data[0][1] = current_value - last_inc; - - last_inc = current_value; - - // Incremental is always positive - if (serie.data[0][1] < 0) { - serie.data[0][1] = 0; - } - } - - data[0].data.push(serie.data[0]); - $.plot("#" + id, data, options); - } + $('#graph').change(function() { + $('form#realgraph').submit(); }); - to = window.setTimeout(refresh_graph, refresh); -} -$('#graph').change(function() { - $('form#realgraph').submit(); -}); - -$('#refresh').change(function() { - var refresh = parseInt($('#refresh').val()); - - // Stop and start the Timeout - clearTimeout(to); - to = window.setTimeout(refresh_graph, refresh); -}); - -// Show the SNMP browser window -function snmpBrowserWindow () { - - // Keep elements in the form and the SNMP browser synced - $('#text-target_ip').val($('#text-ip_target').val()); - $('#text-community').val($('#text-snmp_community').val()); - $('#snmp_browser_version').val($('#snmp_version').val()); - $('#snmp3_browser_auth_user').val($('#snmp3_auth_user').val()); - $('#snmp3_browser_security_level').val($('#snmp3_security_level').val()); - $('#snmp3_browser_auth_method').val($('#snmp3_auth_method').val()); - $('#snmp3_browser_auth_pass').val($('#snmp3_auth_pass').val()); - $('#snmp3_browser_privacy_method').val($('#snmp3_privacy_method').val()); - $('#snmp3_browser_privacy_pass').val($('#snmp3_privacy_pass').val()); - - $("#snmp_browser_container").show().dialog ({ - title: '', - resizable: true, - draggable: true, - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 920, - height: 500 + $('#refresh').change(function () { + refresh = parseInt($('#refresh').val()); + resetDataPooling(); }); -} -// Set the form OID to the value selected in the SNMP browser -function setOID () { - - if($('#snmp_browser_version').val() == '3'){ - $('#text-snmp_oid').val($('#table1-0-1').text()); - } else { - $('#text-snmp_oid').val($('#snmp_selected_oid').text()); + $('#checkbox-incremental').change(function() { + incremental = $('#checkbox-incremental').is(':checked'); + clearGraph(); + }); + + updatePlot([]); + requestData(); + startDataPooling(); + + // Expose this functions + window.realtimeGraphs = { + clearGraph: clearGraph, + setOID: setOID, + snmpBrowserWindow: snmpBrowserWindow } - - // Close the SNMP browser - $('.ui-dialog-titlebar-close').trigger('click'); -} -$('#checkbox-incremental').change(function() { - incremental = $('#checkbox-incremental').is(':checked'); - clearGraph(); -}); - -function firstNotZero(data) { - var notZero = 0; - for(i = 0; i < data[0].data.length; i ++) { - if (data[0].data[i][1] != 0) { - return data[0].data[i][1]; - } - } -} - -function setOnIncremental() { - -} - -function clearGraph() { - data = plot.getData(); - if (data.length == 0) { - return; - } - - for(i = 0; i < data[0].data.length; i ++) { - data[0].data[i][1] = 0; - } - - $.plot("#" + id, data, options); -} +})(); \ No newline at end of file diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 51dc9c54cb..04409881c5 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -14,4 +14,58 @@ ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL DEFAULT '0'; ALTER TABLE `tpolicy_modules` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; -COMMIT; \ No newline at end of file +DROP INDEX id_policy ON `tpolicy_agents`; + +ALTER TABLE `tpolicy_agents` ADD COLUMN `id_node` int(10) NOT NULL DEFAULT '0'; + +ALTER TABLE `tpolicy_agents` ADD UNIQUE(`id_policy`, `id_agent`, `id_node`); + +ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; + +ALTER TABLE `tmetaconsole_event` ADD COLUMN `data` double(22,5) default NULL; + +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `data` double(22,5) default NULL; + +ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + +ALTER TABLE `tmetaconsole_event` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + +CREATE TABLE `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', + `value` text, + `custom` text, + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +COMMIT; diff --git a/pandora_console/extras/mr/19.sql b/pandora_console/extras/mr/19.sql new file mode 100644 index 0000000000..ea08bd0f26 --- /dev/null +++ b/pandora_console/extras/mr/19.sql @@ -0,0 +1,78 @@ +START TRANSACTION; + +-- --------------------------------------------------------------------- +-- Table `tlayout_template` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `id_group` INTEGER UNSIGNED NOT NULL, + `background` varchar(200) NOT NULL, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `background_color` varchar(50) NOT NULL default '#FFF', + `is_favourite` INTEGER UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tlayout_template_data` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout_template` INTEGER UNSIGNED NOT NULL, + `pos_x` INTEGER UNSIGNED NOT NULL default 0, + `pos_y` INTEGER UNSIGNED NOT NULL default 0, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `label` TEXT, + `image` varchar(200) DEFAULT "", + `type` tinyint(1) UNSIGNED NOT NULL default 0, + `period` INTEGER UNSIGNED NOT NULL default 3600, + `module_name` text NOT NULL, + `agent_name` varchar(600) BINARY NOT NULL default '', + `id_layout_linked` INTEGER unsigned NOT NULL default '0', + `parent_item` INTEGER UNSIGNED NOT NULL default 0, + `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, + `id_metaconsole` int(10) NOT NULL default 0, + `id_group` INTEGER UNSIGNED NOT NULL default 0, + `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, + `border_width` INTEGER UNSIGNED NOT NULL default 0, + `type_graph` varchar(50) NOT NULL default 'area', + `label_position` varchar(50) NOT NULL default 'down', + `border_color` varchar(200) DEFAULT "", + `fill_color` varchar(200) DEFAULT "", + `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', + `clock_animation` varchar(60) NOT NULL default "analogic_1", + `time_format` varchar(60) NOT NULL default "time", + `timezone` varchar(60) NOT NULL default "Europe/Madrid", + PRIMARY KEY(`id`), + FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Rename column is_secondary to no_hierarchy in `tusuario _perfil` +-- --------------------------------------------------------------------- +ALTER TABLE `tusuario_perfil` ADD COLUMN `no_hierarchy` tinyint(1) NOT NULL DEFAULT 0; +UPDATE `tusuario_perfil` SET `no_hierarchy` = `is_secondary`; +ALTER TABLE `tusuario_perfil` DROP COLUMN `is_secondary`; + +UPDATE `talert_commands` SET name='Monitoring Event' WHERE name='Pandora FMS Event'; + +-- ----------------------------------------------------- +-- Table `tgis_map_layer_groups` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( + `layer_id` INT NOT NULL, + `group_id` MEDIUMINT(4) UNSIGNED NOT NULL, + `agent_id` INT(10) UNSIGNED NOT NULL COMMENT 'Used to link the position to the group', + PRIMARY KEY (`layer_id`, `group_id`), + FOREIGN KEY (`layer_id`) REFERENCES `tgis_map_layer` (`id_tmap_layer`) ON DELETE CASCADE, + FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, + FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/mr/20.sql b/pandora_console/extras/mr/20.sql new file mode 100644 index 0000000000..a36a832839 --- /dev/null +++ b/pandora_console/extras/mr/20.sql @@ -0,0 +1,49 @@ +START TRANSACTION; + +ALTER TABLE treport_content ADD COLUMN `recursion` TINYINT(1) default NULL; + +ALTER TABLE tevent_filter ADD COLUMN `user_comment` text NOT NULL; +ALTER TABLE tevent_filter ADD COLUMN `source` tinytext NOT NULL; +ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL; + +ALTER TABLE tagente_modulo ALTER COLUMN `parent_module_id` SET default 0; + +-- Changes for the 'service like status' feature (Carrefour) +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default'; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; +ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default'; +ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; + +-- ----------------------------------------------------- +-- Add column in table `treport` +-- ----------------------------------------------------- + +ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; + +ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1'; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default ''; +ALTER TABLE `tpolicy_modules_inventory` ADD COLUMN `custom_fields` MEDIUMBLOB NOT NULL; + +CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `title` TEXT NOT NULL, + `regexp` TEXT NOT NULL, + `fields` TEXT NOT NULL, + `average` tinyint(1) NOT NULL default '0', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index a59d94022e..4c851238ad 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -1,3 +1,14 @@ + + $value) { + db_process_sql_update( + 'tupdate_settings', + array(db_escape_key_identifier('value') => $value), + array(db_escape_key_identifier('key') => $key)); + } + + ui_print_success_message(__('License updated')); +} + +ui_require_javascript_file_enterprise('load_enterprise'); +enterprise_include_once('include/functions_license.php'); +$license = enterprise_hook('license_get_info'); + +$rows = db_get_all_rows_in_table('tupdate_settings'); + +$settings = new StdClass; +foreach ($rows as $row) { + $settings->$row['key'] = $row['value']; +} + +echo ''; + function render_info ($table) { global $console_mode; @@ -46,6 +95,164 @@ function render_row ($data, $label) { } } +function get_value_sum($arr){ + foreach($arr as $clave){ + foreach($clave as $valor){ + $result += $valor; + } + } + return $result; +} + +function execution_time(){ + $times = db_get_all_rows_sql("SELECT datos FROM tagente_datos WHERE id_agente_modulo = 29 ORDER BY utimestamp DESC LIMIT 2"); + if($times[0]['datos'] > $times[1]['datos'] * 1.2) + return "Warning Status   The execution time could be degrading. For a more extensive information of this data consult the Execution Time graph"; + else + return "Normal Status   The execution time is correct. For a more extensive information of this data consult the Execution Time graph"; +} + + +function get_logs_size($file){ + $file_name = '/var'. $file .''; + $size_server_log = filesize($file_name); + return $size_server_log; + +} + +function get_status_logs($path){ + $status_server_log = ""; + $size_server_log = get_logs_size($path); + if ($size_server_log <= 10240){ + $status_server_log = "Normal Status   You have less than 10 MB of logs"; + }else{ + $status_server_log = "Warning Status   You have more than 10 MB of logs"; + } + return $status_server_log; +} +function percentage_modules_per_agent(){ + $status_average_modules = ""; + $total_agents = db_get_value_sql ('SELECT count(*) FROM tagente'); + $total_modules = db_get_value_sql ('SELECT count(*) FROM tagente_modulo'); + $average_modules_per_agent = $total_modules / $total_agents; + if($average_modules_per_agent <= 40){ + $status_average_modules = "Normal Status   The average of modules per agent is less than 40 percent"; + }else{ + $status_average_modules = "Warning Status  The average of modules per agent is more than 40 percent. You can have performance problems"; + } +return $status_average_modules; +} + +function license_capacity(){ + $license = enterprise_hook('license_get_info'); + $license_limit = $license['limit']; + $status_license_capacity = ""; + $current_count = db_get_value_sql ('SELECT count(*) FROM tagente'); + if ($current_count > $license_limit * 90 /100){ + $status_license_capacity = "Warning Status   The license capacity is more than 90 percent"; + }else{ + $status_license_capacity = "Normal Status   The license capacity is less than 90 percent"; + } + return $status_license_capacity; +} + +function status_license_params($license_param){ + $status_license_par =""; + if ($license_param <=0) + $status_license_par = "OFF"; + else + $status_license_par = "ON"; + return $status_license_par; +} +function interval_average_of_network_modules(){ + $total_network_modules = db_get_value_sql ("SELECT count(*) FROM tagente_modulo WHERE id_tipo_modulo BETWEEN 6 AND 18"); + $total_module_interval_time = db_get_value_sql ("SELECT SUM(module_interval) FROM tagente_modulo WHERE id_tipo_modulo BETWEEN 6 AND 18"); + $average_time= (int) $total_module_interval_time / $total_network_modules; + + if($average_time < 180 ){ + $status_average_modules = "Warning Status   The system has a lot of load and a very fine configuration is required"; + }else{ + $status_average_modules = "Normal Status   The system has an acceptable charge"; + } + if ($average_time == 0) + $status_average_modules = "Normal Status   The system has no load"; + return $status_average_modules; +} + +$attachment_total_files = count(glob($config['homedir']."/attachment/{*.*}",GLOB_BRACE)); + +function files_attachment_folder($total_files){ + if($total_files <= 700){ + $status_total_files = "Normal Status   The attachment folder has less than 700 files."; + }else{ + $status_total_files = "Warning Status   The attachment folder has more than 700 files."; + } + return $status_total_files; +} + +$tagente_datos_size = db_get_value_sql('SELECT COUNT(*) FROM tagente_datos'); + +function status_tagente_datos($tagente_datos_size){ + if ($tagente_datos_size <=3000000){ + $tagente_datos_size = "Normal Status   The tagente_datos table has an acceptable amount of data."; + }else{ + $tagente_datos_size = "Warning Status   The tagente_datos table has too much data. A historical database is recommended."; + } + return $tagente_datos_size; +} + +function status_values($val_rec, $val){ + if ($val_rec <= $val) + return $val . " (Min. Recommended Value " . $val_rec. ")"; + else + return $val . " (Min. Recommended Value " . $val_rec. ") Warning Status"; +} + +$tables_fragmentation=db_get_sql ("SELECT (data_free/(index_length+data_length)) +as frag_ratio from information_schema.tables where DATA_FREE > 0 and table_name='tagente_datos' and table_schema='pandora'"); +$db_size=db_get_all_rows_sql("SELECT table_schema, +ROUND(SUM(data_length+index_length)/1024/1024,3) +FROM information_schema.TABLES +GROUP BY table_schema;" +); + +if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN'){ + $total_server_threads = shell_exec("ps -T aux | grep pandora_server | grep -v grep | wc -l"); + $percentage_threads_ram = shell_exec("ps axo pmem,cmd | grep pandora_server | awk '{sum+=$1} END {print sum}'"); + $percentage_threads_cpu = shell_exec("ps axo pcpu,cmd | grep pandora_server | awk '{sum+=$1} END {print sum}'"); + $innodb_buffer_pool_size_min_rec_value = shell_exec("cat /proc/meminfo | grep -i total | head -1 | awk '{print $(NF-1)*0.4/1024}'"); +} +$path_server_logs ="/log/pandora/pandora_server.log"; +$path_console_logs ="/www/html/pandora_console/pandora_console.log"; +$innodb_log_file_size_min_rec_value = "64M"; +$innodb_log_buffer_size_min_rec_value = "16M"; +$innodb_flush_log_at_trx_commit_min_rec_value = 0; +$query_cache_limit_min_rec_value = 2; +$max_allowed_packet_min_rec_value = 32; +$innodb_buffer_pool_size_min_rec_value = shell_exec("cat /proc/meminfo | grep -i total | head -1 | awk '{print $(NF-1)*0.4/1024}'"); +$sort_buffer_size_min_rec_value = 32; +$join_buffer_size_min_rec_value = 265; +$query_cache_type_min_rec_value = "ON"; +$query_cache_size_min_rec_value = 24; +$innodb_lock_wait_timeout_max_rec_value = 120; +$tables_fragmentation_max_rec_value = 10; +$thread_cache_size_max_rec_value = 8; +$thread_stack_min_rec_value = 256; +$max_connections_max_rec_value = 150; +$key_buffer_size_min_rec_value = 256; +$read_buffer_size_min_rec_value = 32; +$read_rnd_buffer_size_min_rec_value = 32; +$query_cache_min_res_unit_min_rec_value = 2; +$innodb_file_per_table_min_rec_value = 0; + +function status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation){ + $status_tables_frag = ""; + if($tables_fragmentation > $tables_fragmentation_max_rec_value) + $status_tables_frag = "Warning Status   The fragmentation tables is higher than recommended. You should defragment them."; + else + $status_tables_frag = "Normal Status   The fragmentation tables is correct."; + return $status_tables_frag; +} $console_mode = 1; if (!isset($argc)) @@ -78,8 +285,6 @@ else { if (file_exists("../include/config.php")) include "../include/config.php"; - global $config; - // Not from console, this is a web session if ((!isset($config["id_user"])) OR (!check_acl ($config["id_user"], 0, "PM"))) { echo "

You don't have privileges to use diagnostic tool

"; @@ -125,9 +330,9 @@ echo "".__("System info").""; @@ -312,7 +520,121 @@ switch ($config["dbtype"]) { WHERE \"key\" = 'current_update'", "Current Update #"); break; } +$innodb_log_file_size =db_get_value_sql ("SELECT @@innodb_log_file_size")/1048576; +$innodb_log_buffer_size =db_get_value_sql("SELECT @@innodb_log_buffer_size")/1048576; +$innodb_flush_log_at_trx_commit =db_get_value_sql("SELECT @@innodb_flush_log_at_trx_commit"); +$max_allowed_packet =db_get_value_sql("SELECT @@max_allowed_packet")/1048576; +$innodb_buffer_pool_size = db_get_value_sql("SELECT @@innodb_buffer_pool_size")/1024; +$sort_buffer_size =number_format(db_get_value_sql("SELECT @@sort_buffer_size")/1024, 2); +$join_buffer_size =db_get_value_sql("SELECT @@join_buffer_size")/1024; +$query_cache_type =db_get_value_sql("SELECT @@query_cache_type"); +$query_cache_size =db_get_value_sql("SELECT @@query_cache_size")/1048576; +$query_cache_limit =db_get_value_sql("SELECT @@query_cache_limit")/1048576; +$innodb_lock_wait_timeout =db_get_value_sql("SELECT @@innodb_lock_wait_timeout"); +$thread_cache_size =db_get_value_sql("SELECT @@thread_cache_size"); +$thread_stack =db_get_value_sql("SELECT @@thread_stack")/1024; +$max_connections =db_get_value_sql("SELECT @@max_connections"); +$key_buffer_size =db_get_value_sql("SELECT @@key_buffer_size")/1024; +$read_buffer_size =db_get_value_sql("SELECT @@read_buffer_size")/1024; +$read_rnd_buffer_size =db_get_value_sql("SELECT @@read_rnd_buffer_size")/1024; +$query_cache_min_res_unit =db_get_value_sql("SELECT @@query_cache_min_res_unit")/1024; +$innodb_file_per_table = db_get_value_sql("SELECT @@innodb_file_per_table"); +echo "".__("MySQL Performance metrics").""; +render_row(status_values($innodb_log_file_size_min_rec_value,$innodb_log_file_size),'InnoDB log file size ', 'InnoDB log file size '); +render_row(status_values($innodb_log_buffer_size_min_rec_value,$innodb_log_buffer_size),'InnoDB log buffer size ', 'InnoDB log buffer size '); +render_row(status_values($innodb_flush_log_at_trx_commit_min_rec_value,$innodb_flush_log_at_trx_commit), 'InnoDB flush log at trx-commit ','InnoDB flush log at trx-commit '); +render_row(status_values($max_allowed_packet_min_rec_value,$max_allowed_packet), 'Maximun allowed packet ','Maximun allowed packet '); +render_row(status_values($innodb_buffer_pool_size_min_rec_value,$innodb_buffer_pool_size), 'InnoDB buffer pool size ','InnoDB buffer pool size '); +render_row(status_values($sort_buffer_size_min_rec_value,$sort_buffer_size), 'Sort buffer size ','Sort buffer size '); +render_row(status_values($join_buffer_size_min_rec_value,$join_buffer_size), 'Join buffer size ','Join buffer size '); +render_row(status_values($query_cache_type_min_rec_value,$query_cache_type), 'Query cache type ', 'Query cache type '); +render_row(status_values($query_cache_size_min_rec_value,$query_cache_size), 'Query cache size ','Query cache size '); +render_row(status_values($query_cache_limit_min_rec_value,$query_cache_limit), 'Query cache limit ','Query cache limit '); +render_row(status_values($innodb_lock_wait_timeout_max_rec_value,$innodb_lock_wait_timeout), 'InnoDB lock wait timeout ','InnoDB lock wait timeout '); +render_row(status_values($thread_cache_size_max_rec_value,$thread_cache_size), 'Thread cache size ','Thread cache size '); +render_row(status_values($thread_stack_min_rec_value,$thread_stack), 'Thread stack ','Thread stack '); +render_row(status_values($max_connections_max_rec_value,$max_connections), 'Maximum connections ','Maximun connections '); +render_row(status_values($key_buffer_size_min_rec_value,$key_buffer_size), 'Key buffer size ','Key buffer size '); +render_row(status_values($read_buffer_size_min_rec_value,$read_buffer_size), 'Read buffer size ','Read buffer size '); +render_row(status_values($read_rnd_buffer_size_min_rec_value,$read_rnd_buffer_size), 'Read rnd-buffer size ','Read rnd-buffer size '); +render_row(status_values($query_cache_min_res_unit_min_rec_value,$query_cache_min_res_unit), 'Query cache min-res-unit ','Query cache min-res-unit '); +render_row(status_values($innodb_file_per_table_min_rec_value,$innodb_file_per_table), 'InnoDB file per table ','InnoDB file per table '); +echo "".__("Tables fragmentation in the PandoraFMS database").""; + + + +render_row ($tables_fragmentation_max_rec_value . "%", "Tables fragmentation (maximum recommended value)"); +render_row (number_format($tables_fragmentation, 2) . "%", "Tables fragmentation (current value)"); +render_row (status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), "Status fragmentation tables"); + +echo "".__(" PandoraFMS logs dates").""; + +render_row(number_format(get_logs_size($path_server_logs)/1024, 2) . "M", 'Size server logs (current value)'); +render_row(get_status_logs($path_server_logs),'Status server logs'); +render_row(number_format(get_logs_size($path_console_logs)/1024, 2) . "M", 'Size console logs (current value)'); +render_row(get_status_logs($path_console_logs),'Status console logs'); + +echo "".__(" PandoraFMS Licence Information").""; + +render_row( html_print_textarea ('keys[customer_key]', 10, 255, $settings->customer_key, 'style="height:40px; width:450px;"', true),'Customer key'); +render_row( $license['expiry_date'],'Expires'); +render_row( $license['limit'] . ' agents','Platform Limit'); +render_row( $license['count'] . ' agents','Current Platform Count'); +render_row( $license['count_enabled']. ' agents','Current Platform Count (enabled: items)'); +render_row( $license['count_disabled']. ' agents','Current Platform Count (disabled: items)'); +render_row( $license['license_mode'],'License Mode'); +render_row( status_license_params($license['nms']) , 'Network Management System'); +render_row( status_license_params($license['dhpm']) , 'Satellite'); +render_row( $license['licensed_to'], 'Licensed to'); +render_row( license_capacity(), "Status of agents capacity"); +render_row(percentage_modules_per_agent(), "Status of average modules per agent"); +render_row(interval_average_of_network_modules(), "Interval average of the network modules"); + +echo "".__(" Status of the attachment folder").""; + +render_row($attachment_total_files, "Total files in the attachment folder"); +render_row(files_attachment_folder($attachment_total_files), "Status of the attachment folder"); + +echo "".__(" Information from the tagente_datos table").""; + +render_row($tagente_datos_size, "Total data in the tagente_datos table"); +render_row(status_tagente_datos($tagente_datos_size), "Status of the tagente_datos table"); +render_row(execution_time(), "Degradation of the execution time when executing a count"); + +echo "".__(" Pandora FMS server threads").""; + +render_row($total_server_threads, "Total server threads"); +render_row($percentage_threads_ram . "%", "Percentage of threads used by the RAM"); +render_row($percentage_threads_cpu . "%", "Percentage of threads used by the CPU"); + +echo "".__(" Graphs modules that represent the self-monitoring system").""; + +$server_name = db_get_value_sql("SELECT name FROM tserver WHERE master = 1"); +$agent_id= db_get_value_sql ("SELECT id_agente FROM tagente WHERE nombre = '$server_name'"); + + $id_modules = agents_get_modules($agent_id); + + $id_modules = array ( + modules_get_agentmodule_id('Agents_Unknown',$agent_id), + modules_get_agentmodule_id('Database Maintenance',$agent_id), + modules_get_agentmodule_id('FreeDisk_SpoolDir',$agent_id), + modules_get_agentmodule_id('Free_RAM',$agent_id), + modules_get_agentmodule_id('Queued_Modules',$agent_id), + modules_get_agentmodule_id('Status',$agent_id), + modules_get_agentmodule_id('System_Load_AVG',$agent_id), + modules_get_agentmodule_id('Execution_time',$agent_id) + ); + + foreach ($id_modules as $id_module){ + $params =array( + 'agent_module_id' => $id_module['id_agente_modulo'], + 'period' => SECONDS_1MONTH, + 'date' => time() , + 'height' => '150' + ); + render_row(grafico_modulo_sparse ($params),"Graph of the " . $id_module['nombre']." module."); + } if ($console_mode == 0) { echo ""; } diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 2cb41a72d0..29c5bb4f8b 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1175,13 +1175,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 18); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 20); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '724'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '727'); -- --------------------------------------------------------------------- -- Table `tconfig_os` @@ -1213,6 +1213,9 @@ UPDATE `tlink` SET `link` = 'https://github.com/pandorafms/pandorafms/issues' WH -- --------------------------------------------------------------------- ALTER TABLE tevent_filter ADD COLUMN `date_from` date DEFAULT NULL; ALTER TABLE tevent_filter ADD COLUMN `date_to` date DEFAULT NULL; +ALTER TABLE tevent_filter ADD COLUMN `user_comment` text NOT NULL; +ALTER TABLE tevent_filter ADD COLUMN `source` tinytext NOT NULL; +ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL; -- --------------------------------------------------------------------- -- Table `tusuario` -- --------------------------------------------------------------------- @@ -1228,7 +1231,7 @@ ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL defa -- --------------------------------------------------------------------- ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; -ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL; +ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL default 0; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL default 0; -- --------------------------------------------------------------------- @@ -1337,6 +1340,7 @@ ALTER TABLE treport_content ADD COLUMN `lapse_calc` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300'; ALTER TABLE treport_content ADD COLUMN `visual_format` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `hide_no_data` tinyint(1) default '0'; +ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` @@ -1668,4 +1672,129 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`( ALTER TABLE tagente ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0'; ALTER TABLE tmetaconsole_agent ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0'; -ALTER TABLE tusuario_perfil ADD COLUMN `is_secondary` tinyint(1) NOT NULL default '0'; +ALTER TABLE tusuario_perfil ADD COLUMN `no_hierarchy` tinyint(1) NOT NULL default '0'; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_rules` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', + `value` text, + `custom` text, + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_actions` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tlayout_template` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `id_group` INTEGER UNSIGNED NOT NULL, + `background` varchar(200) NOT NULL, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `background_color` varchar(50) NOT NULL default '#FFF', + `is_favourite` INTEGER UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tlayout_template_data` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout_template` INTEGER UNSIGNED NOT NULL, + `pos_x` INTEGER UNSIGNED NOT NULL default 0, + `pos_y` INTEGER UNSIGNED NOT NULL default 0, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `label` TEXT, + `image` varchar(200) DEFAULT "", + `type` tinyint(1) UNSIGNED NOT NULL default 0, + `period` INTEGER UNSIGNED NOT NULL default 3600, + `module_name` text NOT NULL, + `agent_name` varchar(600) BINARY NOT NULL default '', + `id_layout_linked` INTEGER unsigned NOT NULL default '0', + `parent_item` INTEGER UNSIGNED NOT NULL default 0, + `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, + `id_metaconsole` int(10) NOT NULL default 0, + `id_group` INTEGER UNSIGNED NOT NULL default 0, + `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, + `border_width` INTEGER UNSIGNED NOT NULL default 0, + `type_graph` varchar(50) NOT NULL default 'area', + `label_position` varchar(50) NOT NULL default 'down', + `border_color` varchar(200) DEFAULT "", + `fill_color` varchar(200) DEFAULT "", + `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', + `clock_animation` varchar(60) NOT NULL default "analogic_1", + `time_format` varchar(60) NOT NULL default "time", + `timezone` varchar(60) NOT NULL default "Europe/Madrid", + PRIMARY KEY(`id`), + FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tlog_graph_models` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `title` TEXT NOT NULL, + `regexp` TEXT NOT NULL, + `fields` TEXT NOT NULL, + `average` tinyint(1) NOT NULL default '0', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); + +-- ----------------------------------------------------- +-- Add column in table `treport` +-- ----------------------------------------------------- + +ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; + +ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1'; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default ''; +ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default ''; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 5879790d57..4e6be0e725 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -258,10 +258,7 @@ if(!$new_agent){ } } - $groups = users_get_groups ($config["id_user"], "AR",false); -$agents = agents_get_group_agents (array_keys ($groups)); - $modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo WHERE id_agente = " . $id_parent); @@ -279,6 +276,7 @@ if (isset($groups[$grupo]) || $new_agent) { $table->data[4][1] = html_print_select_groups(false, "AR", false, 'grupo', $grupo, '', '', 0, true); } else { $table->data[4][1] = groups_get_name($grupo); + $table->data[4][1] .= html_print_input_hidden('grupo', $grupo, true); } $table->data[4][1] .= ' '; $table->data[4][1] .= ui_print_group_icon ($grupo, true); @@ -332,7 +330,8 @@ $table->data = array (); if (enterprise_installed()) { $secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', array($id_agente)); - $table->data['secondary_groups'][0] = __('Secondary groups'); + $table->data['secondary_groups'][0] = __('Secondary groups') . + ui_print_help_icon("secondary_groups", true); $table->data['secondary_groups'][1] = html_print_select_groups( false, // Use the current user to select the groups "AR", // ACL permission @@ -376,28 +375,6 @@ if (enterprise_installed()) { true, // Return HTML (not echo) true // Multiple selection ); -} - -// Custom ID -$table->data[0][0] = __('Custom ID'); -$table->data[0][1] = html_print_input_text ('custom_id', $custom_id, '', 16, 255, true); - -$table->data[1][0] = __('Parent'); -$params = array(); -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'id_parent'; -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_name'] = 'id_agent_parent'; -$params['hidden_input_idagent_value'] = $id_parent; -$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent); -$params['selectbox_id'] = 'cascade_protection_module'; -$params['javascript_is_function_select'] = true; -$params['cascade_protection'] = true; - -$table->data[1][1] = ui_print_agent_autocomplete_input($params); -$table->data[1][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). " " . ui_print_help_icon("cascade_protection", true); -$table->data[1][1] .= "  " . __('Module') . " " . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true); //safe operation mode if($id_agente){ @@ -416,27 +393,6 @@ if($id_agente){ $table->data[2][1] .= "  " . __('Module') . " " . html_print_select ($safe_mode_modules, "safe_mode_module", $safe_mode_module, "", "", 0, true); } - -// Learn mode / Normal mode -$table->data[3][0] = __('Module definition') . - ui_print_help_icon("module_definition", true); -$table->data[3][1] = __('Learning mode') . ' ' . - html_print_radio_button_extended ("modo", 1, '', $modo, false, 'show_modules_not_learning_mode_context_help();', - 'style="margin-right: 40px;"', true); -$table->data[3][1] .= __('Normal mode') . ' ' . - html_print_radio_button_extended ("modo", 0, '', $modo, false, 'show_modules_not_learning_mode_context_help();', - 'style="margin-right: 40px;"', true); -$table->data[3][1] .= __('Autodisable mode') . ' ' . - html_print_radio_button_extended ("modo", 2, '', $modo, false, 'show_modules_not_learning_mode_context_help();', - 'style="margin-right: 40px;"', true); - -// Status (Disabled / Enabled) -$table->data[4][0] = __('Status'); -$table->data[4][1] = __('Disabled') . ' ' . - html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); -$table->data[4][1] .= __('Active') . ' ' . - html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); - // Remote configuration $table->data[5][0] = __('Remote configuration'); @@ -465,6 +421,81 @@ if (!$new_agent) { else $table->data[5][1] = '' . __('Not available') . ''; + + +$cps_array[-1] = __('Disabled'); +if($cps > 0){ + $cps_array[$cps] = __('Enabled'); +} +else{ + $cps_inc = 0; + if($id_agente){ + $cps_inc = service_agents_cps($id_agente); + } + $cps_array[$cps_inc] = __('Enabled'); +} + +$table->data[6][0] = __('Cascade protection services'); +$table->data[6][0] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true); +$table->data[6][1] = html_print_select($cps_array, 'cps', $cps, '', '', 0, true); + + +} +// Custom ID +$table->data[0][0] = __('Custom ID'); +$table->data[0][1] = html_print_input_text ('custom_id', $custom_id, '', 16, 255, true); + +$table->data[1][0] = __('Parent'); +$params = array(); +$params['return'] = true; +$params['show_helptip'] = true; +$params['input_name'] = 'id_parent'; +$params['print_hidden_input_idagent'] = true; +$params['hidden_input_idagent_name'] = 'id_agent_parent'; +$params['hidden_input_idagent_value'] = $id_parent; +$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent); +$params['selectbox_id'] = 'cascade_protection_module'; +$params['javascript_is_function_select'] = true; +$params['cascade_protection'] = true; + +$table->data[1][1] = ui_print_agent_autocomplete_input($params); +if (enterprise_installed()) { +$table->data[1][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). " " . ui_print_help_icon("cascade_protection", true); +} +$table->data[1][1] .= "  " . __('Module') . " " . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true); +// Learn mode / Normal mode +$table->data[3][0] = __('Module definition') . + ui_print_help_icon("module_definition", true); +$table->data[3][1] = __('Learning mode') . ' ' . + html_print_radio_button_extended ("modo", 1, '', $modo, false, 'show_modules_not_learning_mode_context_help();', + 'style="margin-right: 40px;"', true); +$table->data[3][1] .= __('Normal mode') . ' ' . + html_print_radio_button_extended ("modo", 0, '', $modo, false, 'show_modules_not_learning_mode_context_help();', + 'style="margin-right: 40px;"', true); +$table->data[3][1] .= __('Autodisable mode') . ' ' . + html_print_radio_button_extended ("modo", 2, '', $modo, false, 'show_modules_not_learning_mode_context_help();', + 'style="margin-right: 40px;"', true); + +// Status (Disabled / Enabled) +$table->data[4][0] = __('Status'); +$table->data[4][1] = __('Disabled') . ' ' . + ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true) . ' ' . + html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); +$table->data[4][1] .= __('Enabled') . ' ' . + html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); + if (enterprise_installed()) { + $table->data[4][2] = __('Url address'); + $table->data[4][3] = html_print_input_text ('url_description', + $url_description, '', 45, 255, true); + }else{ + $table->data[5][0] = __('Url address'); + $table->data[5][1] = html_print_input_text ('url_description', + $url_description, '', 45, 255, true); + } +$table->data[5][2] = __('Quiet'); +$table->data[5][3] .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true); +$table->data[5][3] = html_print_checkbox('quiet', 1, $quiet, true); + $listIcons = gis_get_array_list_icons(); $arraySelectIcon = array(); @@ -510,30 +541,6 @@ if ($config['activate_gis']) { $update_gis_data, false, '', 'style="margin-right: 40px;"', true); } -$table->data[4][2] = __('Url address'); -$table->data[4][3] = html_print_input_text ('url_description', - $url_description, '', 45, 255, true); - -$table->data[5][2] = __('Quiet'); -$table->data[5][3] .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true); -$table->data[5][3] = html_print_checkbox('quiet', 1, $quiet, true); - -$cps_array[-1] = __('Disabled'); -if($cps > 0){ - $cps_array[$cps] = __('Enabled'); -} -else{ - $cps_inc = 0; - if($id_agente){ - $cps_inc = service_agents_cps($id_agente); - } - $cps_array[$cps_inc] = __('Enabled'); -} - -$table->data[6][0] = __('Cascade protection services'); -$table->data[6][0] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true); -$table->data[6][1] = html_print_select($cps_array, 'cps', $cps, '', '', 0, true); - ui_toggle(html_print_table ($table, true), __('Advanced options')); unset($table); @@ -599,8 +606,8 @@ echo clippy_context_help("modules_not_learning_mode"); echo ""; - if ($id_agente) { + echo '
'; html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); html_print_input_hidden ('update_agent', 1); diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php index 246d5b0290..a884912e63 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_explorer.php @@ -757,7 +757,7 @@ $table->data[2][1] = ''.__('Auth user').''; $table->data[2][2] = html_print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); $table->data[2][3] = ''.__('Auth password').''; $table->data[2][4] = html_print_input_password ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); -$table->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true); +$table->data[2][4] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_awse', true); $table->data[5][0] = ''.__('Privacy method').''; $table->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index 6066c284e1..e27c014a1f 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -474,7 +474,7 @@ $table->data[2][1] = ''.__('Auth user').''; $table->data[2][2] = html_print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); $table->data[2][3] = ''.__('Auth password').''; $table->data[2][4] = html_print_input_password ('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); -$table->data[2][4] .= html_print_input_hidden('active_snmp_v3', 0, true); +$table->data[2][4] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_awsie', true); $table->data[5][0] = ''.__('Privacy method').''; $table->data[5][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index ed52464dc0..3a208e1f7c 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -760,7 +760,7 @@ if ($update_agent) { // if modified some agent paramenter $quiet = (int) get_parameter("quiet", 0); $cps = (int) get_parameter("cps", 0); - $old_interval = db_get_value('intervalo', 'tagente', 'id_agente', $id_agente); + $old_values = db_get_row('tagente', 'id_agente', $id_agente); $fields = db_get_all_fields_in_table('tagent_custom_fields'); if ($fields === false) $fields = array(); @@ -800,10 +800,9 @@ if ($update_agent) { // if modified some agent paramenter ui_print_error_message(__('No agent alias specified')); //If there is an agent with the same name, but a different ID } - /*elseif (agents_get_agent_id ($nombre_agente) > 0 && - agents_get_agent_id ($nombre_agente) != $id_agente) { - ui_print_error_message(__('There is already an agent in the database with this name')); - }*/ + if ($grupo <= 0) { + ui_print_error_message(__('The group id %d is incorrect.', $grupo)); + } else { //If different IP is specified than previous, add the IP if ($direccion_agente != '' && @@ -861,11 +860,21 @@ if ($update_agent) { // if modified some agent paramenter // Update the agent from the metaconsole cache enterprise_include_once('include/functions_agents.php'); enterprise_hook ('agent_update_from_cache', array($id_agente, $values,$server_name)); - - if ($old_interval != $intervalo) { - enterprise_hook('config_agents_update_config_interval', array($id_agente, $intervalo)); + + # Update the configuration files + if ($old_values['intervalo'] != $intervalo) { + enterprise_hook( + 'config_agents_update_config_token', + array($id_agente, 'interval', $intervalo) + ); } - + if ($old_values['disabled'] != $disabled) { + enterprise_hook( + 'config_agents_update_config_token', + array($id_agente, 'standby', $disabled ? "1" : "0") + ); + } + if($tpolicy_group_old){ foreach ($tpolicy_group_old as $key => $value) { $tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents @@ -987,16 +996,16 @@ $edit_module = (bool) get_parameter ('edit_module'); // GET DATA for MODULE UPDATE OR MODULE INSERT if ($update_module || $create_module) { $id_grupo = agents_get_agent_group ($id_agente); + $all_groups = agents_get_all_groups_agent ($id_agente, $id_grupo); - $id_agent_module = (int) get_parameter ('id_agent_module'); - - if (!check_acl ($config["id_user"], $id_grupo, "AW")) { + if (! check_acl_one_of_groups ($config["id_user"], $all_groups, "AW")) { db_pandora_audit("ACL Violation", "Trying to create a module without admin rights"); require ("general/noaccess.php"); exit; } - + + $id_agent_module = (int) get_parameter ('id_agent_module'); $id_module_type = (int) get_parameter ('id_module_type'); $name = (string) get_parameter ('name'); $description = (string) get_parameter ('description'); @@ -1714,12 +1723,18 @@ if ($delete_module) { // DELETE agent module ! ui_print_error_message(__('There was a problem deleting the module')); } else { - ui_print_success_message(__('Module deleted succesfully')); + + echo ''; $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", "Deleted module '".$module_data["nombre"]."' for agent ".$agent["alias"]); } + + } // MODULE DUPLICATION @@ -1937,11 +1952,11 @@ switch ($tab) { resizable: true, draggable: true, modal: true, - height: 220, + height: 240, width: 600, title: 'Changing the module name of a satellite agent', open: function(){ - $('#dialog').html('

Warning
The names of the modules of a satellite should not be
altered manually. Unless you are absolutely certain of
the process, do not alter these names.

'); + $('#dialog').html('

Warning
The names of the modules of a satellite should not be altered manually. Unless you are absolutely certain of the process, do not alter these names.

'); }, buttons: [{ text: "Ok", @@ -1971,11 +1986,11 @@ switch ($tab) { resizable: true, draggable: true, modal: true, - height: 280, - width: 670, + height: 240, + width: 650, title: 'Changing snmp module name', open: function(){ - $('#dialog').html('

Warning
If you change the name of this module, various features
associated with this module, such as network maps,
interface graphs or other network modules, may no longer
work. If you are not completely sure of the process, please
do not change the name of the module.

'); + $('#dialog').html('

Warning
If you change the name of this module, various features associated with this module, such as network maps, interface graphs or other network modules, may no longer work. If you are not completely sure of the process, please do not change the name of the module.

'); }, buttons: [{ text: "Ok", diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 670009bf2f..994b5a69ea 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -343,6 +343,7 @@ if($os != 0){ $search_sql .= " AND id_os = " . $os; } +$user_groups_to_sql = ""; // Show only selected groups if ($ag_group > 0) { $ag_groups = array(); @@ -350,100 +351,39 @@ if ($ag_group > 0) { if ($recursion) { $ag_groups = groups_get_id_recursive($ag_group, true); } - - switch ($config["dbtype"]) { - case "mysql": - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s, %s %s - LIMIT %d, %d', - implode (",", $ag_groups), $search_sql, $order['field'],$order['order'], $order['field2'], $order['order'], $offset, $config["block_size"]); - break; - case "postgresql": - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s, %s %s - LIMIT %d OFFSET %d', - implode (",", $ag_groups), $search_sql, $order['field'],$order['order'], $order['field2'], $order['order'], $config["block_size"], $offset); - break; - case "oracle": - $set = array (); - $set['limit'] = $config["block_size"]; - $set['offset'] = $offset; - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s, %s %s', - implode (",", $ag_groups), $search_sql, $order['field'],$order['order'], $order['field2'], $order['order']); - $sql = oracle_recode_query ($sql, $set); - break; - } - - $sql_total = sprintf ('SELECT COUNT(*) - FROM tagente - WHERE id_grupo IN (%s) - %s', - implode (",", $ag_groups), $search_sql); - $total_agents = db_get_sql ($sql_total); -} -else { + $user_groups_to_sql = implode (",", $ag_groups); +} else { // Concatenate AW and AD permisions to get all the possible groups where the user can manage $user_groupsAW = users_get_groups ($config['id_user'], 'AW'); $user_groupsAD = users_get_groups ($config['id_user'], 'AD'); - + $user_groups = $user_groupsAW + $user_groupsAD; - - $sql = sprintf ('SELECT COUNT(*) - FROM tagente - WHERE id_grupo IN (%s) - %s', - implode (',', array_keys ($user_groups)), - $search_sql); - - $total_agents = db_get_sql ($sql); - - switch ($config["dbtype"]) { - case "mysql": - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s, %s %s - LIMIT %d, %d', - implode (',', array_keys ($user_groups)), - $search_sql, $order['field'],$order['order'], $order['field2'], $order['order'], $offset, $config["block_size"]); - break; - case "postgresql": - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s, %s %s - LIMIT %d OFFSET %d', - implode (',', array_keys ($user_groups)), - $search_sql, $order['field'],$order['order'], $order['field2'], $order['order'], $config["block_size"], $offset); - break; - case "oracle": - $set = array (); - $set['limit'] = $config["block_size"]; - $set['offset'] = $offset; - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s, %s %s', - implode (',', array_keys ($user_groups)), - $search_sql, $order['field'],$order['order'], $order['field2'], $order['order']); - $sql = oracle_recode_query ($sql, $set); - break; - } + $user_groups_to_sql = implode (',', array_keys ($user_groups)); } +$sql = sprintf ('SELECT COUNT(DISTINCT(tagente.id_agente)) + FROM tagente LEFT JOIN tagent_secondary_group tasg + ON tagente.id_agente = tasg.id_agent + WHERE (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s)) + %s', + $user_groups_to_sql, $user_groups_to_sql, + $search_sql); + +$total_agents = db_get_sql ($sql); + +$sql = sprintf ('SELECT * + FROM tagente LEFT JOIN tagent_secondary_group tasg + ON tagente.id_agente = tasg.id_agent + WHERE (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s)) + %s + GROUP BY tagente.id_agente + ORDER BY %s %s, %s %s + LIMIT %d, %d', + $user_groups_to_sql, $user_groups_to_sql, + $search_sql, + $order['field'], $order['order'], $order['field2'], $order['order'], + $offset, $config["block_size"]); + $agents = db_get_all_rows_sql ($sql); // Delete rnum row generated by oracle_recode_query() function @@ -494,13 +434,15 @@ if ($agents !== false) { } /* End Update tagente.remote 0/1 with remote agent function return */ - - $id_grupo = $agent["id_grupo"]; - + + $all_groups = agents_get_all_groups_agent($agent["id_agente"], $agent["id_grupo"]); + $check_aw = check_acl_one_of_groups ($config["id_user"], $all_groups, "AW"); + $check_ad = check_acl_one_of_groups ($config["id_user"], $all_groups, "AD"); + $cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']); - - if (! check_acl ($config["id_user"], $id_grupo, "AW", $agent['id_agente']) && ! check_acl ($config["id_user"], $id_grupo, "AD", $agent['id_agente'])) - continue; + + // Do not show the agent if there is not enough permissions + if (!$check_aw && !$check_ad) continue; if ($color == 1) { $tdcolor = "datos"; @@ -526,7 +468,7 @@ if ($agents !== false) { echo ''; echo ""; - if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { + if ($check_aw) { $main_tab = 'main'; } else { @@ -574,7 +516,7 @@ if ($agents !== false) { } echo '