diff --git a/extras/chrome_extension/manifest.json b/extras/chrome_extension/manifest.json index 662eaf24ee..85e62c1f13 100644 --- a/extras/chrome_extension/manifest.json +++ b/extras/chrome_extension/manifest.json @@ -1,14 +1,14 @@ { "name": "__MSG_name__", - "version": "1.0", + "version": "2.0", "manifest_version": 2, - "description": "__MSG_description__", + "description": "Pandora FMS Event viewer Chrome extension", "homepage_url": "http://pandorafms.com", "browser_action": { "default_title": "__MSG_default_title__", "default_icon": "images/icon.png", "default_popup": "popup.html" - }, + }, "background": { "page": "background.html" }, diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 6d486a253c..c4482d3c0e 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -56,6 +56,7 @@ AGENT_WIN_RC_FILE="$CODEHOME/pandora_agents/win32/versioninfo.rc" SATELLITE_FILE="$PANDHOME_ENT/satellite_server/satellite_server.pl" PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_plugins/NGINX/nginx_requests_queued.pl \ $PANDHOME_ENT/pandora_plugins/Sybase/sybase_plugin.pl \ +$PANDHOME_ENT/pandora_plugins/JMX/pandora_plugin_jmx.pl \ $PANDHOME_ENT/pandora_plugins/MarkLogic/pandora_marklogic.pl \ $PANDHOME_ENT/pandora_plugins/Apache/pandora_apache.pl \ $PANDHOME_ENT/pandora_plugins/Oracle/Database/pandora_oracle.pl \ diff --git a/pandora_agents/pc/Win32/util/tentacle_server.exe b/pandora_agents/pc/Win32/util/tentacle_server.exe index fc0522d9b0..a1b10c214f 100644 Binary files a/pandora_agents/pc/Win32/util/tentacle_server.exe and b/pandora_agents/pc/Win32/util/tentacle_server.exe differ diff --git a/pandora_agents/pc/tentacle_server b/pandora_agents/pc/tentacle_server index 283324b5ff..d6b5d4d3bd 100755 --- a/pandora_agents/pc/tentacle_server +++ b/pandora_agents/pc/tentacle_server @@ -102,7 +102,7 @@ my $SERVICE_NAME="Tentacle Server"; my $SERVICE_PARAMS=join(' ', @ARGV); # Program version -our $VERSION = '0.6.1'; +our $VERSION = '0.6.2'; # IPv4 address to listen on my @t_addresses = ('0', '0.0.0.0'); @@ -217,6 +217,7 @@ sub print_help { print ("\t-d\t\tRun as daemon.\n"); print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n"); print ("\t-f ca_cert\tVerify that the peer certificate is signed by a ca.\n"); + print ("\t-F config_file\tConfiguration file full path.\n"); print ("\t-h\t\tShow help.\n"); print ("\t-I\t\tEnable insecure operations (file listing and moving).\n"); print ("\t-i\t\tFilters.\n"); @@ -278,11 +279,13 @@ sub daemonize { ################################################################################ sub parse_options { my %opts; + my $CONF = {}; + my $token_value; my $tmp; my @t_addresses_tmp; # Get options - if (getopts ('a:b:c:de:f:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { + if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { print_help (); exit 1; } @@ -304,10 +307,16 @@ sub parse_options { } } + # Configuration file + if (defined($opts{'F'})) { + parse_config_file($opts{'F'}, $CONF); + } + # Address - if (defined ($opts{'a'})) { + $token_value = get_config_value($opts{'a'}, $CONF->{'addresses'}); + if (defined ($token_value)) { @t_addresses = (); - @t_addresses_tmp = split(/,/, $opts{'a'}); + @t_addresses_tmp = split(/,/, $token_value); foreach my $t_address (@t_addresses_tmp) { $t_address =~ s/^ *(.*?) *$/$1/; @@ -323,15 +332,17 @@ sub parse_options { } # Maximum simultaneous connections - if (defined ($opts{'c'})) { - $t_max_conn = $opts{'c'}; + $token_value = get_config_value($opts{'c'}, $CONF->{'max_connections'}); + if (defined ($token_value)) { + $t_max_conn = $token_value; if ($t_max_conn !~ /^\d+$/ || $t_max_conn < 1) { error ("Invalid number of maximum simultaneous connections."); } } # Run as daemon - if (defined ($opts{'d'})) { + $token_value = get_config_value($opts{'d'}, $CONF->{'daemon'}, 1); + if (defined ($token_value)) { if ($^ eq 'MSWin32') { error ("-d flag not available for this OS."); } @@ -340,11 +351,12 @@ sub parse_options { } # Enable SSL - if (defined ($opts{'e'})) { + $token_value = get_config_value($opts{'e'}, $CONF->{'ssl_cert'}); + if (defined ($token_value)) { require IO::Socket::SSL; - $t_ssl_cert = $opts{'e'}; + $t_ssl_cert = $token_value; if (! -f $t_ssl_cert) { error ("File $t_ssl_cert does not exist."); } @@ -353,21 +365,24 @@ sub parse_options { } # Verify peer certificate - if (defined ($opts{'f'})) { - $t_ssl_ca = $opts{'f'}; + $token_value = get_config_value($opts{'f'}, $CONF->{'ssl_ca'}); + if (defined ($token_value)) { + $t_ssl_ca = $token_value; if (! -f $t_ssl_ca) { error ("File $t_ssl_ca does not exist."); } } # Insecure mode - if (defined ($opts{'I'})) { + $token_value = get_config_value($opts{'I'}, $CONF->{'insecure'}, 1); + if (defined ($token_value)) { $t_insecure = 1; } # Filters (regexp:dir;regexp:dir...) - if (defined ($opts{'i'})) { - my @filters = split (';', $opts{'i'}); + $token_value = get_config_value($opts{'i'}, $CONF->{'filters'}); + if (defined ($token_value)) { + my @filters = split (';', $token_value); foreach my $filter (@filters) { my ($regexp, $dir) = split (':', $filter); next unless defined ($regexp) && defined ($dir); @@ -381,51 +396,58 @@ sub parse_options { } # SSL private key file - if (defined ($opts{'k'})) { - $t_ssl_key = $opts{'k'}; + $token_value = get_config_value($opts{'k'}, $CONF->{'ssl_key'}); + if (defined ($token_value)) { + $t_ssl_key = $token_value; if (! -f $t_ssl_key) { error ("File $t_ssl_key does not exist."); } } # Maximum file size - if (defined ($opts{'m'})) { - $t_max_size = $opts{'m'}; + $token_value = get_config_value($opts{'m'}, $CONF->{'max_size'}); + if (defined ($token_value)) { + $t_max_size = $token_value; if ($t_max_size !~ /^\d+$/ || $t_max_size < 1) { error ("Invalid maximum file size."); } } # File overwrite - if (defined ($opts{'o'})) { + $token_value = get_config_value($opts{'o'}, $CONF->{'overwrite'}, 1); + if (defined ($token_value)) { $t_overwrite = 1; } # Port - if (defined ($opts{'p'})) { - $t_port = $opts{'p'}; + $token_value = get_config_value($opts{'p'}, $CONF->{'port'}); + if (defined ($token_value)) { + $t_port = $token_value; if ($t_port !~ /^\d+$/ || $t_port < 1 || $t_port > 65535) { error ("Port $t_port is not valid."); } } # Quiet mode - if (defined ($opts{'q'})) { + $token_value = get_config_value($opts{'q'}, $CONF->{'quiet'}, 1); + if (defined ($token_value)) { $t_quiet = 1; } # Retries - if (defined ($opts{'r'})) { - $t_retries = $opts{'r'}; + $token_value = get_config_value($opts{'r'}, $CONF->{'retries'}); + if (defined ($token_value)) { + $t_retries = $token_value; if ($t_retries !~ /^\d+$/ || $t_retries < 1) { error ("Invalid number of retries for network operations."); } } # Storage directory - if (defined ($opts{'s'})) { + $token_value = get_config_value($opts{'s'}, $CONF->{'directory'}); + if (defined ($token_value)) { - $t_directory = $opts{'s'}; + $t_directory = $token_value; # Check that directory exists if (! -d $t_directory) { @@ -444,25 +466,36 @@ sub parse_options { } } else { - if (! defined($opts{'b'})) { + $token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'}); + if (! defined($token_value)) { print_help (); exit 1; } } # Timeout - if (defined ($opts{'t'})) { - $t_timeout = $opts{'t'}; + $token_value = get_config_value($opts{'t'}, $CONF->{'timeout'}); + if (defined ($token_value)) { + $t_timeout = $token_value; if ($t_timeout !~ /^\d+$/ || $t_timeout < 1) { error ("Invalid timeout for network operations."); } } + # Read verbose from config file + if (defined($CONF->{'verbose'})) { + if ($CONF->{'verbose'} eq "1") { + $t_log = 1; + } elsif ($CONF->{'verbose'} eq "2") { + $t_log = 1; + $t_log_hard = 1; + } + } # Be verbose if (defined ($opts{'v'})) { $t_log = 1; + $t_log_hard = 0; } - # Be verbose hard if (defined ($opts{'V'})) { $t_log = 1; @@ -470,18 +503,21 @@ sub parse_options { } # SSL private key password - if (defined ($opts{'w'})) { + $token_value = get_config_value($opts{'w'}, $CONF->{'ssl_password'}, 1); + if (defined ($token_value)) { $t_ssl_pwd = ask_passwd ("Enter private key file password: ", "Enter private key file password again for confirmation: "); } # Server password - if (defined ($opts{'x'})) { - $t_pwd = $opts{'x'}; + $token_value = get_config_value($opts{'x'}, $CONF->{'password'}); + if (defined ($token_value)) { + $t_pwd = $token_value; } #Proxy IP address - if (defined ($opts{'b'})) { - $t_proxy_ip = $opts{'b'}; + $token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'}); + if (defined ($token_value)) { + $t_proxy_ip = $token_value; if ($t_proxy_ip !~ /^[a-zA-Z\.]+$/ && ($t_proxy_ip !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ || $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255 || $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255) && @@ -491,15 +527,17 @@ sub parse_options { } # Proxy Port - if (defined ($opts{'g'})) { - $t_proxy_port = $opts{'g'}; + $token_value = get_config_value($opts{'g'}, $CONF->{'proxy_port'}); + if (defined ($token_value)) { + $t_proxy_port = $token_value; if ($t_proxy_port !~ /^\d+$/ || $t_proxy_port < 1 || $t_proxy_port > 65535) { error ("Proxy port $t_port is not valid."); } } # TCP wrappers support - if (defined ($opts{'T'})) { + $token_value = get_config_value($opts{'T'}, $CONF->{'use_libwrap'}, 1); + if (defined ($token_value)) { if ($t_libwrap_installed) { $t_use_libwrap = 1; } else { @@ -531,9 +569,76 @@ sub parse_options { } # Get the config file - if (defined ($opts{'l'})) { - $log_file = $opts{'l'}; + $token_value = get_config_value($opts{'l'}, $CONF->{'log_file'}); + if (defined ($token_value)) { + $log_file = $token_value; } + + # No command lines config values + + # Get the block size + if (defined ($CONF->{'block_size'})) { + if ($t_port !~ /^\d+$/ || $t_port < 1) { + error ("Invalid block size: " . $CONF->{'block_size'} . "."); + } + $t_block_size = $CONF->{'block_size'}; + } + + # Configuration file invalid chars + if (defined ($CONF->{'invalid_chars'})) { + $t_invalid_chars = $CONF->{'invalid_chars'}; + } +} + +################################################################################ +## SUB parse_config_file +## Get all options from a config file. +################################################################################ +sub parse_config_file { + my ($config_file, $CONF) = @_; + + # File should be writable + if (! -r $config_file) { + print "Configuration file $config_file is not readable.\n"; + return; + } + + # Open the file + my $FH; + if (! open ($FH, "< $config_file")) { + print "Cannot open configuration file $config_file.\n"; + return; + } + + # Read the file and only get the well formed lines + while (<$FH>) { + my $buffer_line = $_; + if ($buffer_line =~ /^[a-zA-Z]/){ # begins with letters + if ($buffer_line =~ m/([\w\-\_\.]+)\s+(.*)/){ + $CONF->{$1} = $2 unless $2 eq ""; + } + } + } + + close ($FH); + return; +} + +################################################################################ +## SUB parse_config_file +## Search in command line options and config hash from configuration file +## to get a value (command line is a priority) +################################################################################ +sub get_config_value { + my ($cmd_value, $conf_value, $bool) = @_; + $bool = 0 unless defined($bool); + + return $cmd_value if defined($cmd_value); + # The boolean type value is 1 or undef (0 should be translated like undefP) + if ($bool && defined($conf_value)) { + return undef if ($conf_value ne "1"); + } + return $conf_value; } ################################################################################ @@ -929,14 +1034,14 @@ sub recv_file { # Check file name if ($base_name =~ /[$t_invalid_chars]/) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " has an invalid file name"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (invalid file name)\n"); return; } # Check file size, empty files are not allowed if ($size < 1 || $size > $t_max_size) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " is too big"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (file is too big)\n"); return; } @@ -946,7 +1051,7 @@ sub recv_file { # Check if file exists if (-f $file && $t_overwrite == 0) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " already exists"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (file already exists)\n"); return; } @@ -979,7 +1084,7 @@ sub send_file { # Check file name if ($base_name =~ /[$t_invalid_chars]/) { print_log ("Requested file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name"); - send_data ("RECV ERR\n"); + send_data ("RECV ERR (file has an invalid file name)\n"); return; } @@ -989,7 +1094,7 @@ sub send_file { # Check if file exists if (! -f $file) { print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " does not exist"); - send_data ("RECV ERR\n"); + send_data ("RECV ERR (file does not exist)\n"); return; } diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index b2ad70c45d..5a21e0240c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.722-180427 +Version: 7.0NG.722-180510 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 bce9497bf2..f43cf78b12 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.722-180427" +pandora_version="7.0NG.722-180510" 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/pandora_agent b/pandora_agents/unix/pandora_agent index b889be6024..c87dcd5339 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.722'; -use constant AGENT_BUILD => '180427'; +use constant AGENT_BUILD => '180510'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 4cf19c08de..f7c64d1315 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.722 -%define release 180427 +%define release 180510 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 0421f86e61..7440866844 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.722 -%define release 180427 +%define release 180510 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 3282eaf04a..fe761d2280 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.722" -PI_BUILD="180427" +PI_BUILD="180510" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/tentacle_server b/pandora_agents/unix/tentacle_server index 283324b5ff..d6b5d4d3bd 100755 --- a/pandora_agents/unix/tentacle_server +++ b/pandora_agents/unix/tentacle_server @@ -102,7 +102,7 @@ my $SERVICE_NAME="Tentacle Server"; my $SERVICE_PARAMS=join(' ', @ARGV); # Program version -our $VERSION = '0.6.1'; +our $VERSION = '0.6.2'; # IPv4 address to listen on my @t_addresses = ('0', '0.0.0.0'); @@ -217,6 +217,7 @@ sub print_help { print ("\t-d\t\tRun as daemon.\n"); print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n"); print ("\t-f ca_cert\tVerify that the peer certificate is signed by a ca.\n"); + print ("\t-F config_file\tConfiguration file full path.\n"); print ("\t-h\t\tShow help.\n"); print ("\t-I\t\tEnable insecure operations (file listing and moving).\n"); print ("\t-i\t\tFilters.\n"); @@ -278,11 +279,13 @@ sub daemonize { ################################################################################ sub parse_options { my %opts; + my $CONF = {}; + my $token_value; my $tmp; my @t_addresses_tmp; # Get options - if (getopts ('a:b:c:de:f:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { + if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { print_help (); exit 1; } @@ -304,10 +307,16 @@ sub parse_options { } } + # Configuration file + if (defined($opts{'F'})) { + parse_config_file($opts{'F'}, $CONF); + } + # Address - if (defined ($opts{'a'})) { + $token_value = get_config_value($opts{'a'}, $CONF->{'addresses'}); + if (defined ($token_value)) { @t_addresses = (); - @t_addresses_tmp = split(/,/, $opts{'a'}); + @t_addresses_tmp = split(/,/, $token_value); foreach my $t_address (@t_addresses_tmp) { $t_address =~ s/^ *(.*?) *$/$1/; @@ -323,15 +332,17 @@ sub parse_options { } # Maximum simultaneous connections - if (defined ($opts{'c'})) { - $t_max_conn = $opts{'c'}; + $token_value = get_config_value($opts{'c'}, $CONF->{'max_connections'}); + if (defined ($token_value)) { + $t_max_conn = $token_value; if ($t_max_conn !~ /^\d+$/ || $t_max_conn < 1) { error ("Invalid number of maximum simultaneous connections."); } } # Run as daemon - if (defined ($opts{'d'})) { + $token_value = get_config_value($opts{'d'}, $CONF->{'daemon'}, 1); + if (defined ($token_value)) { if ($^ eq 'MSWin32') { error ("-d flag not available for this OS."); } @@ -340,11 +351,12 @@ sub parse_options { } # Enable SSL - if (defined ($opts{'e'})) { + $token_value = get_config_value($opts{'e'}, $CONF->{'ssl_cert'}); + if (defined ($token_value)) { require IO::Socket::SSL; - $t_ssl_cert = $opts{'e'}; + $t_ssl_cert = $token_value; if (! -f $t_ssl_cert) { error ("File $t_ssl_cert does not exist."); } @@ -353,21 +365,24 @@ sub parse_options { } # Verify peer certificate - if (defined ($opts{'f'})) { - $t_ssl_ca = $opts{'f'}; + $token_value = get_config_value($opts{'f'}, $CONF->{'ssl_ca'}); + if (defined ($token_value)) { + $t_ssl_ca = $token_value; if (! -f $t_ssl_ca) { error ("File $t_ssl_ca does not exist."); } } # Insecure mode - if (defined ($opts{'I'})) { + $token_value = get_config_value($opts{'I'}, $CONF->{'insecure'}, 1); + if (defined ($token_value)) { $t_insecure = 1; } # Filters (regexp:dir;regexp:dir...) - if (defined ($opts{'i'})) { - my @filters = split (';', $opts{'i'}); + $token_value = get_config_value($opts{'i'}, $CONF->{'filters'}); + if (defined ($token_value)) { + my @filters = split (';', $token_value); foreach my $filter (@filters) { my ($regexp, $dir) = split (':', $filter); next unless defined ($regexp) && defined ($dir); @@ -381,51 +396,58 @@ sub parse_options { } # SSL private key file - if (defined ($opts{'k'})) { - $t_ssl_key = $opts{'k'}; + $token_value = get_config_value($opts{'k'}, $CONF->{'ssl_key'}); + if (defined ($token_value)) { + $t_ssl_key = $token_value; if (! -f $t_ssl_key) { error ("File $t_ssl_key does not exist."); } } # Maximum file size - if (defined ($opts{'m'})) { - $t_max_size = $opts{'m'}; + $token_value = get_config_value($opts{'m'}, $CONF->{'max_size'}); + if (defined ($token_value)) { + $t_max_size = $token_value; if ($t_max_size !~ /^\d+$/ || $t_max_size < 1) { error ("Invalid maximum file size."); } } # File overwrite - if (defined ($opts{'o'})) { + $token_value = get_config_value($opts{'o'}, $CONF->{'overwrite'}, 1); + if (defined ($token_value)) { $t_overwrite = 1; } # Port - if (defined ($opts{'p'})) { - $t_port = $opts{'p'}; + $token_value = get_config_value($opts{'p'}, $CONF->{'port'}); + if (defined ($token_value)) { + $t_port = $token_value; if ($t_port !~ /^\d+$/ || $t_port < 1 || $t_port > 65535) { error ("Port $t_port is not valid."); } } # Quiet mode - if (defined ($opts{'q'})) { + $token_value = get_config_value($opts{'q'}, $CONF->{'quiet'}, 1); + if (defined ($token_value)) { $t_quiet = 1; } # Retries - if (defined ($opts{'r'})) { - $t_retries = $opts{'r'}; + $token_value = get_config_value($opts{'r'}, $CONF->{'retries'}); + if (defined ($token_value)) { + $t_retries = $token_value; if ($t_retries !~ /^\d+$/ || $t_retries < 1) { error ("Invalid number of retries for network operations."); } } # Storage directory - if (defined ($opts{'s'})) { + $token_value = get_config_value($opts{'s'}, $CONF->{'directory'}); + if (defined ($token_value)) { - $t_directory = $opts{'s'}; + $t_directory = $token_value; # Check that directory exists if (! -d $t_directory) { @@ -444,25 +466,36 @@ sub parse_options { } } else { - if (! defined($opts{'b'})) { + $token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'}); + if (! defined($token_value)) { print_help (); exit 1; } } # Timeout - if (defined ($opts{'t'})) { - $t_timeout = $opts{'t'}; + $token_value = get_config_value($opts{'t'}, $CONF->{'timeout'}); + if (defined ($token_value)) { + $t_timeout = $token_value; if ($t_timeout !~ /^\d+$/ || $t_timeout < 1) { error ("Invalid timeout for network operations."); } } + # Read verbose from config file + if (defined($CONF->{'verbose'})) { + if ($CONF->{'verbose'} eq "1") { + $t_log = 1; + } elsif ($CONF->{'verbose'} eq "2") { + $t_log = 1; + $t_log_hard = 1; + } + } # Be verbose if (defined ($opts{'v'})) { $t_log = 1; + $t_log_hard = 0; } - # Be verbose hard if (defined ($opts{'V'})) { $t_log = 1; @@ -470,18 +503,21 @@ sub parse_options { } # SSL private key password - if (defined ($opts{'w'})) { + $token_value = get_config_value($opts{'w'}, $CONF->{'ssl_password'}, 1); + if (defined ($token_value)) { $t_ssl_pwd = ask_passwd ("Enter private key file password: ", "Enter private key file password again for confirmation: "); } # Server password - if (defined ($opts{'x'})) { - $t_pwd = $opts{'x'}; + $token_value = get_config_value($opts{'x'}, $CONF->{'password'}); + if (defined ($token_value)) { + $t_pwd = $token_value; } #Proxy IP address - if (defined ($opts{'b'})) { - $t_proxy_ip = $opts{'b'}; + $token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'}); + if (defined ($token_value)) { + $t_proxy_ip = $token_value; if ($t_proxy_ip !~ /^[a-zA-Z\.]+$/ && ($t_proxy_ip !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ || $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255 || $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255) && @@ -491,15 +527,17 @@ sub parse_options { } # Proxy Port - if (defined ($opts{'g'})) { - $t_proxy_port = $opts{'g'}; + $token_value = get_config_value($opts{'g'}, $CONF->{'proxy_port'}); + if (defined ($token_value)) { + $t_proxy_port = $token_value; if ($t_proxy_port !~ /^\d+$/ || $t_proxy_port < 1 || $t_proxy_port > 65535) { error ("Proxy port $t_port is not valid."); } } # TCP wrappers support - if (defined ($opts{'T'})) { + $token_value = get_config_value($opts{'T'}, $CONF->{'use_libwrap'}, 1); + if (defined ($token_value)) { if ($t_libwrap_installed) { $t_use_libwrap = 1; } else { @@ -531,9 +569,76 @@ sub parse_options { } # Get the config file - if (defined ($opts{'l'})) { - $log_file = $opts{'l'}; + $token_value = get_config_value($opts{'l'}, $CONF->{'log_file'}); + if (defined ($token_value)) { + $log_file = $token_value; } + + # No command lines config values + + # Get the block size + if (defined ($CONF->{'block_size'})) { + if ($t_port !~ /^\d+$/ || $t_port < 1) { + error ("Invalid block size: " . $CONF->{'block_size'} . "."); + } + $t_block_size = $CONF->{'block_size'}; + } + + # Configuration file invalid chars + if (defined ($CONF->{'invalid_chars'})) { + $t_invalid_chars = $CONF->{'invalid_chars'}; + } +} + +################################################################################ +## SUB parse_config_file +## Get all options from a config file. +################################################################################ +sub parse_config_file { + my ($config_file, $CONF) = @_; + + # File should be writable + if (! -r $config_file) { + print "Configuration file $config_file is not readable.\n"; + return; + } + + # Open the file + my $FH; + if (! open ($FH, "< $config_file")) { + print "Cannot open configuration file $config_file.\n"; + return; + } + + # Read the file and only get the well formed lines + while (<$FH>) { + my $buffer_line = $_; + if ($buffer_line =~ /^[a-zA-Z]/){ # begins with letters + if ($buffer_line =~ m/([\w\-\_\.]+)\s+(.*)/){ + $CONF->{$1} = $2 unless $2 eq ""; + } + } + } + + close ($FH); + return; +} + +################################################################################ +## SUB parse_config_file +## Search in command line options and config hash from configuration file +## to get a value (command line is a priority) +################################################################################ +sub get_config_value { + my ($cmd_value, $conf_value, $bool) = @_; + $bool = 0 unless defined($bool); + + return $cmd_value if defined($cmd_value); + # The boolean type value is 1 or undef (0 should be translated like undefP) + if ($bool && defined($conf_value)) { + return undef if ($conf_value ne "1"); + } + return $conf_value; } ################################################################################ @@ -929,14 +1034,14 @@ sub recv_file { # Check file name if ($base_name =~ /[$t_invalid_chars]/) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " has an invalid file name"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (invalid file name)\n"); return; } # Check file size, empty files are not allowed if ($size < 1 || $size > $t_max_size) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " is too big"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (file is too big)\n"); return; } @@ -946,7 +1051,7 @@ sub recv_file { # Check if file exists if (-f $file && $t_overwrite == 0) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " already exists"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (file already exists)\n"); return; } @@ -979,7 +1084,7 @@ sub send_file { # Check file name if ($base_name =~ /[$t_invalid_chars]/) { print_log ("Requested file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name"); - send_data ("RECV ERR\n"); + send_data ("RECV ERR (file has an invalid file name)\n"); return; } @@ -989,7 +1094,7 @@ sub send_file { # Check if file exists if (! -f $file) { print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " does not exist"); - send_data ("RECV ERR\n"); + send_data ("RECV ERR (file does not exist)\n"); return; } diff --git a/pandora_agents/win32/bin/util/tentacle_server.exe b/pandora_agents/win32/bin/util/tentacle_server.exe index fc0522d9b0..a1b10c214f 100644 Binary files a/pandora_agents/win32/bin/util/tentacle_server.exe and b/pandora_agents/win32/bin/util/tentacle_server.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8a3a357bb0..c5197b2f71 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180427} +{180510} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index d8a5290ca1..e224e821f6 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.722(Build 180427)") +#define PANDORA_VERSION ("7.0NG.722(Build 180510)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7330a21d03..dcc4833585 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.722(Build 180427))" + VALUE "ProductVersion", "(7.0NG.722(Build 180510))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DB_Dockerfile b/pandora_console/DB_Dockerfile index eb6465f6c1..5dec3b4f63 100644 --- a/pandora_console/DB_Dockerfile +++ b/pandora_console/DB_Dockerfile @@ -5,6 +5,7 @@ WORKDIR /pandorafms/pandora_console ADD pandoradb.sql /docker-entrypoint-initdb.d ADD pandoradb_data.sql /docker-entrypoint-initdb.d +RUN chown mysql /docker-entrypoint-initdb.d ENV MYSQL_DATABASE=pandora diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 9c5c87433d..335495a622 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.722-180427 +Version: 7.0NG.722-180510 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 662727e75b..fdfd50f889 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.722-180427" +pandora_version="7.0NG.722-180510" package_pear=0 package_pandora=1 diff --git a/pandora_console/Dockerfile b/pandora_console/Dockerfile index ccbcef4cdd..1bdf0363f0 100644 --- a/pandora_console/Dockerfile +++ b/pandora_console/Dockerfile @@ -45,13 +45,14 @@ RUN yum install -y \ php-zip \ nmap \ net-snmp-utils \ + mod_ssl \ xprobe2 #Clone the repo RUN git clone -b develop https://github.com/pandorafms/pandorafms.git /tmp/pandorafms #Exposing ports for: HTTP, SNMP Traps, Tentacle protocol -EXPOSE 80 162/udp 41121 +EXPOSE 80 162/udp 443 41121 # Simple startup script to avoid some issues observed with container restart ADD docker_entrypoint.sh /entrypoint.sh diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index 261babb5aa..b3e9fff95f 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -46,8 +46,19 @@ if (isset ($_GET["loginhash"])) { } } +$public_hash = get_parameter('hash', false); + // Check user -//check_login (); +if ($public_hash === false) { + check_login(); +} else { + enterprise_include_once('include/functions_dashboard.php'); + if (dashboard_check_public_hash($public_hash) === false) { + db_pandora_audit("Invalid public hash", "Trying to access public dashboard"); + require ("general/noaccess.php"); + exit; + } +} define ('AJAX', true); diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index a218d59710..0f0fdf6990 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -14,8 +14,10 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -include_once('include/graphs/fgraph.php'); -include_once('include/functions_snmp_browser.php'); +global $config; + +include_once($config['homedir'] . '/include/graphs/fgraph.php'); +include_once($config['homedir'] . '/include/functions_snmp_browser.php'); function pandora_realtime_graphs () { global $config; @@ -25,8 +27,11 @@ function pandora_realtime_graphs () { $action = get_parameter('action', 'list'); $onheader = array(); - - ui_print_page_header (__("Realtime graphs"), "images/extensions.png", false, "", false, $onheader); + + $hide_header = get_parameter('hide_header', 0); + if (!$hide_header) { + ui_print_page_header (__("Realtime graphs"), "images/extensions.png", false, "", false, $onheader); + } $chart[time()]['graph'] = '0'; $interactive_graph = true; @@ -69,26 +74,40 @@ function pandora_realtime_graphs () { $graph = get_parameter('graph', 'cpu_load'); $refresh = get_parameter('refresh', '1000'); - $data['graph'] = __('Graph') . ' ' . html_print_select ($graph_fields, 'graph', $graph, '', '', 0, true); + if ($graph != 'snmp_module') { + $data['graph'] = __('Graph') . ' ' . html_print_select ($graph_fields, 'graph', $graph, '', '', 0, true); + } $refresh_fields[1000] = human_time_description_raw(1, true, 'large'); $refresh_fields[5000] = human_time_description_raw(5, true, 'large'); $refresh_fields[10000] = human_time_description_raw(10, true, 'large'); $refresh_fields[30000] = human_time_description_raw(30, true, 'large'); + if ($graph == 'snmp_module') { + $agent_alias = get_parameter('agent_alias', ''); + $module_name = get_parameter('module_name', ''); + $module_incremental = get_parameter ('incremental', 0); + $data['module_info'] = "$agent_alias: <b>$module_name</b>"; + + // Append all the hidden in this cell + $data['module_info'] .= html_print_input_hidden ('incremental', $module_incremental, true); + $data['module_info'] .= html_print_select ( + array('snmp_module' => '-'), 'graph', 'snmp_module', '', '', 0, true, false, true, '', false, 'display: none;' + ); + } $data['refresh'] = __('Refresh interval') . ' ' . html_print_select ($refresh_fields, 'refresh', $refresh, '', '', 0, true); - $data['incremental'] = __('Incremental') . ' ' . html_print_checkbox ('incremental', 1, 0, true); + 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); $table->data[] = $data; - - - if ($graph == 'snmp_interface') { - $snmp_address = ''; - $snmp_community = ''; - $snmp_oid = ''; - $snmp_ver = '1'; - $snmp_inc = false; - + + if ($graph == 'snmp_interface' || $graph == 'snmp_module') { + $snmp_address = get_parameter('snmp_address', ''); + $snmp_community = get_parameter('snmp_community', ''); + $snmp_oid = get_parameter('snmp_oid', ''); + $snmp_ver = get_parameter('snmp_ver', ''); + $data = array(); $data['snmp_address'] = __('Target IP') . ' ' . html_print_input_text ('ip_target', $snmp_address, '', 50, 255, true); @@ -111,12 +130,21 @@ function pandora_realtime_graphs () { $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); $table->colspan[2]['snmp_ver'] = 2; - + $table->data[] = $data; - + + // Hide some options in snmp_module graphs + if ($graph == 'snmp_module') { + $table->rowstyle[1] = "display: none;"; + $table->rowstyle[2] = "display: none;"; + } snmp_browser_print_container (false, '100%', '60%', 'none'); } + // Print the relative path to AJAX calls: + html_print_input_hidden('rel_path', get_parameter('rel_path', '')); + + // Print the form echo '<form id="realgraph" method="post">'; html_print_table($table); echo '</form>'; @@ -125,9 +153,9 @@ function pandora_realtime_graphs () { html_print_input_hidden ('custom_action', urlencode (base64_encode(' <a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false); html_print_input_hidden ('incremental_base', '0'); - echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>'; - echo '<script type="text/javascript" src="include/javascript/pandora_snmp_browser.js"></script>'; - echo '<link rel="stylesheet" type="text/css" href="extensions/realtime_graphs/realtime_graphs.css"></style>'; + echo '<script type="text/javascript" src="'.ui_get_full_url("extensions/realtime_graphs/realtime_graphs.js").'"></script>'; + echo '<script type="text/javascript" src="'.ui_get_full_url("include/javascript/pandora_snmp_browser.js").'"></script>'; + echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url("extensions/realtime_graphs/realtime_graphs.css").'"></style>'; // Store servers timezone offset to be retrieved from js set_js_value('timezone_offset', date('Z', time())); diff --git a/pandora_console/extensions/realtime_graphs/ajax.php b/pandora_console/extensions/realtime_graphs/ajax.php index 89ea428ee2..7c3eb0c3b5 100644 --- a/pandora_console/extensions/realtime_graphs/ajax.php +++ b/pandora_console/extensions/realtime_graphs/ajax.php @@ -59,6 +59,7 @@ switch($graph) { $data = exec("ps aux | grep pandora_server | grep -v grep | awk '{ print $3 }'"); break; case 'snmp_interface': + case 'snmp_module': $snmp_address = $_POST['snmp_address']; $snmp_community = $_POST['snmp_community']; $snmp_ver = $_POST['snmp_ver']; diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.js b/pandora_console/extensions/realtime_graphs/realtime_graphs.js index 538a68f144..6c535f2e5d 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.js +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.js @@ -37,7 +37,7 @@ var plot = $.plot("#" + id, data, options); var refresh = parseInt($('#refresh').val()); -var incremental = $('#checkbox-incremental').is(':checked'); +var incremental = $('#checkbox-incremental').is(':checked') || $('#hidden-incremental').val() == 1; var incremental_base = 0; var last_inc = 0; var to; @@ -58,9 +58,11 @@ function refresh_graph () { postvars['snmp_address'] = $('#text-ip_target').val(); postvars['refresh'] = refresh; - + + var rel_path = $("#hidden-rel_path").val(); + $.ajax({ - url: "extensions/realtime_graphs/ajax.php", + url: rel_path + "extensions/realtime_graphs/ajax.php", type: "POST", dataType: "json", data: postvars, diff --git a/pandora_console/extras/mr/15.sql b/pandora_console/extras/mr/15.sql new file mode 100644 index 0000000000..fff6c4e440 --- /dev/null +++ b/pandora_console/extras/mr/15.sql @@ -0,0 +1,9 @@ +START TRANSACTION; + +ALTER TABLE tcluster DROP FOREIGN KEY tcluster_ibfk_1; + +ALTER TABLE tcluster_agent DROP FOREIGN KEY tcluster_agent_ibfk_1; + +ALTER TABLE tcluster_agent DROP FOREIGN KEY tcluster_agent_ibfk_2; + +COMMIT; \ No newline at end of file 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 d25bafbece..e3572edb04 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 @@ -1509,9 +1509,7 @@ create table IF NOT EXISTS `tcluster`( `description` text not null default '', `group` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE + PRIMARY KEY (`id`) ) engine=InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- @@ -1539,8 +1537,6 @@ create table IF NOT EXISTS `tcluster_agent`( `id_cluster` int unsigned not null, `id_agent` int(10) unsigned not null, PRIMARY KEY (`id_cluster`,`id_agent`), - FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE, FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`) ON UPDATE CASCADE ) engine=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index c598626ac2..f8a4622ffe 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -103,24 +103,9 @@ if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { $data[0] = ''; } - - - $data[1] = '<div id="module_data" style="top:1em; float:left; width:50%;">'; $data[1] .= html_print_label(__("Agent"),'agent_name', true)."<br/>"; -$params = array(); -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'agent_name'; -$params['value'] = $agent_name; -$params['javascript_is_function_select'] = true; -$params['selectbox_id'] = 'prediction_module'; -$params['none_module_text'] = __('Select Module'); -$params['use_hidden_input_idagent'] = true; -$params['hidden_input_idagent_id'] = 'hidden-id_agente'; -$data[1] .= ui_print_agent_autocomplete_input($params); - // Get module and agent of the target prediction module if (!empty($prediction_module)) { $id_agente_clean = modules_get_agentmodule_agent($prediction_module); @@ -131,6 +116,19 @@ else { $id_agente_clean = $id_agente; $agent_name_clean = $agent_name; } +$agent_alias = agents_get_alias($id_agente_clean); + +$params = array(); +$params['return'] = true; +$params['show_helptip'] = true; +$params['input_name'] = 'agent_name'; +$params['value'] = $agent_alias; +$params['javascript_is_function_select'] = true; +$params['selectbox_id'] = 'prediction_module'; +$params['none_module_text'] = __('Select Module'); +$params['use_hidden_input_idagent'] = true; +$params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; +$data[1] .= ui_print_agent_autocomplete_input($params); $data[1] .= html_print_label(__("Module"),'prediction_module',true); if ($id_agente) { @@ -154,7 +152,7 @@ $periods [1] = __('Monthly'); $periods [2] = __('Daily'); $data[1] .= html_print_select ($periods, 'custom_integer_2', $custom_integer_2, '', '', 0, true); -$data[1] .= html_print_input_hidden ('id_agente', $id_agente, true); +$data[1] .= html_print_input_hidden ('id_agente_module_prediction', $id_agente, true); $data[1] .= '</div>'; $table_simple->colspan['prediction_module'][1] = 3; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 9cfbbc057e..eb0e9b19b1 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -35,7 +35,6 @@ var img_handler_end; function toggle_advance_options_palette(close) { if ($("#advance_options").css('display') == 'none') { $("#advance_options").css('display', ''); - $("#advance_options *").css('display', ''); } else { $("#advance_options").css('display', 'none'); diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index 8a35de9e32..3de03185f2 100644 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -123,6 +123,15 @@ switch ($action) { 'image_height' => $image_height ); break; + case 'WMS': + $url = get_parameter('url'); + $layers = get_parameter('layers'); + $mapConnectionData = array( + 'type' => 'WMS', + 'url' => $url, + 'layers' => $layers + ); + break; } //TODO VALIDATE PARAMETERS @@ -168,6 +177,7 @@ $table->data = array(); $types["OSM"] = __('Open Street Maps'); $types["Gmap"] = __('Google Maps'); $types["Static_Image"] = __('Static Image'); +$types["WMS"] = __('WMS Server'); $table->data[0][0] = __('Type') . ":"; $table->data[0][1] = html_print_select($types, 'sel_type', $mapConnection_type, "selMapConnectionType();", __('Please select the connection type'), 0, true); @@ -184,6 +194,7 @@ $bb_bottom = ''; $bb_top = ''; $image_width = ''; $image_height = ''; +$layers = ''; if ($mapConnectionData != null) { switch ($mapConnection_type) { case 'OSM': @@ -202,6 +213,10 @@ if ($mapConnectionData != null) { $image_width= $mapConnectionData['image_width']; $image_height= $mapConnectionData['image_height']; break; + case 'WMS': + $mapConnectionDataUrl = $mapConnectionData['url']; + $layers = $mapConnectionData['layers']; + break; } } // Open Street Map Connection @@ -260,6 +275,27 @@ $optionsConnectionImageTable = '<table class="databox" border="0" cellpadding="4 '<td>'. html_print_input_text ('image_height', $image_height, '', 25, 25, true) . '</td>' . '</tr>' . '</table>'; + +// WMS Server Connection +$optionsConnectionWMSTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%">' . + '<tr class="row_0">' . + '<td>' . __("WMS Server URL") . '</td>' . + '<td>' . + '<input id="type" type="hidden" name="type" value="WMS" />' . + html_print_input_text('url', $mapConnectionDataUrl, '', 90, 255, true) . + '</td>' . + '</tr>' . + '<tr class="row_1">' . + '<td>' . + __("Layers") . + ui_print_help_tip (__('Enter a single element or a comma separated list'), true) . + '</td>' . + '<td>' . + html_print_input_text('layers', $layers, '', 90, 255, true) . + '</td>' . + '</tr>' . + '</table>'; + if ($mapConnectionData != null) { switch ($mapConnection_type) { case 'OSM': @@ -271,6 +307,9 @@ if ($mapConnectionData != null) { case 'Static_Image': $optionsConnectionTypeTable = $optionsConnectionImageTable; break; + case 'WMS': + $optionsConnectionTypeTable = $optionsConnectionWMSTable; + break; } } @@ -434,6 +473,8 @@ function refreshMapViewSecondStep() { objBaseLayers[0]['bb_top'] = $('input[name=bb_top]').val(); objBaseLayers[0]['image_width'] = $('input[name=image_width]').val(); objBaseLayers[0]['image_height'] = $('input[name=image_height]').val(); + // type WMS + objBaseLayers[0]['layers'] = $('input[name=layers]').val(); arrayControls = null; arrayControls = Array('Navigation', 'PanZoom', 'MousePosition'); @@ -487,6 +528,9 @@ function selMapConnectionType() { case 'Static_Image': $('#form_map_connection_type').html('<?php echo $optionsConnectionImageTable; ?>').hide(); break; + case 'WMS': + $('#form_map_connection_type').html('<?php echo $optionsConnectionWMSTable; ?>').hide(); + break; default: $('#form_map_connection_type').html('').hide(); break; diff --git a/pandora_console/images/realtime_shortcut.png b/pandora_console/images/realtime_shortcut.png new file mode 100644 index 0000000000..eb2f5673a7 Binary files /dev/null and b/pandora_console/images/realtime_shortcut.png differ diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 75499d6e13..090a79f61e 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -234,7 +234,8 @@ if ($get_graphs){ $height = 300; } $table .= "<div style='width: 90%'><h4>".$graph[0]['name']."</h4><hr></div>"; - $table .= graphic_combined_module($modules, + $table .= graphic_combined_module( + $modules, $weights, $value['time_lapse'], 1000, @@ -261,7 +262,7 @@ if ($get_graphs){ $labels, false, false, - null, + true, false, false, $value['fullscale'] diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 2da50acdd4..10b181baee 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1083,6 +1083,10 @@ if ($list_modules) { $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; $win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"])); + // Try to display the SNMP module realtime graph + $rt_button .= get_module_realtime_link_graph($module); + if (!empty($rt_button)) $data[8] = $rt_button . " "; + # Show events for boolean modules by default. if ($graph_type == 'boolean') { $draw_events = 1; @@ -1099,9 +1103,8 @@ if ($list_modules) { base64_encode($module["nombre"]))) . "&" . "refresh=" . SECONDS_10MINUTES . "&" . "draw_events=$draw_events', 'day_".$win_handle."')"; - - if(!is_snapshot_data($module['datos'])){ - $data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> '; + if(!is_snapshot_data($module['datos'])){ + $data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> '; } $server_name = ''; $data[8] .= "<a href='javascript: " . diff --git a/pandora_console/include/ajax/update_manager.ajax.php b/pandora_console/include/ajax/update_manager.ajax.php index 80c62539da..3a74f6d941 100644 --- a/pandora_console/include/ajax/update_manager.ajax.php +++ b/pandora_console/include/ajax/update_manager.ajax.php @@ -15,6 +15,14 @@ global $config; +check_login (); + +if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) { + db_pandora_audit("ACL Violation", "Trying to access update Management"); + require ("general/noaccess.php"); + return; +} + require_once($config['homedir'] . "/include/functions_update_manager.php"); require_once($config['homedir'] . "/include/functions_graph.php"); enterprise_include_once("include/functions_update_manager.php"); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index bc6169682f..781559cc74 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC180427'; +$build_version = 'PC180510'; $pandora_version = 'v7.0NG.722'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_extensions.php b/pandora_console/include/functions_extensions.php index f80b5b5964..47e30d71fd 100755 --- a/pandora_console/include/functions_extensions.php +++ b/pandora_console/include/functions_extensions.php @@ -92,28 +92,27 @@ function extensions_is_extension ($page) { * * @param bool $enterprise */ -function extensions_get_extensions ($enterprise = false) { - - $dir = EXTENSIONS_DIR; - $master_dir = ENTERPRISE_DIR . '/' . EXTENSIONS_DIR; +function extensions_get_extensions ($enterprise = false, $rel_path = '') { + + $dir = $rel_path . EXTENSIONS_DIR; + $master_dir = $rel_path . ENTERPRISE_DIR . '/' . EXTENSIONS_DIR; $handle = false; if ($enterprise) { - $dir = ENTERPRISE_DIR . '/' . EXTENSIONS_DIR; + $dir = $rel_path . ENTERPRISE_DIR . '/' . EXTENSIONS_DIR; if (defined("METACONSOLE")) { - $dir = '../' . EXTENSIONS_DIR; - $master_dir = '../' . EXTENSIONS_DIR; + $dir = $rel_path . '../' . EXTENSIONS_DIR; + $master_dir = $rel_path . '../' . EXTENSIONS_DIR; } } else { if (defined("METACONSOLE")) { - $dir = '../../' . $dir; - $master_dir = '../' . EXTENSIONS_DIR; + $dir = $rel_path . '../../' . $dir; + $master_dir = $rel_path . '../' . EXTENSIONS_DIR; } } - + if (file_exists ($dir)) $handle = @opendir ($dir); - if (empty ($handle)) return; @@ -148,11 +147,22 @@ function extensions_get_extensions ($enterprise = false) { /* Load extensions in enterprise directory */ if (! $enterprise && file_exists ($master_dir)) - return array_merge ($extensions, extensions_get_extensions (true)); + return array_merge ($extensions, extensions_get_extensions (true, $rel_path)); return $extensions; } +/** + * @brief Check if an extension is enabled + * + * @param string Extension name (ended with .php) + * @return True if enabled + */ +function extensions_is_enabled_extension($name) { + global $config; + return isset($config['extensions'][$name]); +} + /** * Get disabled open and enterprise extensions */ diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index d642cce933..9d941b35a1 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -118,6 +118,10 @@ function gis_print_map($idDiv, $iniZoom, $latCenter, $lonCenter, $baselayers, $c case 'Gmap': echo "baselayer['gmap_type'] = '" . $baselayer['gmap_type'] . "';"; break; + case 'WMS': + echo "baselayer['url'] = '" . $baselayer['url'] . "';"; + echo "baselayer['layers'] = '" . $baselayer['layers'] . "';"; + break; } echo "baselayerList.push(baselayer);"; @@ -1035,6 +1039,10 @@ function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $c $baselayers[0]['image_width'] = $conectionData['image_width']; $baselayers[0]['image_height'] = $conectionData['image_height']; break; + case 'WMS': + $baselayers[0]['url'] = $conectionData['url']; + $baselayers[0]['layers'] = $conectionData['layers']; + break; } if ($gmap_layer === true) { diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index b444231b54..6c0c5a83e6 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1117,15 +1117,42 @@ function graph_get_formatted_date($timestamp, $format1, $format2) { * * @return Mixed */ -function graphic_combined_module ($module_list, $weight_list, $period, - $width, $height, $title, $unit_name, $show_events = 0, - $show_alerts = 0, $pure = 0, $stacked = 0, $date = 0, - $only_image = false, $homeurl = '', $ttl = 1, $projection = false, - $prediction_period = false, $background_color = 'white', - $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, - $show_min = true, $show_avg = true, $labels = array(), $dashboard = false, - $vconsole = false, $percentil = null, $from_interface = false, - $id_widget_dashboard=false, $fullscale = false, $summatory = 0, $average = 0, $modules_series = 0) { +function graphic_combined_module ( + $module_list, + $weight_list, + $period, + $width, + $height, + $title, + $unit_name, + $show_events = 0, + $show_alerts = 0, + $pure = 0, + $stacked = 0, + $date = 0, + $only_image = false, + $homeurl = '', + $ttl = 1, + $projection = false, + $prediction_period = false, + $background_color = 'white', + $name_list = array(), + $unit_list = array(), + $show_last = true, + $show_max = true, + $show_min = true, + $show_avg = true, + $labels = array(), + $dashboard = false, + $vconsole = false, + $percentil = null, + $from_interface = false, + $id_widget_dashboard=false, + $fullscale = false, + $summatory = 0, + $average = 0, + $modules_series = 0 +) { global $config; global $graphic_type; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index dfe09384b7..8f52df21e2 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2684,4 +2684,62 @@ function recursive_get_dt_from_modules_tree (&$f_modules, $modules, $deep) { } } +/** + * @brief Get the button with the link to open realtime stats into a new window + * Only to native (not satellite discovered) snmp modules. + * + * @param array With all the module info + * @return string All the HTML code to paint the button + */ +function get_module_realtime_link_graph ($module) { + global $config; + + // Sometimes some parameters are renamed + if (!isset($module['id_tipo_modulo'])) $module['id_tipo_modulo'] = $module['module_type']; + if (!isset($module['nombre'])) $module['nombre'] = $module['module_name']; + + // Avoid to show on metaconsole + if (is_metaconsole()) return ''; + // Realtime graph is an extension and it should be enabled + if (!extensions_is_enabled_extension("realtime_graphs.php")) return ''; + // Only to remote_snmp, remote_snmp_proc. snmp_snmp_inc + if ($module['id_tipo_modulo'] != 15 && $module['id_tipo_modulo'] != 16 && $module['id_tipo_modulo'] != 18) { + return ''; + } + // Only version 1, 2 and 2c + if ($module['tcp_send'] != "1" && $module['tcp_send'] != "2" && $module['tcp_send'] != "2c") { + return ''; + } + + $params = array( + 'graph' => 'snmp_module', + 'agent_alias' => modules_get_agentmodule_agent_alias($module['id_agente_modulo']), + 'module_name' => $module['nombre'], + 'snmp_address' => $module['ip_target'], + 'snmp_community' => $module['snmp_community'], + 'snmp_oid' => $module['snmp_oid'], + 'snmp_ver' => $module['tcp_send'], + 'hide_header' => 1, + 'rel_path' => '../../' + ); + // Incremental type + if ($module['id_tipo_modulo'] == 16) $params['incremental'] = 1; + $link = "operation/agentes/realtime_win.php?"; + foreach ($params as $p_key => $p_value) { + $link .= "$p_key=" . urlencode(io_safe_output($p_value)) . "&"; + } + $link = substr($link, 0, -1); + + $win_handle = "realtime_" . dechex(crc32($module["id_agente_modulo"].$module["nombre"])); + + $link_button = '<a href="javascript:winopeng_var(\''.$link.'\',\''.$win_handle.'\', 850, 480)">' . + html_print_image( + "images/realtime_shortcut.png", + true, + array("border" => '0', "alt" => "", 'title' => __('Realtime SNMP graph')) + ) . + '</a>'; + + return $link_button; +} ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 25a6ae18b4..74329b6fd4 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -879,7 +879,7 @@ function reporting_SLA($report, $content, $type = 'dinamic', } $i++; } - $data['sla_value'] = reporting_sla_get_compliance_from_array($data) * 100; + $data['sla_value'] = reporting_sla_get_compliance_from_array($data); $data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision'] ); } else{ @@ -895,8 +895,8 @@ function reporting_SLA($report, $content, $type = 'dinamic', $data['checks_error'] = $sla_array['checks_error']; $data['checks_unknown'] = $sla_array['checks_unknown']; $data['checks_not_init'] = $sla_array['checks_not_init']; - $data['sla_value'] = $sla_array['SLA'] * 100; - $data['sla_fixed'] = $sla_array['sla_fixed'] * 100; + $data['sla_value'] = $sla_array['SLA']; + $data['sla_fixed'] = $sla_array['sla_fixed']; } //checks whether or not it meets the SLA @@ -5854,7 +5854,7 @@ function reporting_availability_graph($report, $content, $pdf=false) { $raw_graph[$i]['utimestamp'] = $value_sla['date_to'] - $value_sla['date_from']; $i++; } - $data['sla_value'] = reporting_sla_get_compliance_from_array($data) * 100; + $data['sla_value'] = reporting_sla_get_compliance_from_array($data); $data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision'] ); } else{ @@ -5870,7 +5870,7 @@ function reporting_availability_graph($report, $content, $pdf=false) { $data['checks_error'] = $sla_array['checks_error']; $data['checks_unknown'] = $sla_array['checks_unknown']; $data['checks_not_init'] = $sla_array['checks_not_init']; - $data['sla_value'] = $sla_array['SLA'] * 100; + $data['sla_value'] = $sla_array['SLA']; } //checks whether or not it meets the SLA @@ -11018,7 +11018,7 @@ function reporting_sla_get_compliance_from_array ($sla_array) { $time_total_working = $time_compliance + $sla_array['time_error']; return $time_compliance == 0 ? 0 - : $time_compliance/$time_total_working; + : ($time_compliance/$time_total_working) * 100; } /** diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 0170b4ebe8..c6698d70cd 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -576,16 +576,17 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height enterprise_include_once ('include/functions_satellite.php'); $rows = get_proxy_servers(); - foreach ($rows as $row) { - if ($row['server_type'] != 13) { - $s_type = " (Standard)"; + if ($rows !== false) { + foreach ($rows as $row) { + if ($row['server_type'] != 13) { + $s_type = " (Standard)"; + } + else { + $s_type = " (Satellite)"; + } + $servers_to_exec[$row['id_server']] = $row['name'] . $s_type; + } } - else { - $s_type = " (Satellite)"; - } - - $servers_to_exec[$row['id_server']] = $row['name'] . $s_type; - } } $table->data[1][1] = '<strong>' . __('Server to execute') . '</strong> '; $table->data[1][1] .= html_print_select($servers_to_exec, 'server_to_exec', '', '', '', '', true); diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index b5f39f80d6..ff07b6bcb4 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -654,7 +654,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['position_row']['items'] = array('static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', 'label', 'icon', 'datos', 'box_item', - 'auto_sla_graph', 'bars_graph','clock'); + 'auto_sla_graph', 'bars_graph','clock', 'donut_graph'); $form_items_advance['position_row']['html'] = ' <td align="left">' . __('Position') . '</td> <td align="left">(' . html_print_input_text('left', '0', '', 3, 5, true) . @@ -684,7 +684,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'group_item', 'static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph', - 'bars_graph'); + 'bars_graph', 'donut_graph'); $form_items_advance['parent_row']['html'] = '<td align="left">' . __('Parent') . '</td> <td align="left">' . @@ -696,7 +696,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['map_linked_row']['items'] = array( 'group_item', 'static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', - 'icon', 'label', 'datos'); + 'icon', 'label', 'datos', 'donut_graph'); $form_items_advance['map_linked_row']['html'] = '<td align="left">'. __('Map linked') . '</td>' . '<td align="left">' . html_print_select_from_sql ( @@ -732,7 +732,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['element_group_row']['items'] = array( 'group_item', 'static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', - 'icon', 'label', 'datos'); + 'icon', 'label', 'datos', 'donut_graph'); $form_items_advance['element_group_row']['html'] = '<td align="left">'. __('Restrict access to group') . '</td>' . '<td align="left">' . diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index df5e7f28ad..4a5deb4443 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -497,6 +497,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, // Javascript code + if ($font_size == '') $font_size = '\'\''; $return .= "<script type='text/javascript'>"; $return .= "$(document).ready( function () {"; $return .= "pandoraFlotArea(" . diff --git a/pandora_console/include/javascript/openlayers.pandora.js b/pandora_console/include/javascript/openlayers.pandora.js index e0599c709f..32b7282440 100755 --- a/pandora_console/include/javascript/openlayers.pandora.js +++ b/pandora_console/include/javascript/openlayers.pandora.js @@ -139,7 +139,7 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob map.events.on({"zoomend": EventZoomEnd}); map.events.on({"mouseup": EventZoomEnd}); - + //Define the maps layer for (var baselayerIndex in objBaseLayers) { if (isInt(baselayerIndex)) { @@ -217,6 +217,29 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob ); map.addLayer(baseLayer); break; + case 'WMS': + // http://<server>/geoserver/wms + // ?bbox=-130,24,-66,50 + // &styles=population + // &Format=application/openlayers + // &request=GetMap + // &layers=topp:states + // &width=550 + // &height=250 + // &srs=EPSG:4326 + var layer = new OpenLayers.Layer.WMS( + objBaseLayers[baselayerIndex]['name'], + objBaseLayers[baselayerIndex]['url'], + { + layers: objBaseLayers[baselayerIndex]['layers'], + format: "image/png" + }, + { + numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'] + } + ); + map.addLayer(layer); + break; } } } diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 46e376509f..4aaf466876 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1564,6 +1564,70 @@ function round_with_decimals (value, multiplier = 1) { return round_with_decimals (value, multiplier * 10); } +/* + + $("body").append('<div id="event_delete_confirm_dialog"><h4>' + '<?php echo __('Are you sure?'); ?>' + '</h4></div>'); + $("#event_delete_confirm_dialog").dialog({ + resizable: false, + draggable: false, + modal: true, + height: 280, + width: 330, + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); } + }); +*/ + +/** + * Display a confirm dialog box + * + * @param string Text to display + * @param string Ok button text + * @param string Cancel button text + * @param function Callback to action when ok button is pressed +*/ +function display_confirm_dialog ( + message = '', + ok_text = '', + cancel_text = '', + ok_function = function () {} +) { + // Clean function to close the dialog + var clean_function = function () { + $("#pandora_confirm_dialog_text").hide(); + $("#pandora_confirm_dialog_text").remove(); + } + + // Modify the ok function to close the dialog too + var ok_function_clean = function () { + ok_function(); + clean_function(); + } + + // Display the dialog + $("body").append('<div id="pandora_confirm_dialog_text"><h3>' + message + '</h3></div>'); + $("#pandora_confirm_dialog_text").dialog({ + resizable: false, + draggable: true, + modal: true, + dialogClass: "pandora_confirm_dialog", + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: true, + modal: true, + buttons: { + Cancel: clean_function, + "Confirm": ok_function_clean + } + }); +} + function ellipsize (str, max, ellipse) { if (max == null) max = 140; if (ellipse == null) ellipse = "…"; diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index e5612ad7ef..f31ebb56d6 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -316,6 +316,10 @@ function configure_modules_form () { $("#text-max_critical").attr ("value", (data["max_critical"] == 0) ? 0 : data["max_critical"]); $("#text-str_critical").attr ("value", data["str_critical"]); $("#text-ff_event").attr ("value", (data["min_ff_event"] == 0) ? 0 : data["min_ff_event"]); + $("input[name=each_ff][value=" + data["each_ff"] + "]").prop('checked', true); + $("#text-ff_event_normal").attr ("value", (data["min_ff_event_normal"] == 0) ? 0 : data["min_ff_event_normal"]); + $("#text-ff_event_warning").attr ("value", (data["min_ff_event_warning"] == 0) ? 0 : data["min_ff_event_warning"]); + $("#text-ff_event_critical").attr ("value", (data["min_ff_event_critical"] == 0) ? 0 : data["min_ff_event_critical"]); $("#text-post_process").attr("value", (data["post_process"] == 0) ? 0 : data["post_process"]); $("#text-unit").attr("value", (data["unit"] == '') ? '' : data["unit"]); $("#text-critical_inverse").attr ("value", (data["critical_inverse"] == 0) ? 0 : data["critical_inverse"]); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 9b39270e66..b1467fa7d1 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4628,8 +4628,25 @@ form ul.form_flex li ul li{ border: 0px; } -.tickLabel { +.yAxis.y1Axis > .tickLabel { white-space: nowrap; line-height: 1.05em!important; + width: auto!important; } +.pandora_confirm_dialog .ui-dialog-buttonset { + display: flex; + width: 100%; + margin-left: 10px; + float: none !important; +} + +.pandora_confirm_dialog .ui-dialog-buttonset button{ + flex: 50%; +} + +#pandora_confirm_dialog_text h3{ + margin-left: 20px; + margin-right: 20px; + text-align: center; +} \ No newline at end of file diff --git a/pandora_console/index.php b/pandora_console/index.php index b283be0785..db2ce4b2ca 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -555,12 +555,15 @@ if (! isset ($config['id_user'])) { exit ("</html>"); } } - if($home_page != 'Visual console'){ - header("Location: ".$config['homeurl']."index.php?sec=".$_GET["sec"]."&sec2=".$_GET["sec2"]); + // Form the url + $query_params_redirect = $_GET; + // Visual console do not want sec2 + if($home_page == 'Visual console') unset($query_params_redirect["sec2"]); + $redirect_url = '?1=1'; + foreach ($query_params_redirect as $key => $value) { + $redirect_url .= '&'.safe_url_extraclean($key).'='.safe_url_extraclean($value); } - else{ - header("Location: ".$config['homeurl']."index.php?sec=".$_GET["sec"]); - } + header("Location: ".$config['homeurl']."index.php".$redirect_url); } // Hash login process elseif (isset ($_GET["loginhash"])) { diff --git a/pandora_console/install.php b/pandora_console/install.php index fef0b9fddd..106ef13712 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@ <div style='height: 10px'> <?php $version = '7.0NG.722'; -$build = '180427'; +$build = '180510'; $banner = "v$version Build $build"; error_reporting(0); diff --git a/pandora_console/operation/agentes/realtime_win.php b/pandora_console/operation/agentes/realtime_win.php new file mode 100644 index 0000000000..6106583c80 --- /dev/null +++ b/pandora_console/operation/agentes/realtime_win.php @@ -0,0 +1,105 @@ +<?php + +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// 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 for version 2. +// 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. + + +if (! isset($_SESSION['id_usuario'])) { + session_start(); + //session_write_close(); +} + +// Global & session management +require_once ('../../include/config.php'); +require_once ($config['homedir'] . '/include/auth/mysql.php'); +require_once ($config['homedir'] . '/include/functions.php'); +require_once ($config['homedir'] . '/include/functions_db.php'); +require_once ($config['homedir'] . '/include/functions_reporting.php'); +require_once ($config['homedir'] . '/include/functions_graph.php'); +require_once ($config['homedir'] . '/include/functions_modules.php'); +require_once ($config['homedir'] . '/include/functions_agents.php'); +require_once ($config['homedir'] . '/include/functions_tags.php'); +require_once ($config['homedir'] . '/include/functions_extensions.php'); +check_login (); + +// Metaconsole connection to the node +$server_id = (int) get_parameter("server"); +if (is_metaconsole() && !empty($server_id)) { + $server = metaconsole_get_connection_by_id($server_id); + + // Error connecting + if (metaconsole_connect($server) !== NOERR) { + echo "<html>"; + echo "<body>"; + ui_print_error_message(__('There was a problem connecting with the node')); + echo "</body>"; + echo "</html>"; + exit; + } +} + +$user_language = get_user_language ($config['id_user']); +if (file_exists ('../../include/languages/'.$user_language.'.mo')) { + $l10n = new gettext_reader (new CachedFileReader ('../../include/languages/'.$user_language.'.mo')); + $l10n->load_tables(); +} + +echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>'; +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <?php + // Parsing the refresh before sending any header + $refresh = (int) get_parameter ("refresh", -1); + if ($refresh > 0) { + $query = ui_get_url_refresh (false); + echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />'; + } + ?> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Pandora FMS Realtime Module Graph</title> + <link rel="stylesheet" href="../../include/styles/pandora_minimal.css" type="text/css" /> + <link rel="stylesheet" href="../../include/styles/jquery-ui-1.10.0.custom.css" type="text/css" /> + <script type='text/javascript' src='../../include/javascript/pandora.js'></script> + <script type='text/javascript' src='../../include/javascript/jquery-1.9.0.js'></script> + <script type='text/javascript' src='../../include/javascript/jquery.pandora.js'></script> + <script type='text/javascript' src='../../include/javascript/jquery.jquery-ui-1.10.0.custom.js'></script> + <?php + //Include the javascript for the js charts library + include_once($config["homedir"] . '/include/graphs/functions_flot.php'); + include_javascript_dependencies_flot_graph(); + ?> + </head> + <body bgcolor="#ffffff" style='background:#ffffff;'> + <?php + $config['extensions'] = extensions_get_extensions (false, '../../'); + if (!extensions_is_enabled_extension("realtime_graphs.php")) { + ui_print_error_message(__('Realtime extension is not enabled.')); + return; + } else { + include_once('../../extensions/realtime_graphs.php'); + } + pandora_realtime_graphs(); + ?> + + </body> +</html> + +<?php +// Echo the script tags of the datepicker and the timepicker +// Modify the user language cause the ui.datepicker language files use - instead _ +$custom_user_language = str_replace('_', '-', $user_language); +ui_require_jquery_file("ui.datepicker-" . $custom_user_language, "include/javascript/i18n/", true); +ui_include_time_picker(true); +?> diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index f630953dd5..57946cf610 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -753,7 +753,11 @@ switch ($config['dbtype']) { tagente.id_grupo AS id_group, tagente.id_agente AS id_agent, tagente_modulo.id_tipo_modulo AS module_type, - tagente_modulo.module_interval, + tagente_modulo.module_interval, + tagente_modulo.tcp_send, + tagente_modulo.ip_target, + tagente_modulo.snmp_community, + tagente_modulo.snmp_oid, tagente_estado.datos, tagente_estado.estado, tagente_modulo.min_warning, @@ -1272,12 +1276,11 @@ if (!empty($result)) { $graph_params_str = http_build_query($graph_params); $link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')'; - - $data[7] = ''; - + + $data[7] = get_module_realtime_link_graph($row); + if(!is_snapshot_data($row['datos'])){ - - $data[7] = '<a href="javascript:'.$link.'">' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) . '</a>'; + $data[7] .= '<a href="javascript:'.$link.'">' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) . '</a>'; } $data[7] .= '<a href="javascript: ' . 'show_module_detail_dialog(' . diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 8a506c979e..01373c8358 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -666,8 +666,12 @@ else { if ($i != 0 && $allow_action) { //Actions - $data[$i] = ''; - + $data[$i] = '<a href="javascript:" onclick="show_event_dialog(' . $event["id_evento"] . ', '.$group_rep.');">'; + $data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - " . strip_tags(io_safe_output($event["evento"])), true); + $data[$i] .= html_print_image ("images/eye.png", true, + array ("title" => __('Show more'))); + $data[$i] .= '</a>'; + if(!$readonly) { // Validate event if (($event["estado"] != 1) && (tags_checks_event_acl ($config["id_user"], $event["id_grupo"], "EW", $event['clean_tags'], $childrens_ids))) { @@ -676,6 +680,13 @@ else { $data[$i] .= html_print_image ("images/ok.png", true, array ("title" => __('Validate event'))); $data[$i] .= '</a>'; + // Display the go to in progress status button + if ($event["estado"] != 2) { + $data[$i] .= '<a href="javascript:validate_event_advanced('.$event["id_evento"].', 2)" id="in-progress-'.$event["id_evento"].'">'; + $data[$i] .= html_print_image ("images/hourglass.png", true, + array ("title" => __('Change to in progress status'))); + $data[$i] .= '</a>'; + } } // Delete event @@ -688,18 +699,19 @@ else { $data[$i] .= '</a>'; } else { - $data[$i] .= html_print_image ("images/cross.disabled.png", true, - array ("title" => __('Is not allowed delete events in process'))).' '; + $data[$i] .= html_print_image ( + "images/cross.disabled.png", + true, + array ( + "title" => __('Is not allowed delete events in process'), + "id" => "delete-" . $event['id_evento'] + ) + ); + $data[$i] .= ' '; } } } - - $data[$i] .= '<a href="javascript:" onclick="show_event_dialog(' . $event["id_evento"] . ', '.$group_rep.');">'; - $data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - " . strip_tags(io_safe_output($event["evento"])), true); - $data[$i] .= html_print_image ("images/eye.png", true, - array ("title" => __('Show more'))); - $data[$i] .= '</a>'; - + $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;'; $i++; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 9564e87b5e..03101d09b4 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -873,41 +873,45 @@ $(document).ready( function() { "html" ); }); - - $("a.delete_event").click (function () { - confirmation = confirm("<?php echo __('Are you sure?'); ?>"); - if (!confirmation) { - return; - } - meta = $('#hidden-meta').val(); - history_var = $('#hidden-history').val(); - - $tr = $(this).parents ("tr"); - id = this.id.split ("-").pop (); - - $("#delete_cross_"+id).attr ("src", "images/spinner.gif"); - - jQuery.post ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>", - {"page" : "operation/events/events", - "delete_event" : 1, - "id" : id, - "similars" : <?php echo ($group_rep ? 1 : 0) ?>, - "meta" : meta, - "history" : history_var - }, - function (data, status) { - if (data == "ok") { - $tr.remove (); - $('#show_message_error').html('<h3 class="suc"> <?php echo __('Successfully delete'); ?> </h3>'); - } - else - $('#show_message_error').html('<h3 class="error"> <?php echo __('Error deleting event'); ?> </h3>'); - }, - "html" + + $("td").on('click', 'a.delete_event', function () { + var click_element = this; + display_confirm_dialog( + "<?php echo __('Are you sure?'); ?>", + "<?php echo __('Confirm'); ?>", + "<?php echo __('Cancel'); ?>", + function () { + meta = $('#hidden-meta').val(); + history_var = $('#hidden-history').val(); + + $tr = $(click_element).parents ("tr"); + id = click_element.id.split ("-").pop (); + + $("#delete_cross_"+id).attr ("src", "images/spinner.gif"); + + jQuery.post ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>", + {"page" : "operation/events/events", + "delete_event" : 1, + "id" : id, + "similars" : <?php echo ($group_rep ? 1 : 0) ?>, + "meta" : meta, + "history" : history_var + }, + function (data, status) { + if (data == "ok") { + $tr.remove (); + $('#show_message_error').html('<h3 class="suc"> <?php echo __('Successfully delete'); ?> </h3>'); + } + else + $('#show_message_error').html('<h3 class="error"> <?php echo __('Error deleting event'); ?> </h3>'); + }, + "html" + ); + return false; + } ); - return false; }); - + function toggleDiv (divid) { if (document.getElementById(divid).style.display == 'none') { document.getElementById(divid).style.display = 'block'; @@ -940,6 +944,11 @@ function validate_event_advanced(id, new_status) { $tr = $('#validate-'+id).parents ("tr"); var grouped = $('#group_rep').val(); + + // Get images url + var hourglass_image = "<?php echo ui_get_full_url("images/hourglass.png", false, false, false); ?>"; + var cross_disabled_image = "<?php echo ui_get_full_url("images/cross.disabled.png", false, false, false); ?>"; + var cross_image = "<?php echo ui_get_full_url("images/cross.png", false, false, false); ?>"; var similar_ids; similar_ids = $('#hidden-similar_ids_'+id).val(); @@ -964,31 +973,46 @@ function validate_event_advanced(id, new_status) { // Change status description $("#status_row_"+id).html(<?php echo "'" . __('Event validated') . "'"; ?>); - // Change state image + // Change delete icon + $("#delete-"+id).remove(); + $("#validate-"+id).parent().append('<a class="delete_event" href="javascript:" id="delete-' + id + '"></a>'); + $("#delete-"+id).append("<img src='" + cross_image + "' />"); + $("#delete-"+id + " img").attr ("id", "delete_cross_" + id); + $("#delete-"+id + " img").attr ("data-title", <?php echo "'" . __('Delete event') . "'"; ?>); + $("#delete-"+id + " img").attr ("alt", <?php echo "'" . __('Delete event') . "'"; ?>); + $("#delete-"+id + " img").attr ("data-use_title_for_force_title", 1); + $("#delete-"+id + " img").attr ("class", "forced_title"); + + // Change other buttons actions $("#validate-"+id).css("display", "none"); + $("#in-progress-"+id).css("display", "none"); $("#status_img_"+id).attr ("src", "images/tick.png"); - $("#status_img_"+id).attr ("title", <?php echo "'" . __('Event validated') . "'"; ?>); - $("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event validated') . "'"; ?>); + $("#status_img_"+id).attr ("data-title", <?php echo "'" . __('Event in process') . "'"; ?>); + $("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>); + $("#status_img_"+id).attr ("data-use_title_for_force_title", 1); + $("#status_img_"+id).attr ("class", "forced_title"); } // In process else if (new_status == 2) { // Change status description $("#status_row_"+id).html(<?php echo "'" . __('Event in process') . "'"; ?>); - // Remove delete link (if event is not grouped and there is more than one event) - if (grouped == 1) { - if (parseInt($("#count_event_group_"+id).text()) <= 1) { - $("#delete-"+id).replaceWith('<img alt="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" title="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" src="images/cross.disabled.png">'); - } - } - else { // Remove delete link (if event is not grouped) - $("#delete-"+id).replaceWith('<img alt="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" title="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" src="images/cross.disabled.png">'); - } - // Change state image - $("#status_img_"+id).attr ("src", "images/hourglass.png"); - $("#status_img_"+id).attr ("title", <?php echo "'" . __('Event in process') . "'"; ?>); + $("#status_img_"+id).attr ("src", hourglass_image); + $("#status_img_"+id).attr ("data-title", <?php echo "'" . __('Event in process') . "'"; ?>); $("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>); - + $("#status_img_"+id).attr ("data-use_title_for_force_title", 1); + $("#status_img_"+id).attr ("class", "forced_title"); + + // Change the actions buttons + $("#delete-"+id).remove(); + $("#in-progress-"+id).remove(); + // Format the new disabled delete icon. + $("#validate-"+id).parent().append("<img id='delete-" + id + "' src='" + cross_disabled_image + "' />"); + $("#delete-"+id).attr ("data-title", <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?>); + $("#delete-"+id).attr ("alt", <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?>); + $("#delete-"+id).attr ("data-use_title_for_force_title", 1); + $("#delete-"+id).attr ("class", "forced_title"); + // Remove row due to new state if (($("#status").val() == 0) || ($("#status").val() == 1)) { diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index c07364c0b1..04d0bd3154 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -87,7 +87,9 @@ switch ($config["dbtype"]) { case "postgresql": case "oracle": $sql = "SELECT * - FROM tevento + FROM tevento te + LEFT JOIN tagent_secondary_group tasg + ON te.id_grupo = tasg.id_group WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC"; break; @@ -97,9 +99,9 @@ $now = date ("Y-m-d"); // Show contentype header Header ("Content-type: text/txt"); -header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"'); +header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.csv"'); -echo "timestamp, agent, group, event, status, user, event_type, severity"; +echo "timestamp, agent, group, event, status, user, event_type, severity, id"; echo chr (13); $new = true; @@ -126,6 +128,8 @@ while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) { echo io_safe_output($event["event_type"]); echo ","; echo $event["criticity"]; + echo ","; + echo $event["id_evento"]; echo chr (13); } ?> diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 68c94f9c60..725ce6e601 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -96,6 +96,10 @@ if ($confMap !== false) { $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; break; + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; } $num_baselayer++; if ($mapC['default_map_connection'] == 1) { @@ -203,11 +207,7 @@ if ($layers != false) { // Resize GIS map on fullscreen ?> <script type="text/javascript"> - $().ready(function() { - - var new_height = $(document).height(); - $("#map").css("height", new_height - 60); - $("svg[id*=OpenLayers]").css("height", new_height - 60); - + $(document).ready(function() { + $("#map").css("height", $(document).height() - 100); }); </script> \ No newline at end of file diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 36e20bf709..9b4b8f65c8 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -77,6 +77,10 @@ if ($confMap !== false) { $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; break; + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; } $num_baselayer++; if ($mapC['default_map_connection'] == 1) { @@ -157,12 +161,12 @@ $buttons[]['text'] = ' ' . __('Show agents by state: ') . ui_print_page_header(__('Map') . " » " . __('Map') . " " . $map['map_name'], "images/op_gis.png", false, "", false, $buttons); -if ($config["pure"] == 0) { - echo "<div id='map' style='width: 100%; height: 500px; border: 1px solid black;' ></div>"; -} -else { - echo "<div id='map' style='position:absolute; top:40px; z-index:100; width: 100%; height: 500px; min-height:500px; border: 1px solid black;' ></div>"; -} +$map_inline_style = "width: 100%; min-height:500px; height: calc(100vh - 80px);"; +$map_inline_style .= $config["pure"] + ? "position:absolute; top: 80px; left: 0px;" + : "border: 1px solid black;"; + +echo '<div id="map" style="' . $map_inline_style . '" />'; gis_print_map('map', $map['zoom_level'], $map['initial_latitude'], $map['initial_longitude'], $baselayers, $controls); @@ -234,18 +238,11 @@ if ($layers != false) { gis_activate_ajax_refresh($layers, $timestampLastOperation); } -// Resize GIS map on fullscreen -if ($config["pure"] != 0) { - ?> - <script type="text/javascript"> - $().ready(function() { - - var new_height = $(document).height(); - $("#map").css("height", new_height - 60); - $("svg[id*=OpenLayers]").css("height", new_height - 60); - - }); - </script> - <?php -} ?> + +<script type="text/javascript"> + $(document).ready(function() { + var $map = $("#map"); + $map.css("height", "calc(100vh - " + $map.offset().top + "px - 20px)"); + }); +</script> diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index df24cd6dc2..ab1e7ca815 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.722 -%define release 180427 +%define release 180510 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 41ccffa2e6..9481056346 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.722 -%define release 180427 +%define release 180510 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 0e92ff7784..b274e7be53 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.722-180427 +Version: 7.0NG.722-180510 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 6a6bf5e511..9c7024b21d 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.722-180427" +pandora_version="7.0NG.722-180510" package_cpan=0 package_pandora=1 @@ -69,6 +69,7 @@ then mkdir -p temp_package/etc/init.d/ mkdir -p temp_package/lib/systemd/system/ mkdir -p temp_package/etc/pandora/ + mkdir -p temp_package/etc/tentacle/ mkdir -p temp_package/var/spool/pandora/data_in chmod 770 temp_package/var/spool/pandora/data_in mkdir -p temp_package/var/spool/pandora/data_in/conf @@ -82,6 +83,7 @@ then chmod 770 temp_package/var/spool/pandora/data_in/trans mkdir -p temp_package/var/log/pandora/ mkdir -p temp_package/usr/share/pandora_server/conf/ + mkdir -p temp_package/usr/share/tentacle_server/conf/ mkdir -p temp_package/usr/lib/perl5/ mkdir -p temp_package/usr/share/man/man1/ mkdir -p temp_package/etc/logrotate.d/ @@ -90,7 +92,8 @@ then cp -aRf bin/pandora_exec temp_package/usr/bin/pandora_exec.server cp -aRf bin/tentacle_server temp_package/usr/bin/ - cp -aRf conf/* temp_package/usr/share/pandora_server/conf/ + cp -aRf conf/pandora_* temp_package/usr/share/pandora_server/conf/ + cp -aRf conf/tentacle_* temp_package/usr/share/tentacle_server/conf/ cp -aRf util temp_package/usr/share/pandora_server/ cp -aRf lib/* temp_package/usr/lib/perl5/ cp -aRf AUTHORS COPYING README temp_package/usr/share/pandora_server/ diff --git a/pandora_server/DEBIAN/postinst b/pandora_server/DEBIAN/postinst index 0606e651c8..f25483eb62 100755 --- a/pandora_server/DEBIAN/postinst +++ b/pandora_server/DEBIAN/postinst @@ -71,7 +71,7 @@ chown -R pandora:www-data /var/spool/pandora/ echo "Creating setup directory in /etc/pandora" mkdir /etc/pandora 2> /dev/null -#Check if exist old conf file +#Check if exist old conf files if [ ! -e /etc/pandora/pandora_server.conf ] then cp /usr/share/pandora_server/conf/pandora_server.conf.new /etc/pandora/pandora_server.conf @@ -80,6 +80,14 @@ else cp /usr/share/pandora_server/conf/pandora_server.conf.new /etc/pandora/pandora_server.conf.new echo "Skipping creation of pandora_server.conf: there is already one." fi +if [ ! -e /etc/tentacle/tentacle_server.conf ] +then + cp /usr/share/tentacle_server/conf/tentacle_server.conf.new /etc/tentacle/tentacle_server.conf + chmod 664 /etc/tentacle/tentacle_server.conf +else + cp /usr/share/tentacle_server/conf/tentacle_server.conf.new /etc/tentacle/tentacle_server.conf.new + echo "Skipping creation of tentacle_server.conf: there is already one." +fi echo "Enabling start-up pandora & tentacle server daemons"; if [ -x `command -v systemctl` ]; then diff --git a/pandora_server/bin/tentacle_server b/pandora_server/bin/tentacle_server index 283324b5ff..d6b5d4d3bd 100755 --- a/pandora_server/bin/tentacle_server +++ b/pandora_server/bin/tentacle_server @@ -102,7 +102,7 @@ my $SERVICE_NAME="Tentacle Server"; my $SERVICE_PARAMS=join(' ', @ARGV); # Program version -our $VERSION = '0.6.1'; +our $VERSION = '0.6.2'; # IPv4 address to listen on my @t_addresses = ('0', '0.0.0.0'); @@ -217,6 +217,7 @@ sub print_help { print ("\t-d\t\tRun as daemon.\n"); print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n"); print ("\t-f ca_cert\tVerify that the peer certificate is signed by a ca.\n"); + print ("\t-F config_file\tConfiguration file full path.\n"); print ("\t-h\t\tShow help.\n"); print ("\t-I\t\tEnable insecure operations (file listing and moving).\n"); print ("\t-i\t\tFilters.\n"); @@ -278,11 +279,13 @@ sub daemonize { ################################################################################ sub parse_options { my %opts; + my $CONF = {}; + my $token_value; my $tmp; my @t_addresses_tmp; # Get options - if (getopts ('a:b:c:de:f:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { + if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) { print_help (); exit 1; } @@ -304,10 +307,16 @@ sub parse_options { } } + # Configuration file + if (defined($opts{'F'})) { + parse_config_file($opts{'F'}, $CONF); + } + # Address - if (defined ($opts{'a'})) { + $token_value = get_config_value($opts{'a'}, $CONF->{'addresses'}); + if (defined ($token_value)) { @t_addresses = (); - @t_addresses_tmp = split(/,/, $opts{'a'}); + @t_addresses_tmp = split(/,/, $token_value); foreach my $t_address (@t_addresses_tmp) { $t_address =~ s/^ *(.*?) *$/$1/; @@ -323,15 +332,17 @@ sub parse_options { } # Maximum simultaneous connections - if (defined ($opts{'c'})) { - $t_max_conn = $opts{'c'}; + $token_value = get_config_value($opts{'c'}, $CONF->{'max_connections'}); + if (defined ($token_value)) { + $t_max_conn = $token_value; if ($t_max_conn !~ /^\d+$/ || $t_max_conn < 1) { error ("Invalid number of maximum simultaneous connections."); } } # Run as daemon - if (defined ($opts{'d'})) { + $token_value = get_config_value($opts{'d'}, $CONF->{'daemon'}, 1); + if (defined ($token_value)) { if ($^ eq 'MSWin32') { error ("-d flag not available for this OS."); } @@ -340,11 +351,12 @@ sub parse_options { } # Enable SSL - if (defined ($opts{'e'})) { + $token_value = get_config_value($opts{'e'}, $CONF->{'ssl_cert'}); + if (defined ($token_value)) { require IO::Socket::SSL; - $t_ssl_cert = $opts{'e'}; + $t_ssl_cert = $token_value; if (! -f $t_ssl_cert) { error ("File $t_ssl_cert does not exist."); } @@ -353,21 +365,24 @@ sub parse_options { } # Verify peer certificate - if (defined ($opts{'f'})) { - $t_ssl_ca = $opts{'f'}; + $token_value = get_config_value($opts{'f'}, $CONF->{'ssl_ca'}); + if (defined ($token_value)) { + $t_ssl_ca = $token_value; if (! -f $t_ssl_ca) { error ("File $t_ssl_ca does not exist."); } } # Insecure mode - if (defined ($opts{'I'})) { + $token_value = get_config_value($opts{'I'}, $CONF->{'insecure'}, 1); + if (defined ($token_value)) { $t_insecure = 1; } # Filters (regexp:dir;regexp:dir...) - if (defined ($opts{'i'})) { - my @filters = split (';', $opts{'i'}); + $token_value = get_config_value($opts{'i'}, $CONF->{'filters'}); + if (defined ($token_value)) { + my @filters = split (';', $token_value); foreach my $filter (@filters) { my ($regexp, $dir) = split (':', $filter); next unless defined ($regexp) && defined ($dir); @@ -381,51 +396,58 @@ sub parse_options { } # SSL private key file - if (defined ($opts{'k'})) { - $t_ssl_key = $opts{'k'}; + $token_value = get_config_value($opts{'k'}, $CONF->{'ssl_key'}); + if (defined ($token_value)) { + $t_ssl_key = $token_value; if (! -f $t_ssl_key) { error ("File $t_ssl_key does not exist."); } } # Maximum file size - if (defined ($opts{'m'})) { - $t_max_size = $opts{'m'}; + $token_value = get_config_value($opts{'m'}, $CONF->{'max_size'}); + if (defined ($token_value)) { + $t_max_size = $token_value; if ($t_max_size !~ /^\d+$/ || $t_max_size < 1) { error ("Invalid maximum file size."); } } # File overwrite - if (defined ($opts{'o'})) { + $token_value = get_config_value($opts{'o'}, $CONF->{'overwrite'}, 1); + if (defined ($token_value)) { $t_overwrite = 1; } # Port - if (defined ($opts{'p'})) { - $t_port = $opts{'p'}; + $token_value = get_config_value($opts{'p'}, $CONF->{'port'}); + if (defined ($token_value)) { + $t_port = $token_value; if ($t_port !~ /^\d+$/ || $t_port < 1 || $t_port > 65535) { error ("Port $t_port is not valid."); } } # Quiet mode - if (defined ($opts{'q'})) { + $token_value = get_config_value($opts{'q'}, $CONF->{'quiet'}, 1); + if (defined ($token_value)) { $t_quiet = 1; } # Retries - if (defined ($opts{'r'})) { - $t_retries = $opts{'r'}; + $token_value = get_config_value($opts{'r'}, $CONF->{'retries'}); + if (defined ($token_value)) { + $t_retries = $token_value; if ($t_retries !~ /^\d+$/ || $t_retries < 1) { error ("Invalid number of retries for network operations."); } } # Storage directory - if (defined ($opts{'s'})) { + $token_value = get_config_value($opts{'s'}, $CONF->{'directory'}); + if (defined ($token_value)) { - $t_directory = $opts{'s'}; + $t_directory = $token_value; # Check that directory exists if (! -d $t_directory) { @@ -444,25 +466,36 @@ sub parse_options { } } else { - if (! defined($opts{'b'})) { + $token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'}); + if (! defined($token_value)) { print_help (); exit 1; } } # Timeout - if (defined ($opts{'t'})) { - $t_timeout = $opts{'t'}; + $token_value = get_config_value($opts{'t'}, $CONF->{'timeout'}); + if (defined ($token_value)) { + $t_timeout = $token_value; if ($t_timeout !~ /^\d+$/ || $t_timeout < 1) { error ("Invalid timeout for network operations."); } } + # Read verbose from config file + if (defined($CONF->{'verbose'})) { + if ($CONF->{'verbose'} eq "1") { + $t_log = 1; + } elsif ($CONF->{'verbose'} eq "2") { + $t_log = 1; + $t_log_hard = 1; + } + } # Be verbose if (defined ($opts{'v'})) { $t_log = 1; + $t_log_hard = 0; } - # Be verbose hard if (defined ($opts{'V'})) { $t_log = 1; @@ -470,18 +503,21 @@ sub parse_options { } # SSL private key password - if (defined ($opts{'w'})) { + $token_value = get_config_value($opts{'w'}, $CONF->{'ssl_password'}, 1); + if (defined ($token_value)) { $t_ssl_pwd = ask_passwd ("Enter private key file password: ", "Enter private key file password again for confirmation: "); } # Server password - if (defined ($opts{'x'})) { - $t_pwd = $opts{'x'}; + $token_value = get_config_value($opts{'x'}, $CONF->{'password'}); + if (defined ($token_value)) { + $t_pwd = $token_value; } #Proxy IP address - if (defined ($opts{'b'})) { - $t_proxy_ip = $opts{'b'}; + $token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'}); + if (defined ($token_value)) { + $t_proxy_ip = $token_value; if ($t_proxy_ip !~ /^[a-zA-Z\.]+$/ && ($t_proxy_ip !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ || $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255 || $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255) && @@ -491,15 +527,17 @@ sub parse_options { } # Proxy Port - if (defined ($opts{'g'})) { - $t_proxy_port = $opts{'g'}; + $token_value = get_config_value($opts{'g'}, $CONF->{'proxy_port'}); + if (defined ($token_value)) { + $t_proxy_port = $token_value; if ($t_proxy_port !~ /^\d+$/ || $t_proxy_port < 1 || $t_proxy_port > 65535) { error ("Proxy port $t_port is not valid."); } } # TCP wrappers support - if (defined ($opts{'T'})) { + $token_value = get_config_value($opts{'T'}, $CONF->{'use_libwrap'}, 1); + if (defined ($token_value)) { if ($t_libwrap_installed) { $t_use_libwrap = 1; } else { @@ -531,9 +569,76 @@ sub parse_options { } # Get the config file - if (defined ($opts{'l'})) { - $log_file = $opts{'l'}; + $token_value = get_config_value($opts{'l'}, $CONF->{'log_file'}); + if (defined ($token_value)) { + $log_file = $token_value; } + + # No command lines config values + + # Get the block size + if (defined ($CONF->{'block_size'})) { + if ($t_port !~ /^\d+$/ || $t_port < 1) { + error ("Invalid block size: " . $CONF->{'block_size'} . "."); + } + $t_block_size = $CONF->{'block_size'}; + } + + # Configuration file invalid chars + if (defined ($CONF->{'invalid_chars'})) { + $t_invalid_chars = $CONF->{'invalid_chars'}; + } +} + +################################################################################ +## SUB parse_config_file +## Get all options from a config file. +################################################################################ +sub parse_config_file { + my ($config_file, $CONF) = @_; + + # File should be writable + if (! -r $config_file) { + print "Configuration file $config_file is not readable.\n"; + return; + } + + # Open the file + my $FH; + if (! open ($FH, "< $config_file")) { + print "Cannot open configuration file $config_file.\n"; + return; + } + + # Read the file and only get the well formed lines + while (<$FH>) { + my $buffer_line = $_; + if ($buffer_line =~ /^[a-zA-Z]/){ # begins with letters + if ($buffer_line =~ m/([\w\-\_\.]+)\s+(.*)/){ + $CONF->{$1} = $2 unless $2 eq ""; + } + } + } + + close ($FH); + return; +} + +################################################################################ +## SUB parse_config_file +## Search in command line options and config hash from configuration file +## to get a value (command line is a priority) +################################################################################ +sub get_config_value { + my ($cmd_value, $conf_value, $bool) = @_; + $bool = 0 unless defined($bool); + + return $cmd_value if defined($cmd_value); + # The boolean type value is 1 or undef (0 should be translated like undefP) + if ($bool && defined($conf_value)) { + return undef if ($conf_value ne "1"); + } + return $conf_value; } ################################################################################ @@ -929,14 +1034,14 @@ sub recv_file { # Check file name if ($base_name =~ /[$t_invalid_chars]/) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " has an invalid file name"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (invalid file name)\n"); return; } # Check file size, empty files are not allowed if ($size < 1 || $size > $t_max_size) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " is too big"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (file is too big)\n"); return; } @@ -946,7 +1051,7 @@ sub recv_file { # Check if file exists if (-f $file && $t_overwrite == 0) { print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " already exists"); - send_data ("SEND ERR\n"); + send_data ("SEND ERR (file already exists)\n"); return; } @@ -979,7 +1084,7 @@ sub send_file { # Check file name if ($base_name =~ /[$t_invalid_chars]/) { print_log ("Requested file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name"); - send_data ("RECV ERR\n"); + send_data ("RECV ERR (file has an invalid file name)\n"); return; } @@ -989,7 +1094,7 @@ sub send_file { # Check if file exists if (! -f $file) { print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " does not exist"); - send_data ("RECV ERR\n"); + send_data ("RECV ERR (file does not exist)\n"); return; } diff --git a/pandora_server/bin/tentacle_server.exe b/pandora_server/bin/tentacle_server.exe index fc0522d9b0..a1b10c214f 100644 Binary files a/pandora_server/bin/tentacle_server.exe and b/pandora_server/bin/tentacle_server.exe differ diff --git a/pandora_server/conf/tentacle_server.conf.new b/pandora_server/conf/tentacle_server.conf.new new file mode 100644 index 0000000000..d4ebe4a71f --- /dev/null +++ b/pandora_server/conf/tentacle_server.conf.new @@ -0,0 +1,75 @@ +########################################################################## +# Tentacle Server Parameters +# See https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Tentacle +# for protocol description. +# Tentacle have IANA assigned port tpc/41121 as official port. +########################################################################## + +# [-a] IPv4 address to listen on. Several IPs cam be selected separating if by comma. +addresses 0.0.0.0 + +# [-p] Port to listen on +port 41121 + +# [-c] Maximum number of simultaneous connections +# max_connections 10 + +# [-d] Run as daemon. 1 true, 0 false +daemon 1 + +# [-i] Enable insecure mode +# insecure 0 + +# Filters (regexp:dir;regexp:dir...) +filters .*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans + +# [-m] Maximum file size allowed by the server in bytes +#max_size 2000000 + +# [-o] Accept files with a repeated name +# overwrite 0 + +# [-q] Do not output error messages. +# quiet 0 + +# [-r] Number of retries for socket read/write operations +# retries 3 + +# [-s] Storage directory +directory /var/spool/pandora/data_in + +# [-b] Address to proxy client requests to +# proxy_ip 127.0.0.1 + +# [-g] Port to proxy client requests to +# proxy_port 41121 + +# [-t] Timeout for socket read/write operations in seconds +# timeout 1 + +# [-v and -V] Verbose level +# 0: Do not display any informative messages +# 1: Display only important messages [-v] +# 2: Display all messages [-V] +# verbose 0 + +# [-l] Log file +log_file /dev/null + +# [-x] Server password +# password PASSWORD + +# [-e] SSL certificate file full path +# ssl_cert /path/to/ssl/cert + +# [-f] SSL CA file full path +# ssl_ca /path/to/ssl/ca + +# [-k] SSL private key file +# ssl_key /path/to/private/key/file + +# [-w] SSL password. Set to 1 to ask for password by command line +# ssl_password 0 + +# [-T] Use libwrap library (Authen::Libwrap perl module) +# use_libwrap 0 \ No newline at end of file diff --git a/pandora_server/extras/.gitignore b/pandora_server/extras/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 85ea844a12..2bf1e44a28 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -43,7 +43,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.722"; -my $pandora_build = "180427"; +my $pandora_build = "180510"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index be949002f1..52c87c2717 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -31,7 +31,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.722"; -my $pandora_build = "180427"; +my $pandora_build = "180510"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index caab4eb6e4..7d3f6e4322 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.722 -%define release 180427 +%define release 180510 Summary: Pandora FMS Server Name: %{name} @@ -48,6 +48,7 @@ rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{_bindir}/ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pandora/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/tentacle/ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/spool/pandora/data_in mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/spool/pandora/data_in/conf mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/spool/pandora/data_in/md5 @@ -81,6 +82,7 @@ rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/recon_scripts/PandoraFMS install -m 0644 util/pandora_server_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_server install -m 0640 conf/pandora_server.conf.new $RPM_BUILD_ROOT%{_sysconfdir}/pandora/pandora_server.conf.new +install -m 0640 conf/tentacle_server.conf.new $RPM_BUILD_ROOT%{_sysconfdir}/tentacle/tentacle_server.conf.new mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d chmod 0750 $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d @@ -119,8 +121,8 @@ if [ "$1" = 1 ]; then echo " " fi -# This will avoid pandora_server.conf overwritting on UPGRADES. - +# This will avoid confi files overwritting on UPGRADES. +# Main configuration file if [ ! -e "/etc/pandora/pandora_server.conf" ] then echo "Creating a new version of Pandora FMS Server config file at /etc/pandora/pandora_server.conf" @@ -130,6 +132,12 @@ else echo "An existing version of pandora_server.conf is found." cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old fi +# Tentacle server +if [ ! -e "/etc/tentacle/tentacle_server.conf" ] +then + echo "Creating a new version of Tentacle Server config file at /etc/tentacle/tentacle_server.conf" + cat /etc/tentacle/tentacle_server.conf.new > /etc/tentacle/tentacle_server.conf +fi echo "Don't forget to start Tentacle Server daemon if you want to receive" echo "data using tentacle" @@ -175,6 +183,9 @@ exit 0 %defattr(600,root,root) /etc/pandora/pandora_server.conf.new +%defattr(664,root,root) +/etc/tentacle/tentacle_server.conf.new + %defattr(-,pandora,apache,2770) %{_localstatedir}/spool/pandora %{_localstatedir}/spool/pandora/data_in diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index cfdb35b9a5..812ad41c00 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.722 -%define release 180427 +%define release 180510 Summary: Pandora FMS Server Name: %{name} @@ -54,6 +54,7 @@ mkdir -p $RPM_BUILD_ROOT/usr/bin/ mkdir -p $RPM_BUILD_ROOT/usr/sbin/ mkdir -p $RPM_BUILD_ROOT/etc/init.d/ mkdir -p $RPM_BUILD_ROOT/etc/pandora/ +mkdir -p $RPM_BUILD_ROOT/etc/tentacle/ mkdir -p $RPM_BUILD_ROOT/var/spool/pandora/data_in mkdir -p $RPM_BUILD_ROOT/var/spool/pandora/data_in/conf mkdir -p $RPM_BUILD_ROOT/var/spool/pandora/data_in/md5 @@ -62,6 +63,7 @@ mkdir -p $RPM_BUILD_ROOT/var/spool/pandora/data_in/netflow mkdir -p $RPM_BUILD_ROOT/var/spool/pandora/data_in/trans mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_server/conf/ +mkdir -p $RPM_BUILD_ROOT%{prefix}/tentacle/conf/ mkdir -p $RPM_BUILD_ROOT/usr/lib/perl5/ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ @@ -70,8 +72,10 @@ cp -aRf bin/pandora_server $RPM_BUILD_ROOT/usr/bin/ cp -aRf bin/pandora_exec $RPM_BUILD_ROOT/usr/bin/ cp -aRf bin/tentacle_server $RPM_BUILD_ROOT/usr/bin/ -cp -aRf conf/* $RPM_BUILD_ROOT%{prefix}/pandora_server/conf/ +cp -aRf conf/pandora_* $RPM_BUILD_ROOT%{prefix}/pandora_server/conf/ cp -aRf conf/pandora_server.conf.new $RPM_BUILD_ROOT/etc/pandora/ +cp -aRf conf/tentacle_* $RPM_BUILD_ROOT%{prefix}/tentacle/conf/ +cp -aRf conf/tentacle_server.conf.new $RPM_BUILD_ROOT/etc/tentacle/ cp -aRf util $RPM_BUILD_ROOT%{prefix}/pandora_server/ cp -aRf lib/* $RPM_BUILD_ROOT/usr/lib/perl5/ cp -aRf AUTHORS COPYING README $RPM_BUILD_ROOT%{prefix}/pandora_server/ @@ -112,6 +116,8 @@ if [ ! -d /etc/pandora ] ; then mkdir -p /etc/pandora fi +# Avoid to overwrite config files on upgrades +# Main configuration files if [ ! -e "/etc/pandora/pandora_server.conf" ] then echo "Creating a new version of Pandora FMS Server config file at /etc/pandora/pandora_server.conf" @@ -121,6 +127,12 @@ else echo "An existing version of pandora_server.conf is found." cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old fi +# Tentacle config files +if [ ! -e "/etc/tentacle/tentacle_server.conf" ] +then + echo "Creating a new version of Tentacle Server config file at /etc/tentacle/tentacle_server.conf" + cat /etc/tentacle/tentacle_server.conf.new > /etc/tentacle/tentacle_server.conf +fi echo "Don't forget to start Tentacle Server daemon if you want to receive" echo "data using tentacle" @@ -152,6 +164,7 @@ rm -Rf %{prefix}pandora_server rm -Rf /var/log/pandora rm -Rf /usr/lib/perl5/PandoraFMS/ rm -Rf /etc/pandora/pandora_server.conf* +rm -Rf /etc/tentacle/tentacle_server.conf* rm -Rf /var/spool/pandora rm -Rf /etc/init.d/pandora_server /etc/init.d/tentacle_serverd rm -Rf /usr/bin/pandora_exec /usr/bin/pandora_server /usr/bin/tentacle_server @@ -174,6 +187,7 @@ rm -Rf /usr/share/man/man1/tentacle_server.1.gz %defattr(755,pandora,root,755) /usr/lib/perl5/PandoraFMS/ %{prefix}/pandora_server +%{prefix}/tentacle /var/log/pandora %defattr(-,pandora,www,2770) @@ -188,6 +202,9 @@ rm -Rf /usr/share/man/man1/tentacle_server.1.gz %defattr(-,pandora,root,750) /etc/pandora +%defattr(-,pandora,root,754) +/etc/tentacle + %defattr(644,pandora,root) /usr/share/man/man1/pandora_server.1.gz /usr/share/man/man1/tentacle_server.1.gz diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 0a59ec0ac3..b51199705a 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.722" -PI_BUILD="180427" +PI_BUILD="180510" MODE=$1 if [ $# -gt 1 ]; then @@ -27,6 +27,9 @@ TENTACLE_SERVER=/etc/init.d/tentacle_serverd PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf PANDORA_CFG_FILE_DIST=conf/pandora_server.conf.new PANDORA_INIT_SCRIPT=util/pandora_server +TENTACLE_CFG_DIR=/etc/tentacle +TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf +TENTACLE_CFG_FILE_DIST=conf/tentacle_server.conf.new TENTACLE_INIT_SCRIPT=util/tentacle_serverd PERL=perl MANDIR=$PREFIX/share/man/man1 @@ -91,6 +94,8 @@ set_global_vars () { PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf PANDORA_CFG_FILE_DIST=$DISTRO/pandora_server.conf.new PANDORA_INIT_SCRIPT=$DISTRO/pandora_server + TENTACLE_CFG_DIR=$PREFIX/etc/tentacle + TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server MANDIR=$PREFIX/man/man1 INITDIR=$PREFIX/etc/rc.d @@ -103,6 +108,8 @@ set_global_vars () { PANDORA_HOME=$PREFIX/share/pandora_server PANDORA_CFG_DIR=$PREFIX/etc/pandora PANDORA_SERVER=/etc/rc.d/pandora_server + TENTACLE_CFG_DIR=$PREFIX/etc/tentacle + TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf TENTACLE_SERVER=/etc/rc.d/tentacle_server PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf PANDORA_CFG_FILE_DIST=$DISTRO/pandora_server.conf.new @@ -361,6 +368,19 @@ install () { then # tentacle_server is already installed by "make install" install_startup_script -s 80 $TENTACLE_INIT_SCRIPT + + # Create the directory to locate the Tentacle configuration file + echo "Creating setup Tentacle directory in $TENTACLE_CFG_DIR" + mkdir -p $DESTDIR$TENTACLE_CFG_DIR 2> /dev/null + if [ -f "$DESTDIR$TENTACLE_CFG_FILE" ] + then + echo cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_DIR + cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_DIR + else + echo cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_FILE + cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_FILE + chmod 774 $DESTDIR$TENTACLE_CFG_FILE + fi echo "Installing Tentacle Server manual" cp man/man1/tentacle_server.1.gz $DESTDIR$MANDIR @@ -457,6 +477,8 @@ uninstall () { rm -Rf $DESTDIR$PANDORA_LOG 2> /dev/null rm -f $DESTDIR$PANDORA_CFG_FILE 2> /dev/null rm -f "$DESTDIR$PANDORA_CFG_FILE.new" 2> /dev/null + rm -f $DESTDIR$TENTACLE_CFG_FILE 2> /dev/null + rm -f "$DESTDIR$TENTACLE_CFG_FILE.new" 2> /dev/null rm -f $DESTDIR$PANDORA_SERVER 2> /dev/null rm -f $DESTDIR$PREFIX/bin/pandora_server 2> /dev/null rm -f $DESTDIR$PREFIX/bin/pandora_exec 2> /dev/null diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index c552d48c2e..e88931feee 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.722 PS180427"; +my $version = "7.0NG.722 PS180510"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index bd5937a596..bba9b996a7 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.722 PS180427"; +my $version = "7.0NG.722 PS180510"; # save program name for logging my $progname = basename($0); diff --git a/pandora_server/util/tentacle_serverd b/pandora_server/util/tentacle_serverd index fdfe3e0d67..0c0f35ff97 100755 --- a/pandora_server/util/tentacle_serverd +++ b/pandora_server/util/tentacle_serverd @@ -57,7 +57,7 @@ function get_pid { # in a "strech" term, ps aux don't report more than COLUMNS # characters and this will not work. COLUMNS=300 - TENTACLE_PID=`ps -Af | grep "$TENTACLE_PATH$TENTACLE_DAEMON" | grep "$TENTACLE_PORT" | grep -v grep | tail -1 | awk '{ print $2 }'` + TENTACLE_PID=`ps -Af | grep "$TENTACLE_PATH$TENTACLE_DAEMON" | grep "$TENTACLE_CONFIG_FILE" | grep -v grep | tail -1 | awk '{ print $2 }'` echo $TENTACLE_PID } @@ -71,18 +71,12 @@ function get_all_pid { echo $TENTACLE_PID } -# Pandora server settings -PANDORA_SERVER_PATH="/var/spool/pandora/data_in" - # Tentacle server settings TENTACLE_DAEMON="tentacle_server" TENTACLE_PATH="/usr/bin" TENTACLE_USER="pandora" - -TENTACLE_ADDR="0.0.0.0" -TENTACLE_PORT="41121" -TENTACLE_EXT_OPTS="-i.*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans" -TENTACLE_LOG_FILE="/dev/null" +TENTACLE_CONFIG_FILE="/etc/tentacle/tentacle_server.conf" +TENTACLE_EXT_OPTS="" # Set umask to 0002, because group MUST have access to write files to # use remote file management on Pandora FMS Enterprise. @@ -90,7 +84,7 @@ TENTACLE_LOG_FILE="/dev/null" umask 0007 # Main script -TENTACLE_OPTS="-a $TENTACLE_ADDR -p $TENTACLE_PORT -s $PANDORA_SERVER_PATH $TENTACLE_EXT_OPTS -d -l $TENTACLE_LOG_FILE -v" +TENTACLE_OPTS="-F $TENTACLE_CONFIG_FILE $TENTACLE_EXT_OPTS" # Fix TENTACLE_PATH case "$TENTACLE_PATH" in @@ -114,7 +108,8 @@ case "$1" in echo "Tentacle Server is already running with PID $TENTACLE_PID" rc_exit # running start on a service already running fi - + + # Init the tentacle process sudo -u $TENTACLE_USER ${TENTACLE_PATH}$TENTACLE_DAEMON $TENTACLE_OPTS sleep 1 @@ -124,7 +119,7 @@ case "$1" in rc_status -v else echo "Tentacle Server could not be started." - echo "Verify that port $TENTACLE_PORT is not used." + echo "Verify that Tentacle port is not used." rc_failed 7 # program not running fi diff --git a/pandora_server/util/tentacle_serverd.service b/pandora_server/util/tentacle_serverd.service index 488bc3d4a8..e5c3bfad3e 100644 --- a/pandora_server/util/tentacle_serverd.service +++ b/pandora_server/util/tentacle_serverd.service @@ -4,7 +4,7 @@ After=network-online.target [Service] Type=forking -ExecStart=/usr/bin/tentacle_server -a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf;.*\.md5:md5;.*\.zip:collections -d +ExecStart=/usr/bin/tentacle_server -F /etc/tentacle/tentacle_server.conf User=pandora [Install]