2009-08-27 Ramon Novoa <rnovoa@artica.es>

* util/tentacle_serverd: Remote config .conf and
          .md5 files are now stored in different subdirectories.

        * bin/tentacle_server: Updated to latest version.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1887 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2009-08-27 17:47:50 +00:00
parent f8e6683426
commit 9cd4939586
3 changed files with 51 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2009-08-27 Ramon Novoa <rnovoa@artica.es>
* util/tentacle_serverd: Remote config .conf and
.md5 files are now stored in different subdirectories.
* bin/tentacle_server: Updated to latest version.
2009-08-25 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Fixed compound alerts.

View File

@ -29,7 +29,7 @@ use Thread::Semaphore;
use POSIX ":sys_wait_h";
# Program version
our $VERSION = '0.2.0';
our $VERSION = '0.2.1';
# Address to listen on
my $t_address = '0.0.0.0';
@ -46,6 +46,9 @@ my $t_daemon = 0;
# Storage directory
my $t_directory = '';
# Filters
my %t_filters;
# String containing quoted invalid file name characters
my $t_invalid_chars = '\?\[\]\/\\\=\+\<\>\:\;\'\,\*\~';
@ -115,6 +118,7 @@ sub print_help {
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-h\t\tShow help.\n");
print ("\t-i\t\tFilters.\n");
print ("\t-k key\t\tOpenSSL private key file.\n");
print ("\t-m size\t\tMaximum file size in bytes (default ${t_max_size}b).\n");
print ("\t-o\t\tEnable file overwrite.\n");
@ -190,7 +194,7 @@ sub parse_options {
my $tmp;
# Get options
if (getopts ('a:c:de:f:hk:m:op:qr:s:t:vwx:', \%opts) == 0 || defined ($opts{'h'})) {
if (getopts ('a:c:de:f:hi:k:m:op:qr:s:t:vwx:', \%opts) == 0 || defined ($opts{'h'})) {
print_help ();
exit 1;
}
@ -243,6 +247,21 @@ sub parse_options {
}
}
# Filters (regexp:dir;regexp:dir...)
if (defined ($opts{'i'})) {
my @filters = split (';', $opts{'i'});
foreach my $filter (@filters) {
my ($regexp, $dir) = split (':', $filter);
next unless defined ($regexp) && defined ($dir);
# Remove any trailing /
my $char = chop ($dir);
$dir .= $char if ($char) ne '/';
$t_filters{$regexp} = $dir;
}
}
# SSL private key file
if (defined ($opts{'k'})) {
$t_ssl_key = $opts{'k'};
@ -571,7 +590,8 @@ sub recv_file {
return;
}
$file = "$t_directory/$base_name";
# Apply filters
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
# Check if file exists
if (-f $file && $t_overwrite == 0) {
@ -613,7 +633,8 @@ sub send_file {
return;
}
$file = "$t_directory/$base_name";
# Apply filters
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
# Check if file exists
if (! -f $file) {
@ -856,6 +877,23 @@ sub ask_passwd {
return $pwd1;
}
################################################################################
## SUB apply_filters
## Applies filters to the given file.
################################################################################
sub apply_filters ($) {
my ($file_name) = @_;
while (my ($regexp, $dir) = each (%t_filters)) {
if ($file_name =~ /$regexp/) {
print_log ("File '$file_name' matches filter '$regexp' (changing to directory '$dir')");
return $dir . '/';
}
}
return '';
}
################################################################################
# Main
################################################################################

View File

@ -3,7 +3,7 @@
# Tentacle server simple startup script
# Copyright (c) 2007 Artica Soluciones Tecnologicas S.L.
# Linux Version (generic)
# v0.1 Build 210508
# v0.1 Build 090827
### BEGIN INIT INTO
# Provides: tentacle_server
@ -24,7 +24,7 @@ TENTACLE_USER="pandora"
TENTACLE_ADDR="0.0.0.0"
TENTACLE_PORT="41121"
TENTACLE_EXT_OPTS=""
TENTACLE_EXT_OPTS="-i.*\.conf:conf;.*\.md5:md5"
# Set umask to 0002, because group MUST have access to write files to
# use remote file management on Pandora FMS Enterprise.