mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Merge remote-tracking branch 'origin/develop' into 2226-Analisis_de_causa_raiz_en_alertas_mediante_los_servicios
This commit is contained in:
commit
4c7c248671
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -58,6 +58,8 @@ use strict;
|
|||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
||||||
my $SOCKET_MODULE =
|
my $SOCKET_MODULE =
|
||||||
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
||||||
@ -131,6 +133,12 @@ my $t_ssl_pwd = '';
|
|||||||
# Timeout for socket read/write operations in seconds
|
# Timeout for socket read/write operations in seconds
|
||||||
my $t_timeout = 1;
|
my $t_timeout = 1;
|
||||||
|
|
||||||
|
# bind ipaddr
|
||||||
|
my $t_bind_address = undef;
|
||||||
|
|
||||||
|
# Compress data before sending it through the socket.
|
||||||
|
my $t_zip = 0;
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB print_help
|
## SUB print_help
|
||||||
## Print help screen.
|
## Print help screen.
|
||||||
@ -141,6 +149,7 @@ sub print_help {
|
|||||||
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
||||||
print ("Options:\n");
|
print ("Options:\n");
|
||||||
print ("\t-a address\tServer address (default $t_address).\n");
|
print ("\t-a address\tServer address (default $t_address).\n");
|
||||||
|
print ("\t-b localaddress\tLocal address to bind.\n");
|
||||||
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
||||||
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
||||||
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
||||||
@ -154,7 +163,8 @@ sub print_help {
|
|||||||
print ("\t-v\t\tBe verbose.\n");
|
print ("\t-v\t\tBe verbose.\n");
|
||||||
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
||||||
print ("\t-x pwd\t\tServer password.\n");
|
print ("\t-x pwd\t\tServer password.\n");
|
||||||
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n\n");
|
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n");
|
||||||
|
print ("\t-z Compress data.\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -166,7 +176,7 @@ sub parse_options {
|
|||||||
my $tmp;
|
my $tmp;
|
||||||
|
|
||||||
# Get options
|
# Get options
|
||||||
if (getopts ('a:ce:f:ghk:p:qr:t:vwx:y:', \%opts) == 0 || defined ($opts{'h'})) {
|
if (getopts ('a:b:ce:f:ghk:p:qr:t:vwx:y:z', \%opts) == 0 || defined ($opts{'h'})) {
|
||||||
print_help ();
|
print_help ();
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@ -183,6 +193,18 @@ sub parse_options {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Bind local address
|
||||||
|
if (defined ($opts{'b'})) {
|
||||||
|
$t_bind_address = $opts{'b'};
|
||||||
|
if (($t_bind_address !~ /^[a-zA-Z\.][a-zA-Z0-9\.\-]+$/ && ($t_bind_address !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
||||||
|
|| $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255
|
||||||
|
|| $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255)) &&
|
||||||
|
($t_address !~ /^[0-9a-f:]+$/o)) {
|
||||||
|
error ("Local address $t_bind_address is not valid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Enable SSL without a client certificate
|
# Enable SSL without a client certificate
|
||||||
if (defined ($opts{'c'})) {
|
if (defined ($opts{'c'})) {
|
||||||
require IO::Socket::SSL;
|
require IO::Socket::SSL;
|
||||||
@ -299,6 +321,11 @@ sub parse_options {
|
|||||||
error ("Proxy port $t_proxy_port is not valid.");
|
error ("Proxy port $t_proxy_port is not valid.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Compress data
|
||||||
|
if (defined ($opts{'z'})) {
|
||||||
|
$t_zip = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -309,20 +336,42 @@ sub start_client {
|
|||||||
|
|
||||||
# Connect to server
|
# Connect to server
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -344,18 +393,38 @@ sub start_client_proxy {
|
|||||||
|
|
||||||
# Connect to proxy
|
# Connect to proxy
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -408,6 +477,8 @@ sub start_ssl {
|
|||||||
if ($t_ssl_cert eq ''){
|
if ($t_ssl_cert eq ''){
|
||||||
IO::Socket::SSL->start_SSL (
|
IO::Socket::SSL->start_SSL (
|
||||||
$t_socket,
|
$t_socket,
|
||||||
|
# No authentication
|
||||||
|
SSL_verify_mode => 0x00,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif ($t_ssl_ca eq '') {
|
elsif ($t_ssl_ca eq '') {
|
||||||
@ -525,6 +596,46 @@ sub recv_file {
|
|||||||
print_log ("Received file '$file'");
|
print_log ("Received file '$file'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file from the server
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $data = '';
|
||||||
|
my $file = $_[0];
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# Request file
|
||||||
|
send_data ("ZRECV <$file>\n");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response !~ /^ZRECV SIZE (\d+)$/) {
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = $1;
|
||||||
|
send_data ("ZRECV OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZRECV ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
print_log ("Received compressed file '$file'");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the server
|
## Send a file to the server
|
||||||
@ -578,6 +689,55 @@ sub send_file {
|
|||||||
print_log ("File sent");
|
print_log ("File sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the server (compressed)
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name;
|
||||||
|
my $data = '';
|
||||||
|
my $response = '';
|
||||||
|
my $retries;
|
||||||
|
my $file = $_[0];
|
||||||
|
my $size;
|
||||||
|
my $written;
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
$base_name = basename ($file);
|
||||||
|
|
||||||
|
# Request to send file
|
||||||
|
send_data ("ZSEND <$base_name> SIZE $size\n");
|
||||||
|
print_log ("Request to send file '$base_name' size ${size}b (compressed)");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
|
||||||
|
# Server rejected the file
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("Server responded SEND OK");
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("File sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -830,13 +990,21 @@ if ($t_recv == 0) {
|
|||||||
|
|
||||||
# Send the files
|
# Send the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
send_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zsend_file($file);
|
||||||
|
} else {
|
||||||
|
send_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Send the files
|
# Receive the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
recv_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zrecv_file ($file);
|
||||||
|
} else {
|
||||||
|
recv_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,6 +1050,8 @@ __END__
|
|||||||
|
|
||||||
=item I<-x pwd> B<Server password>.
|
=item I<-x pwd> B<Server password>.
|
||||||
|
|
||||||
|
=item I<-z> Compress data.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 EXIT STATUS
|
=head1 EXIT STATUS
|
||||||
|
@ -60,6 +60,8 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use threads;
|
use threads;
|
||||||
use Thread::Semaphore;
|
use Thread::Semaphore;
|
||||||
use POSIX ":sys_wait_h";
|
use POSIX ":sys_wait_h";
|
||||||
@ -959,6 +961,15 @@ sub serve_connection {
|
|||||||
print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
|
print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
|
||||||
send_file ($1);
|
send_file ($1);
|
||||||
}
|
}
|
||||||
|
elsif ($command =~ /^ZSEND <(.*)> SIZE (\d+)$/) {
|
||||||
|
print_info ("Request to send compressed file '$1' size ${2}b from " . $t_client_socket->sockhost ());
|
||||||
|
zrecv_file ($1, $2);
|
||||||
|
}
|
||||||
|
# Client wants to receive a file
|
||||||
|
elsif ($command =~ /^ZRECV <(.*)>$/) {
|
||||||
|
print_info ("Request to receive compressed file '$1' from " . $t_client_socket->sockhost ());
|
||||||
|
zsend_file ($1);
|
||||||
|
}
|
||||||
# Quit
|
# Quit
|
||||||
elsif ($command =~ /^QUIT$/) {
|
elsif ($command =~ /^QUIT$/) {
|
||||||
print_info ("Connection closed from " . $t_client_socket->sockhost ());
|
print_info ("Connection closed from " . $t_client_socket->sockhost ());
|
||||||
@ -1070,6 +1081,61 @@ sub recv_file {
|
|||||||
print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file of size $_[1] and save it in $t_directory as $_[0].
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $base_name = $_[0];
|
||||||
|
my $data = '';
|
||||||
|
my $file;
|
||||||
|
my $size = $_[1];
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# 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 ("ZSEND 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 ("ZSEND ERR (file is too big)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
|
||||||
|
|
||||||
|
# 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 ("ZSEND ERR (file already exists)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
send_data ("ZSEND OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZSEND ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
send_data ("ZSEND OK\n");
|
||||||
|
print_info ("Received compressed file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the client
|
## Send a file to the client
|
||||||
@ -1122,6 +1188,57 @@ sub send_file {
|
|||||||
print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
|
print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the client
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name = $_[0];
|
||||||
|
my $data = '';
|
||||||
|
my $file;
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
|
||||||
|
# Check file name
|
||||||
|
if ($base_name =~ /[$t_invalid_chars]/) {
|
||||||
|
print_log ("Requested compressed file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name");
|
||||||
|
send_data ("ZRECV ERR (file has an invalid file name)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if (! -f $file) {
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " does not exist");
|
||||||
|
send_data ("ZRECV ERR (file does not exist)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
send_data ("ZRECV SIZE $size\n");
|
||||||
|
|
||||||
|
# Wait for client response
|
||||||
|
$response = recv_command ($t_block_size);
|
||||||
|
if ($response ne "ZRECV OK") {
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " not sent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the file
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -58,6 +58,8 @@ use strict;
|
|||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
||||||
my $SOCKET_MODULE =
|
my $SOCKET_MODULE =
|
||||||
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
||||||
@ -131,6 +133,12 @@ my $t_ssl_pwd = '';
|
|||||||
# Timeout for socket read/write operations in seconds
|
# Timeout for socket read/write operations in seconds
|
||||||
my $t_timeout = 1;
|
my $t_timeout = 1;
|
||||||
|
|
||||||
|
# bind ipaddr
|
||||||
|
my $t_bind_address = undef;
|
||||||
|
|
||||||
|
# Compress data before sending it through the socket.
|
||||||
|
my $t_zip = 0;
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB print_help
|
## SUB print_help
|
||||||
## Print help screen.
|
## Print help screen.
|
||||||
@ -141,6 +149,7 @@ sub print_help {
|
|||||||
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
||||||
print ("Options:\n");
|
print ("Options:\n");
|
||||||
print ("\t-a address\tServer address (default $t_address).\n");
|
print ("\t-a address\tServer address (default $t_address).\n");
|
||||||
|
print ("\t-b localaddress\tLocal address to bind.\n");
|
||||||
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
||||||
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
||||||
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
||||||
@ -154,7 +163,8 @@ sub print_help {
|
|||||||
print ("\t-v\t\tBe verbose.\n");
|
print ("\t-v\t\tBe verbose.\n");
|
||||||
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
||||||
print ("\t-x pwd\t\tServer password.\n");
|
print ("\t-x pwd\t\tServer password.\n");
|
||||||
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n\n");
|
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n");
|
||||||
|
print ("\t-z Compress data.\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -166,7 +176,7 @@ sub parse_options {
|
|||||||
my $tmp;
|
my $tmp;
|
||||||
|
|
||||||
# Get options
|
# Get options
|
||||||
if (getopts ('a:ce:f:ghk:p:qr:t:vwx:y:', \%opts) == 0 || defined ($opts{'h'})) {
|
if (getopts ('a:b:ce:f:ghk:p:qr:t:vwx:y:z', \%opts) == 0 || defined ($opts{'h'})) {
|
||||||
print_help ();
|
print_help ();
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@ -183,6 +193,18 @@ sub parse_options {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Bind local address
|
||||||
|
if (defined ($opts{'b'})) {
|
||||||
|
$t_bind_address = $opts{'b'};
|
||||||
|
if (($t_bind_address !~ /^[a-zA-Z\.][a-zA-Z0-9\.\-]+$/ && ($t_bind_address !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
||||||
|
|| $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255
|
||||||
|
|| $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255)) &&
|
||||||
|
($t_address !~ /^[0-9a-f:]+$/o)) {
|
||||||
|
error ("Local address $t_bind_address is not valid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Enable SSL without a client certificate
|
# Enable SSL without a client certificate
|
||||||
if (defined ($opts{'c'})) {
|
if (defined ($opts{'c'})) {
|
||||||
require IO::Socket::SSL;
|
require IO::Socket::SSL;
|
||||||
@ -299,6 +321,11 @@ sub parse_options {
|
|||||||
error ("Proxy port $t_proxy_port is not valid.");
|
error ("Proxy port $t_proxy_port is not valid.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Compress data
|
||||||
|
if (defined ($opts{'z'})) {
|
||||||
|
$t_zip = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -309,20 +336,42 @@ sub start_client {
|
|||||||
|
|
||||||
# Connect to server
|
# Connect to server
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -344,18 +393,38 @@ sub start_client_proxy {
|
|||||||
|
|
||||||
# Connect to proxy
|
# Connect to proxy
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -408,6 +477,8 @@ sub start_ssl {
|
|||||||
if ($t_ssl_cert eq ''){
|
if ($t_ssl_cert eq ''){
|
||||||
IO::Socket::SSL->start_SSL (
|
IO::Socket::SSL->start_SSL (
|
||||||
$t_socket,
|
$t_socket,
|
||||||
|
# No authentication
|
||||||
|
SSL_verify_mode => 0x00,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif ($t_ssl_ca eq '') {
|
elsif ($t_ssl_ca eq '') {
|
||||||
@ -525,6 +596,46 @@ sub recv_file {
|
|||||||
print_log ("Received file '$file'");
|
print_log ("Received file '$file'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file from the server
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $data = '';
|
||||||
|
my $file = $_[0];
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# Request file
|
||||||
|
send_data ("ZRECV <$file>\n");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response !~ /^ZRECV SIZE (\d+)$/) {
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = $1;
|
||||||
|
send_data ("ZRECV OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZRECV ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
print_log ("Received compressed file '$file'");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the server
|
## Send a file to the server
|
||||||
@ -578,6 +689,55 @@ sub send_file {
|
|||||||
print_log ("File sent");
|
print_log ("File sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the server (compressed)
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name;
|
||||||
|
my $data = '';
|
||||||
|
my $response = '';
|
||||||
|
my $retries;
|
||||||
|
my $file = $_[0];
|
||||||
|
my $size;
|
||||||
|
my $written;
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
$base_name = basename ($file);
|
||||||
|
|
||||||
|
# Request to send file
|
||||||
|
send_data ("ZSEND <$base_name> SIZE $size\n");
|
||||||
|
print_log ("Request to send file '$base_name' size ${size}b (compressed)");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
|
||||||
|
# Server rejected the file
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("Server responded SEND OK");
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("File sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -830,13 +990,21 @@ if ($t_recv == 0) {
|
|||||||
|
|
||||||
# Send the files
|
# Send the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
send_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zsend_file($file);
|
||||||
|
} else {
|
||||||
|
send_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Send the files
|
# Receive the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
recv_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zrecv_file ($file);
|
||||||
|
} else {
|
||||||
|
recv_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,6 +1050,8 @@ __END__
|
|||||||
|
|
||||||
=item I<-x pwd> B<Server password>.
|
=item I<-x pwd> B<Server password>.
|
||||||
|
|
||||||
|
=item I<-z> Compress data.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 EXIT STATUS
|
=head1 EXIT STATUS
|
||||||
|
@ -58,6 +58,8 @@ use strict;
|
|||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
||||||
my $SOCKET_MODULE =
|
my $SOCKET_MODULE =
|
||||||
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
||||||
@ -131,6 +133,12 @@ my $t_ssl_pwd = '';
|
|||||||
# Timeout for socket read/write operations in seconds
|
# Timeout for socket read/write operations in seconds
|
||||||
my $t_timeout = 1;
|
my $t_timeout = 1;
|
||||||
|
|
||||||
|
# bind ipaddr
|
||||||
|
my $t_bind_address = undef;
|
||||||
|
|
||||||
|
# Compress data before sending it through the socket.
|
||||||
|
my $t_zip = 0;
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB print_help
|
## SUB print_help
|
||||||
## Print help screen.
|
## Print help screen.
|
||||||
@ -141,6 +149,7 @@ sub print_help {
|
|||||||
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
||||||
print ("Options:\n");
|
print ("Options:\n");
|
||||||
print ("\t-a address\tServer address (default $t_address).\n");
|
print ("\t-a address\tServer address (default $t_address).\n");
|
||||||
|
print ("\t-b localaddress\tLocal address to bind.\n");
|
||||||
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
||||||
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
||||||
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
||||||
@ -154,7 +163,8 @@ sub print_help {
|
|||||||
print ("\t-v\t\tBe verbose.\n");
|
print ("\t-v\t\tBe verbose.\n");
|
||||||
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
||||||
print ("\t-x pwd\t\tServer password.\n");
|
print ("\t-x pwd\t\tServer password.\n");
|
||||||
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n\n");
|
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n");
|
||||||
|
print ("\t-z Compress data.\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -166,7 +176,7 @@ sub parse_options {
|
|||||||
my $tmp;
|
my $tmp;
|
||||||
|
|
||||||
# Get options
|
# Get options
|
||||||
if (getopts ('a:ce:f:ghk:p:qr:t:vwx:y:', \%opts) == 0 || defined ($opts{'h'})) {
|
if (getopts ('a:b:ce:f:ghk:p:qr:t:vwx:y:z', \%opts) == 0 || defined ($opts{'h'})) {
|
||||||
print_help ();
|
print_help ();
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@ -183,6 +193,18 @@ sub parse_options {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Bind local address
|
||||||
|
if (defined ($opts{'b'})) {
|
||||||
|
$t_bind_address = $opts{'b'};
|
||||||
|
if (($t_bind_address !~ /^[a-zA-Z\.][a-zA-Z0-9\.\-]+$/ && ($t_bind_address !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
||||||
|
|| $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255
|
||||||
|
|| $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255)) &&
|
||||||
|
($t_address !~ /^[0-9a-f:]+$/o)) {
|
||||||
|
error ("Local address $t_bind_address is not valid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Enable SSL without a client certificate
|
# Enable SSL without a client certificate
|
||||||
if (defined ($opts{'c'})) {
|
if (defined ($opts{'c'})) {
|
||||||
require IO::Socket::SSL;
|
require IO::Socket::SSL;
|
||||||
@ -299,6 +321,11 @@ sub parse_options {
|
|||||||
error ("Proxy port $t_proxy_port is not valid.");
|
error ("Proxy port $t_proxy_port is not valid.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Compress data
|
||||||
|
if (defined ($opts{'z'})) {
|
||||||
|
$t_zip = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -309,20 +336,42 @@ sub start_client {
|
|||||||
|
|
||||||
# Connect to server
|
# Connect to server
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -344,18 +393,38 @@ sub start_client_proxy {
|
|||||||
|
|
||||||
# Connect to proxy
|
# Connect to proxy
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -408,6 +477,8 @@ sub start_ssl {
|
|||||||
if ($t_ssl_cert eq ''){
|
if ($t_ssl_cert eq ''){
|
||||||
IO::Socket::SSL->start_SSL (
|
IO::Socket::SSL->start_SSL (
|
||||||
$t_socket,
|
$t_socket,
|
||||||
|
# No authentication
|
||||||
|
SSL_verify_mode => 0x00,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif ($t_ssl_ca eq '') {
|
elsif ($t_ssl_ca eq '') {
|
||||||
@ -525,6 +596,46 @@ sub recv_file {
|
|||||||
print_log ("Received file '$file'");
|
print_log ("Received file '$file'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file from the server
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $data = '';
|
||||||
|
my $file = $_[0];
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# Request file
|
||||||
|
send_data ("ZRECV <$file>\n");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response !~ /^ZRECV SIZE (\d+)$/) {
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = $1;
|
||||||
|
send_data ("ZRECV OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZRECV ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
print_log ("Received compressed file '$file'");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the server
|
## Send a file to the server
|
||||||
@ -578,6 +689,55 @@ sub send_file {
|
|||||||
print_log ("File sent");
|
print_log ("File sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the server (compressed)
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name;
|
||||||
|
my $data = '';
|
||||||
|
my $response = '';
|
||||||
|
my $retries;
|
||||||
|
my $file = $_[0];
|
||||||
|
my $size;
|
||||||
|
my $written;
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
$base_name = basename ($file);
|
||||||
|
|
||||||
|
# Request to send file
|
||||||
|
send_data ("ZSEND <$base_name> SIZE $size\n");
|
||||||
|
print_log ("Request to send file '$base_name' size ${size}b (compressed)");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
|
||||||
|
# Server rejected the file
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("Server responded SEND OK");
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("File sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -830,13 +990,21 @@ if ($t_recv == 0) {
|
|||||||
|
|
||||||
# Send the files
|
# Send the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
send_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zsend_file($file);
|
||||||
|
} else {
|
||||||
|
send_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Send the files
|
# Receive the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
recv_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zrecv_file ($file);
|
||||||
|
} else {
|
||||||
|
recv_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,6 +1050,8 @@ __END__
|
|||||||
|
|
||||||
=item I<-x pwd> B<Server password>.
|
=item I<-x pwd> B<Server password>.
|
||||||
|
|
||||||
|
=item I<-z> Compress data.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 EXIT STATUS
|
=head1 EXIT STATUS
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package: pandorafms-agent-unix
|
package: pandorafms-agent-unix
|
||||||
Version: 7.0NG.724-180628
|
Version: 7.0NG.724-180709
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.724-180628"
|
pandora_version="7.0NG.724-180709"
|
||||||
|
|
||||||
echo "Test if you has the tools for to make the packages."
|
echo "Test if you has the tools for to make the packages."
|
||||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||||
|
Binary file not shown.
@ -42,7 +42,7 @@ my $Sem = undef;
|
|||||||
my $ThreadSem = undef;
|
my $ThreadSem = undef;
|
||||||
|
|
||||||
use constant AGENT_VERSION => '7.0NG.724';
|
use constant AGENT_VERSION => '7.0NG.724';
|
||||||
use constant AGENT_BUILD => '180628';
|
use constant AGENT_BUILD => '180709';
|
||||||
|
|
||||||
# Agent log default file size maximum and instances
|
# Agent log default file size maximum and instances
|
||||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 7.0NG.724
|
%define version 7.0NG.724
|
||||||
%define release 180628
|
%define release 180709
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 7.0NG.724
|
%define version 7.0NG.724
|
||||||
%define release 180628
|
%define release 180709
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
|
|
||||||
PI_VERSION="7.0NG.724"
|
PI_VERSION="7.0NG.724"
|
||||||
PI_BUILD="180628"
|
PI_BUILD="180709"
|
||||||
OS_NAME=`uname -s`
|
OS_NAME=`uname -s`
|
||||||
|
|
||||||
FORCE=0
|
FORCE=0
|
||||||
|
@ -58,6 +58,8 @@ use strict;
|
|||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
use Socket (qw(SOCK_STREAM AF_INET AF_INET6));
|
||||||
my $SOCKET_MODULE =
|
my $SOCKET_MODULE =
|
||||||
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
|
||||||
@ -131,6 +133,12 @@ my $t_ssl_pwd = '';
|
|||||||
# Timeout for socket read/write operations in seconds
|
# Timeout for socket read/write operations in seconds
|
||||||
my $t_timeout = 1;
|
my $t_timeout = 1;
|
||||||
|
|
||||||
|
# bind ipaddr
|
||||||
|
my $t_bind_address = undef;
|
||||||
|
|
||||||
|
# Compress data before sending it through the socket.
|
||||||
|
my $t_zip = 0;
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB print_help
|
## SUB print_help
|
||||||
## Print help screen.
|
## Print help screen.
|
||||||
@ -141,6 +149,7 @@ sub print_help {
|
|||||||
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
print ("Tentacle client v$VERSION. See http://www.openideas.info/wiki for protocol description.\n\n");
|
||||||
print ("Options:\n");
|
print ("Options:\n");
|
||||||
print ("\t-a address\tServer address (default $t_address).\n");
|
print ("\t-a address\tServer address (default $t_address).\n");
|
||||||
|
print ("\t-b localaddress\tLocal address to bind.\n");
|
||||||
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
print ("\t-c\t\tEnable SSL without a client certificate.\n");
|
||||||
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
|
||||||
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
print ("\t-f ca\t\tVerify that the peer certificate is signed by a ca.\n");
|
||||||
@ -154,7 +163,8 @@ sub print_help {
|
|||||||
print ("\t-v\t\tBe verbose.\n");
|
print ("\t-v\t\tBe verbose.\n");
|
||||||
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
|
||||||
print ("\t-x pwd\t\tServer password.\n");
|
print ("\t-x pwd\t\tServer password.\n");
|
||||||
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n\n");
|
print ("\t-y proxy\tProxy server string (user:password\@address:port).\n");
|
||||||
|
print ("\t-z Compress data.\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -166,7 +176,7 @@ sub parse_options {
|
|||||||
my $tmp;
|
my $tmp;
|
||||||
|
|
||||||
# Get options
|
# Get options
|
||||||
if (getopts ('a:ce:f:ghk:p:qr:t:vwx:y:', \%opts) == 0 || defined ($opts{'h'})) {
|
if (getopts ('a:b:ce:f:ghk:p:qr:t:vwx:y:z', \%opts) == 0 || defined ($opts{'h'})) {
|
||||||
print_help ();
|
print_help ();
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@ -183,6 +193,18 @@ sub parse_options {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Bind local address
|
||||||
|
if (defined ($opts{'b'})) {
|
||||||
|
$t_bind_address = $opts{'b'};
|
||||||
|
if (($t_bind_address !~ /^[a-zA-Z\.][a-zA-Z0-9\.\-]+$/ && ($t_bind_address !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
||||||
|
|| $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255
|
||||||
|
|| $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255)) &&
|
||||||
|
($t_address !~ /^[0-9a-f:]+$/o)) {
|
||||||
|
error ("Local address $t_bind_address is not valid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Enable SSL without a client certificate
|
# Enable SSL without a client certificate
|
||||||
if (defined ($opts{'c'})) {
|
if (defined ($opts{'c'})) {
|
||||||
require IO::Socket::SSL;
|
require IO::Socket::SSL;
|
||||||
@ -299,6 +321,11 @@ sub parse_options {
|
|||||||
error ("Proxy port $t_proxy_port is not valid.");
|
error ("Proxy port $t_proxy_port is not valid.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Compress data
|
||||||
|
if (defined ($opts{'z'})) {
|
||||||
|
$t_zip = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -309,20 +336,42 @@ sub start_client {
|
|||||||
|
|
||||||
# Connect to server
|
# Connect to server
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_port,
|
PeerAddr => $t_address,
|
||||||
Type => SOCK_STREAM
|
PeerPort => $t_port,
|
||||||
);
|
LocalAddr => $t_bind_address,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_address,
|
||||||
|
PeerPort => $t_port,
|
||||||
|
Type => SOCK_STREAM
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -344,18 +393,38 @@ sub start_client_proxy {
|
|||||||
|
|
||||||
# Connect to proxy
|
# Connect to proxy
|
||||||
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
if ($SOCKET_MODULE ne 'IO::Socket::INET') {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET6,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET6,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET6,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
$t_socket = $SOCKET_MODULE->new (
|
if (defined ($t_bind_address)) {
|
||||||
Domain => AF_INET,
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
PeerAddr => $t_proxy_address,
|
Domain => AF_INET,
|
||||||
PeerPort => $t_proxy_port,
|
PeerAddr => $t_proxy_address,
|
||||||
);
|
PeerPort => $t_proxy_port,
|
||||||
|
LocalAddr => $t_bind_address,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$t_socket = $SOCKET_MODULE->new (
|
||||||
|
Domain => AF_INET,
|
||||||
|
PeerAddr => $t_proxy_address,
|
||||||
|
PeerPort => $t_proxy_port,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! defined ($t_socket)) {
|
if (! defined ($t_socket)) {
|
||||||
@ -408,6 +477,8 @@ sub start_ssl {
|
|||||||
if ($t_ssl_cert eq ''){
|
if ($t_ssl_cert eq ''){
|
||||||
IO::Socket::SSL->start_SSL (
|
IO::Socket::SSL->start_SSL (
|
||||||
$t_socket,
|
$t_socket,
|
||||||
|
# No authentication
|
||||||
|
SSL_verify_mode => 0x00,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif ($t_ssl_ca eq '') {
|
elsif ($t_ssl_ca eq '') {
|
||||||
@ -525,6 +596,46 @@ sub recv_file {
|
|||||||
print_log ("Received file '$file'");
|
print_log ("Received file '$file'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file from the server
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $data = '';
|
||||||
|
my $file = $_[0];
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# Request file
|
||||||
|
send_data ("ZRECV <$file>\n");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response !~ /^ZRECV SIZE (\d+)$/) {
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = $1;
|
||||||
|
send_data ("ZRECV OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZRECV ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
print_log ("Received compressed file '$file'");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the server
|
## Send a file to the server
|
||||||
@ -578,6 +689,55 @@ sub send_file {
|
|||||||
print_log ("File sent");
|
print_log ("File sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the server (compressed)
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name;
|
||||||
|
my $data = '';
|
||||||
|
my $response = '';
|
||||||
|
my $retries;
|
||||||
|
my $file = $_[0];
|
||||||
|
my $size;
|
||||||
|
my $written;
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
$base_name = basename ($file);
|
||||||
|
|
||||||
|
# Request to send file
|
||||||
|
send_data ("ZSEND <$base_name> SIZE $size\n");
|
||||||
|
print_log ("Request to send file '$base_name' size ${size}b (compressed)");
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
|
||||||
|
# Server rejected the file
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("Server responded SEND OK");
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
# Wait for server response
|
||||||
|
$response = recv_command ();
|
||||||
|
if ($response ne "ZSEND OK") {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Server responded $response.");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_log ("File sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -830,13 +990,21 @@ if ($t_recv == 0) {
|
|||||||
|
|
||||||
# Send the files
|
# Send the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
send_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zsend_file($file);
|
||||||
|
} else {
|
||||||
|
send_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Send the files
|
# Receive the files
|
||||||
foreach $file (@ARGV) {
|
foreach $file (@ARGV) {
|
||||||
recv_file ($file);
|
if ($t_zip == 1) {
|
||||||
|
zrecv_file ($file);
|
||||||
|
} else {
|
||||||
|
recv_file ($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,6 +1050,8 @@ __END__
|
|||||||
|
|
||||||
=item I<-x pwd> B<Server password>.
|
=item I<-x pwd> B<Server password>.
|
||||||
|
|
||||||
|
=item I<-z> Compress data.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 EXIT STATUS
|
=head1 EXIT STATUS
|
||||||
|
@ -60,6 +60,8 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use threads;
|
use threads;
|
||||||
use Thread::Semaphore;
|
use Thread::Semaphore;
|
||||||
use POSIX ":sys_wait_h";
|
use POSIX ":sys_wait_h";
|
||||||
@ -959,6 +961,15 @@ sub serve_connection {
|
|||||||
print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
|
print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
|
||||||
send_file ($1);
|
send_file ($1);
|
||||||
}
|
}
|
||||||
|
elsif ($command =~ /^ZSEND <(.*)> SIZE (\d+)$/) {
|
||||||
|
print_info ("Request to send compressed file '$1' size ${2}b from " . $t_client_socket->sockhost ());
|
||||||
|
zrecv_file ($1, $2);
|
||||||
|
}
|
||||||
|
# Client wants to receive a file
|
||||||
|
elsif ($command =~ /^ZRECV <(.*)>$/) {
|
||||||
|
print_info ("Request to receive compressed file '$1' from " . $t_client_socket->sockhost ());
|
||||||
|
zsend_file ($1);
|
||||||
|
}
|
||||||
# Quit
|
# Quit
|
||||||
elsif ($command =~ /^QUIT$/) {
|
elsif ($command =~ /^QUIT$/) {
|
||||||
print_info ("Connection closed from " . $t_client_socket->sockhost ());
|
print_info ("Connection closed from " . $t_client_socket->sockhost ());
|
||||||
@ -1070,6 +1081,61 @@ sub recv_file {
|
|||||||
print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file of size $_[1] and save it in $t_directory as $_[0].
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $base_name = $_[0];
|
||||||
|
my $data = '';
|
||||||
|
my $file;
|
||||||
|
my $size = $_[1];
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# 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 ("ZSEND 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 ("ZSEND ERR (file is too big)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
|
||||||
|
|
||||||
|
# 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 ("ZSEND ERR (file already exists)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
send_data ("ZSEND OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZSEND ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
send_data ("ZSEND OK\n");
|
||||||
|
print_info ("Received compressed file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the client
|
## Send a file to the client
|
||||||
@ -1122,6 +1188,57 @@ sub send_file {
|
|||||||
print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
|
print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the client
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name = $_[0];
|
||||||
|
my $data = '';
|
||||||
|
my $file;
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
|
||||||
|
# Check file name
|
||||||
|
if ($base_name =~ /[$t_invalid_chars]/) {
|
||||||
|
print_log ("Requested compressed file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name");
|
||||||
|
send_data ("ZRECV ERR (file has an invalid file name)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if (! -f $file) {
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " does not exist");
|
||||||
|
send_data ("ZRECV ERR (file does not exist)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
send_data ("ZRECV SIZE $size\n");
|
||||||
|
|
||||||
|
# Wait for client response
|
||||||
|
$response = recv_command ($t_block_size);
|
||||||
|
if ($response ne "ZRECV OK") {
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " not sent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the file
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
Version
|
Version
|
||||||
{180628}
|
{180709}
|
||||||
|
|
||||||
ViewReadme
|
ViewReadme
|
||||||
{Yes}
|
{Yes}
|
||||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||||||
using namespace Pandora_Strutils;
|
using namespace Pandora_Strutils;
|
||||||
|
|
||||||
#define PATH_SIZE _MAX_PATH+1
|
#define PATH_SIZE _MAX_PATH+1
|
||||||
#define PANDORA_VERSION ("7.0NG.724(Build 180628)")
|
#define PANDORA_VERSION ("7.0NG.724(Build 180709)")
|
||||||
|
|
||||||
string pandora_path;
|
string pandora_path;
|
||||||
string pandora_dir;
|
string pandora_dir;
|
||||||
|
@ -11,7 +11,7 @@ BEGIN
|
|||||||
VALUE "LegalCopyright", "Artica ST"
|
VALUE "LegalCopyright", "Artica ST"
|
||||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||||
VALUE "ProductVersion", "(7.0NG.724(Build 180628))"
|
VALUE "ProductVersion", "(7.0NG.724(Build 180709))"
|
||||||
VALUE "FileVersion", "1.0.0.0"
|
VALUE "FileVersion", "1.0.0.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package: pandorafms-console
|
package: pandorafms-console
|
||||||
Version: 7.0NG.724-180628
|
Version: 7.0NG.724-180709
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.724-180628"
|
pandora_version="7.0NG.724-180709"
|
||||||
|
|
||||||
package_pear=0
|
package_pear=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
@ -1971,8 +1971,8 @@ switch ($tab) {
|
|||||||
resizable: true,
|
resizable: true,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
modal: true,
|
modal: true,
|
||||||
height: 260,
|
height: 280,
|
||||||
width: 600,
|
width: 670,
|
||||||
title: 'Changing snmp module name',
|
title: 'Changing snmp module name',
|
||||||
open: function(){
|
open: function(){
|
||||||
$('#dialog').html('<br><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;margin-top:30px;"><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br> If you change the name of this module, various features <br> associated with this module, such as network maps, <br> interface graphs or other network modules, may no longer <br> work. If you are not completely sure of the process, please <br> do not change the name of the module. </p>');
|
$('#dialog').html('<br><img src="images/icono-warning-triangulo.png" style="float:left;margin-left:25px;margin-top:30px;"><p style="float:right;font-style:nunito;font-size:11pt;margin-right:50px;"><span style="font-weight:bold;font-size:12pt;">Warning</span> <br> If you change the name of this module, various features <br> associated with this module, such as network maps, <br> interface graphs or other network modules, may no longer <br> work. If you are not completely sure of the process, please <br> do not change the name of the module. </p>');
|
||||||
|
@ -224,9 +224,9 @@ $table->data[1][1] = html_print_select_groups(
|
|||||||
'', false, '', false, false, 'id_grupo', $strict_user);
|
'', false, '', false, false, 'id_grupo', $strict_user);
|
||||||
|
|
||||||
$table->data[2][0] = '<b>' . __('Group').'</b>';
|
$table->data[2][0] = '<b>' . __('Group').'</b>';
|
||||||
$table->data[2][1] = html_print_select_groups($config["id_user"], $access,
|
$display_all_group = (users_is_admin() || users_can_manage_group_all("AR"));
|
||||||
true, 'id_group', $id_group, '', '', -1, true, false, false, '',
|
$table->data[2][1] = html_print_select_groups($config['id_user'], "AR",
|
||||||
false, false, false, false, 'id_grupo', $strict_user);
|
$display_all_group, 'id_group', $idGroup, '', '', '', true);
|
||||||
|
|
||||||
$types = get_event_types ();
|
$types = get_event_types ();
|
||||||
// Expand standard array to add not_normal (not exist in the array, used only for searches)
|
// Expand standard array to add not_normal (not exist in the array, used only for searches)
|
||||||
|
@ -67,10 +67,13 @@ $table->data['name'][1] = html_print_input_text('name', $reportName,
|
|||||||
__('Name'), 80, 100, true, false, true);
|
__('Name'), 80, 100, true, false, true);
|
||||||
|
|
||||||
$table->data['group'][0] = __('Group');
|
$table->data['group'][0] = __('Group');
|
||||||
|
$write_groups = users_get_groups_for_select(false, "AR", true, true, false, 'id_grupo');
|
||||||
|
|
||||||
$write_groups = users_get_groups_for_select(false, "RW",
|
|
||||||
true, true, false, 'id_grupo');
|
|
||||||
|
|
||||||
|
html_print_select_groups($config['id_user'], "AR",
|
||||||
|
true, 'id_group', $idGroup, '', '', '', true);
|
||||||
|
|
||||||
|
|
||||||
// If the report group is not among the RW groups (special permission) we add it
|
// If the report group is not among the RW groups (special permission) we add it
|
||||||
if (!isset($write_groups[$idGroupReport]) && $idGroupReport) {
|
if (!isset($write_groups[$idGroupReport]) && $idGroupReport) {
|
||||||
$write_groups[$idGroupReport] = groups_get_name($idGroupReport);
|
$write_groups[$idGroupReport] = groups_get_name($idGroupReport);
|
||||||
|
@ -127,12 +127,9 @@ else {
|
|||||||
|
|
||||||
$table->data[1][0] = __('Group:');
|
$table->data[1][0] = __('Group:');
|
||||||
|
|
||||||
// Only display group "All" if user is administrator
|
|
||||||
// or has "RW" privileges
|
|
||||||
|
|
||||||
$display_all_group = (users_is_admin() || users_can_manage_group_all("RW"));
|
|
||||||
$table->data[1][1] = html_print_select_groups($config['id_user'], "RW",
|
$table->data[1][1] = html_print_select_groups($config['id_user'], "RW",
|
||||||
$display_all_group, 'id_group', $idGroup, '', '', '', true);
|
true, 'id_group', $idGroup, '', '', '', true);
|
||||||
$backgrounds_list = list_files(
|
$backgrounds_list = list_files(
|
||||||
$config['homedir'] . '/images/console/background/', "jpg", 1, 0);
|
$config['homedir'] . '/images/console/background/', "jpg", 1, 0);
|
||||||
$backgrounds_list = array_merge($backgrounds_list,
|
$backgrounds_list = array_merge($backgrounds_list,
|
||||||
|
@ -101,14 +101,16 @@ foreach ($servers as $server) {
|
|||||||
switch ($server['type']) {
|
switch ($server['type']) {
|
||||||
case "snmp":
|
case "snmp":
|
||||||
case "event":
|
case "event":
|
||||||
|
case "autoprovision":
|
||||||
|
case "migration":
|
||||||
$data[3] = $server["version"];
|
$data[3] = $server["version"];
|
||||||
$data[4] = 'N/A';
|
$data[4] = __('N/A');
|
||||||
$data[5] = 'N/A';
|
$data[5] = __('N/A');
|
||||||
break;
|
break;
|
||||||
case "export":
|
case "export":
|
||||||
$data[3] = $server["version"];
|
$data[3] = $server["version"];
|
||||||
$data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"];
|
$data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"];
|
||||||
$data[5] = 'N/A';
|
$data[5] = __('N/A');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$data[3] = $server["version"];
|
$data[3] = $server["version"];
|
||||||
|
@ -685,6 +685,17 @@ $options_full_escale[2] = __('On Boolean graphs');
|
|||||||
$table_chars->data[$row][1] = html_print_select($options_full_escale, 'full_scale_option', $config["full_scale_option"], '', '', 0, true, false, false);
|
$table_chars->data[$row][1] = html_print_select($options_full_escale, 'full_scale_option', $config["full_scale_option"], '', '', 0, true, false, false);
|
||||||
$row++;
|
$row++;
|
||||||
|
|
||||||
|
|
||||||
|
$table_chars->data[$row][0] = __('Soft graphs:');
|
||||||
|
$table_chars->data[$row][0] .= ui_print_help_tip(__('This option may cause performance issues'), true);
|
||||||
|
|
||||||
|
$options_soft_graphs = array();
|
||||||
|
$options_soft_graphs[0] = __('Standard mode');
|
||||||
|
$options_soft_graphs[1] = __('Classic mode');
|
||||||
|
|
||||||
|
$table_chars->data[$row][1] = html_print_select($options_soft_graphs, 'type_mode_graph', $config["type_mode_graph"], '', '', 0, true, false, false);
|
||||||
|
$row++;
|
||||||
|
|
||||||
$table_chars->data[$row][0] = __('Graph image height');
|
$table_chars->data[$row][0] = __('Graph image height');
|
||||||
$table_chars->data[$row][1] = html_print_input_text ('graph_image_height', $config['graph_image_height'], '', 20, 20, true);
|
$table_chars->data[$row][1] = html_print_input_text ('graph_image_height', $config['graph_image_height'], '', 20, 20, true);
|
||||||
$row++;
|
$row++;
|
||||||
|
BIN
pandora_console/images/autoprovision.png
Normal file
BIN
pandora_console/images/autoprovision.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 551 B |
BIN
pandora_console/images/migration.png
Normal file
BIN
pandora_console/images/migration.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 407 B |
@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* Pandora build version and version
|
* Pandora build version and version
|
||||||
*/
|
*/
|
||||||
$build_version = 'PC180628';
|
$build_version = 'PC180709';
|
||||||
$pandora_version = 'v7.0NG.724';
|
$pandora_version = 'v7.0NG.724';
|
||||||
|
|
||||||
// Do not overwrite default timezone set if defined.
|
// Do not overwrite default timezone set if defined.
|
||||||
|
@ -364,6 +364,8 @@ define('SERVER_TYPE_MAINFRAME', 15);
|
|||||||
define('SERVER_TYPE_SYNC', 16);
|
define('SERVER_TYPE_SYNC', 16);
|
||||||
define('SERVER_TYPE_WUX', 17);
|
define('SERVER_TYPE_WUX', 17);
|
||||||
define('SERVER_TYPE_SYSLOG', 18);
|
define('SERVER_TYPE_SYSLOG', 18);
|
||||||
|
define('SERVER_TYPE_AUTOPROVISION', 19);
|
||||||
|
define('SERVER_TYPE_MIGRATION', 20);
|
||||||
|
|
||||||
/* REPORTS */
|
/* REPORTS */
|
||||||
define('REPORT_TOP_N_MAX', 1);
|
define('REPORT_TOP_N_MAX', 1);
|
||||||
|
@ -3104,20 +3104,57 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
if (isset($show_elements_graph['labels']) &&
|
if (isset($show_elements_graph['labels']) &&
|
||||||
is_array($show_elements_graph['labels']) &&
|
is_array($show_elements_graph['labels']) &&
|
||||||
(count($show_elements_graph['labels']) > 0)){
|
(count($show_elements_graph['labels']) > 0)){
|
||||||
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
|
$name_legend = $data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(strpos($key, 'baseline') !== false){
|
if(strpos($key, 'baseline') !== false){
|
||||||
$data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
|
$name_legend = $data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
|
||||||
$value['module_name'] . ' Baseline ';
|
$value['module_name'] . ' Baseline ';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
|
$name_legend = $data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
|
||||||
$value['module_name'] . ': ';
|
$value['module_name'] . ': ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strpos($key, 'baseline') === false){
|
if(($show_elements_graph['fullscale'] ||
|
||||||
|
$show_elements_graph['type_mode_graph'] ) &&
|
||||||
|
strpos($key, 'baseline') === false ){
|
||||||
|
$data_return['legend'][$key] .=
|
||||||
|
__('Min:') . remove_right_zeros(
|
||||||
|
number_format(
|
||||||
|
$value['min'],
|
||||||
|
$config['graph_precision']
|
||||||
|
)
|
||||||
|
) . ' ' .
|
||||||
|
__('Max:') . remove_right_zeros(
|
||||||
|
number_format(
|
||||||
|
$value['max'],
|
||||||
|
$config['graph_precision']
|
||||||
|
)
|
||||||
|
) . ' ' .
|
||||||
|
_('Avg:') . remove_right_zeros(
|
||||||
|
number_format(
|
||||||
|
$value['avg'],
|
||||||
|
$config['graph_precision']
|
||||||
|
)
|
||||||
|
) . ' ' . $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2'){
|
||||||
|
$data_return['color'][$key] = $color_series['overlapped'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data_return['color'][$key] = $color_series[$i];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(!$show_elements_graph['fullscale'] && strpos($key, 'min') !== false ||
|
||||||
|
!$show_elements_graph['fullscale'] && strpos($key, 'max') !== false){
|
||||||
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
|
|
||||||
|
$data_return['legend'][$key] = $name_legend;
|
||||||
|
if($show_elements_graph['type_mode_graph']){
|
||||||
$data_return['legend'][$key] .=
|
$data_return['legend'][$key] .=
|
||||||
__('Min:') . remove_right_zeros(
|
__('Min:') . remove_right_zeros(
|
||||||
number_format(
|
number_format(
|
||||||
@ -3177,13 +3214,7 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
__('Percentil') . ' ' .
|
__('Percentil') . ' ' .
|
||||||
$config['percentil'] .
|
$config['percentil'] .
|
||||||
'º ' . __('of module') . ' ';
|
'º ' . __('of module') . ' ';
|
||||||
if (isset($show_elements_graph['labels']) && is_array($show_elements_graph['labels'])){
|
$data_return['legend'][$key] .= $name_legend;
|
||||||
$data_return['legend'][$key] .= $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$data_return['legend'][$key] .= $value['agent_alias'] . ' / ' .
|
|
||||||
$value['module_name'] . ': ' . ' Value: ';
|
|
||||||
}
|
|
||||||
$data_return['legend'][$key] .= remove_right_zeros(
|
$data_return['legend'][$key] .= remove_right_zeros(
|
||||||
number_format(
|
number_format(
|
||||||
$value['data'][0][1],
|
$value['data'][0][1],
|
||||||
|
@ -25,16 +25,19 @@ require_once($config['homedir'] . '/include/functions_users.php');
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the agent exists in the DB.
|
* Check the agent exists in the DB.
|
||||||
*
|
*
|
||||||
* @param int $id_agent The agent id.
|
* @param int $id_agent The agent id.
|
||||||
* @param boolean $show_disabled Show the agent found althought it is disabled. By default false.
|
* @param boolean $show_disabled Show the agent found althought it is disabled. By default false.
|
||||||
*
|
*
|
||||||
* @return boolean The result to check if the agent is in the DB.
|
* @return boolean The result to check if the agent is in the DB.
|
||||||
*/
|
*/
|
||||||
function agents_check_agent_exists($id_agent, $show_disabled = true) {
|
function agents_check_agent_exists($id_agent, $show_disabled = true) {
|
||||||
$agent = db_get_value_filter('id_agente', 'tagente',
|
$agent = db_get_value_filter(
|
||||||
array('id_agente' => $id_agent, 'disabled' => !$show_disabled));
|
'id_agente',
|
||||||
|
'tagente',
|
||||||
|
array('id_agente' => $id_agent, 'disabled' => !$show_disabled)
|
||||||
|
);
|
||||||
|
|
||||||
if (!empty($agent)) {
|
if (!empty($agent)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2688,7 +2691,7 @@ function agents_get_all_groups_agent ($id_agent, $group = false) {
|
|||||||
*/
|
*/
|
||||||
function agents_count_agents_filter ($filter = array(), $access = "AR") {
|
function agents_count_agents_filter ($filter = array(), $access = "AR") {
|
||||||
$total_agents = agents_get_agents(
|
$total_agents = agents_get_agents(
|
||||||
array ('id_group' => $id_group),
|
$filter,
|
||||||
array ('COUNT(DISTINCT id_agente) as total'),
|
array ('COUNT(DISTINCT id_agente) as total'),
|
||||||
$access
|
$access
|
||||||
);
|
);
|
||||||
|
@ -180,7 +180,13 @@ function returnData($returnType, $data, $separator = ';') {
|
|||||||
if ($separator == ";") {
|
if ($separator == ";") {
|
||||||
$separator = null;
|
$separator = null;
|
||||||
}
|
}
|
||||||
echo json_encode ($data, $separator);
|
|
||||||
|
if(empty($separator)){
|
||||||
|
echo json_encode ($data);
|
||||||
|
} else {
|
||||||
|
echo json_encode ($data, $separator);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9335,7 +9341,7 @@ function api_get_total_agents($id_group, $trash1, $trash2, $returnType) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_agents = agents_count_agents_filter(array ('id_group' => $id_group));
|
$total_agents = agents_count_agents_filter(array ('id_grupo' => $id_group));
|
||||||
|
|
||||||
$data = array('type' => 'string', 'data' => $total_agents);
|
$data = array('type' => 'string', 'data' => $total_agents);
|
||||||
returnData($returnType, $data);
|
returnData($returnType, $data);
|
||||||
|
@ -627,7 +627,10 @@ function config_update_config () {
|
|||||||
|
|
||||||
if (!config_update_value ('full_scale_option', (int) get_parameter('full_scale_option', 0)))
|
if (!config_update_value ('full_scale_option', (int) get_parameter('full_scale_option', 0)))
|
||||||
$error_update[] = __('Default full scale (TIP)');
|
$error_update[] = __('Default full scale (TIP)');
|
||||||
|
|
||||||
|
if (!config_update_value ('type_mode_graph', (int) get_parameter('type_mode_graph', 0)))
|
||||||
|
$error_update[] = __('Default soft graphs');
|
||||||
|
|
||||||
if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 0)))
|
if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 0)))
|
||||||
$error_update[] = __('Default height of the chart image');
|
$error_update[] = __('Default height of the chart image');
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend
|
|||||||
* utimestamp
|
* utimestamp
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false) {
|
function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false, $slice_size = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (!isset($id_agente_modulo)) {
|
if (!isset($id_agente_modulo)) {
|
||||||
@ -709,7 +709,9 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve module_interval to build the template
|
// Retrieve module_interval to build the template
|
||||||
$slice_size = $module_interval;
|
if($slice_size === false){
|
||||||
|
$slice_size = $module_interval;
|
||||||
|
}
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ function grafico_modulo_sparse_data_chart (
|
|||||||
$data_slice = $date_array['period'] / (250 * $params['zoom']);
|
$data_slice = $date_array['period'] / (250 * $params['zoom']);
|
||||||
|
|
||||||
if( $data_module_graph['id_module_type'] == 23 ||
|
if( $data_module_graph['id_module_type'] == 23 ||
|
||||||
$data_module_graph['id_module_type'] == 3 ||
|
$data_module_graph['id_module_type'] == 3 ||
|
||||||
$data_module_graph['id_module_type'] == 17 ||
|
$data_module_graph['id_module_type'] == 17 ||
|
||||||
$data_module_graph['id_module_type'] == 10 ||
|
$data_module_graph['id_module_type'] == 10 ||
|
||||||
$data_module_graph['id_module_type'] == 33 ){
|
$data_module_graph['id_module_type'] == 33 ){
|
||||||
@ -258,12 +258,11 @@ function grafico_modulo_sparse_data_chart (
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//all points(data) and boolean
|
//all points(data) and boolean
|
||||||
if( $params['zoom'] == 5 ||
|
if( $data_module_graph['id_module_type'] == 2 ||
|
||||||
$data_module_graph['id_module_type'] == 2 ||
|
$data_module_graph['id_module_type'] == 6 ||
|
||||||
$data_module_graph['id_module_type'] == 6 ||
|
|
||||||
$data_module_graph['id_module_type'] == 21 ||
|
$data_module_graph['id_module_type'] == 21 ||
|
||||||
$data_module_graph['id_module_type'] == 18 ||
|
$data_module_graph['id_module_type'] == 18 ||
|
||||||
$data_module_graph['id_module_type'] == 9 ||
|
$data_module_graph['id_module_type'] == 9 ||
|
||||||
$data_module_graph['id_module_type'] == 31 ||
|
$data_module_graph['id_module_type'] == 31 ||
|
||||||
$data_module_graph['id_module_type'] == 100 ){
|
$data_module_graph['id_module_type'] == 100 ){
|
||||||
|
|
||||||
@ -278,19 +277,6 @@ function grafico_modulo_sparse_data_chart (
|
|||||||
$data_module_graph['history_db']
|
$data_module_graph['history_db']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$data = db_get_all_rows_filter (
|
|
||||||
'tagente_datos',
|
|
||||||
array ('id_agente_modulo' => (int)$agent_module_id,
|
|
||||||
"utimestamp > '". $date_array['start_date']. "'",
|
|
||||||
"utimestamp < '". $date_array['final_date'] . "'",
|
|
||||||
'group' => "ROUND(utimestamp / $data_slice)",
|
|
||||||
'order' => 'utimestamp ASC'),
|
|
||||||
array ('sum(datos)/count(datos) as datos', 'min(utimestamp) as utimestamp'),
|
|
||||||
'AND',
|
|
||||||
$data_module_graph['history_db']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data === false){
|
if($data === false){
|
||||||
@ -415,29 +401,58 @@ function grafico_modulo_sparse_data(
|
|||||||
$params['show_unknown'],
|
$params['show_unknown'],
|
||||||
$params['percentil'],
|
$params['percentil'],
|
||||||
$series_suffix,
|
$series_suffix,
|
||||||
$params['flag_overlapped']
|
$params['flag_overlapped'],
|
||||||
|
false,
|
||||||
|
$params['type_mode_graph']
|
||||||
);
|
);
|
||||||
|
|
||||||
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
|
|
||||||
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
|
|
||||||
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
|
|
||||||
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
|
|
||||||
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$array_data = grafico_modulo_sparse_data_chart (
|
//uncompress data except boolean and string.
|
||||||
$agent_module_id,
|
if( $data_module_graph['id_module_type'] == 23 ||
|
||||||
$date_array,
|
$data_module_graph['id_module_type'] == 3 ||
|
||||||
$data_module_graph,
|
$data_module_graph['id_module_type'] == 17 ||
|
||||||
$params,
|
$data_module_graph['id_module_type'] == 10 ||
|
||||||
$series_suffix
|
$data_module_graph['id_module_type'] == 33 ||
|
||||||
);
|
$data_module_graph['id_module_type'] == 2 ||
|
||||||
|
$data_module_graph['id_module_type'] == 6 ||
|
||||||
|
$data_module_graph['id_module_type'] == 21 ||
|
||||||
|
$data_module_graph['id_module_type'] == 18 ||
|
||||||
|
$data_module_graph['id_module_type'] == 9 ||
|
||||||
|
$data_module_graph['id_module_type'] == 31 ||
|
||||||
|
$data_module_graph['id_module_type'] == 100 ){
|
||||||
|
html_debug_prinbt('entra');
|
||||||
|
$array_data = grafico_modulo_sparse_data_chart (
|
||||||
|
$agent_module_id,
|
||||||
|
$date_array,
|
||||||
|
$data_module_graph,
|
||||||
|
$params,
|
||||||
|
$series_suffix
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$array_data = fullscale_data(
|
||||||
|
$agent_module_id,
|
||||||
|
$date_array,
|
||||||
|
$params['show_unknown'],
|
||||||
|
$params['percentil'],
|
||||||
|
$series_suffix,
|
||||||
|
$params['flag_overlapped'],
|
||||||
|
$data_slice = $date_array['period'] / (250 * $params['zoom']) + 100,
|
||||||
|
$params['type_mode_graph']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($array_data === false){
|
if($array_data === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
|
||||||
|
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
|
||||||
|
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
|
||||||
|
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
|
||||||
|
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
|
||||||
|
|
||||||
//This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
|
//This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
|
||||||
if($params['force_interval'] != ''){
|
if($params['force_interval'] != ''){
|
||||||
$period_time_interval = $date_array['period'] * 1000;
|
$period_time_interval = $date_array['period'] * 1000;
|
||||||
@ -878,6 +893,11 @@ function grafico_modulo_sparse ($params) {
|
|||||||
$params['zoom'] = 1;
|
$params['zoom'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($params['type_mode_graph'])){
|
||||||
|
//$config['type_mode_graph']
|
||||||
|
$params['type_mode_graph'] = $config['type_mode_graph'];
|
||||||
|
}
|
||||||
|
|
||||||
//XXXX Configurable
|
//XXXX Configurable
|
||||||
$params['grid_color'] = '#C1C1C1';
|
$params['grid_color'] = '#C1C1C1';
|
||||||
$params['legend_color'] = '#636363';
|
$params['legend_color'] = '#636363';
|
||||||
@ -1328,6 +1348,11 @@ function graphic_combined_module (
|
|||||||
$params['show_unknown'] = false;
|
$params['show_unknown'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($params['type_mode_graph'])){
|
||||||
|
//$config['type_mode_graph']
|
||||||
|
$params['type_mode_graph'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$params['graph_combined'] = true;
|
$params['graph_combined'] = true;
|
||||||
$params_combined['graph_combined'] = true;
|
$params_combined['graph_combined'] = true;
|
||||||
|
|
||||||
@ -1367,7 +1392,8 @@ function graphic_combined_module (
|
|||||||
$sources = db_get_all_rows_field_filter(
|
$sources = db_get_all_rows_field_filter(
|
||||||
'tgraph_source',
|
'tgraph_source',
|
||||||
'id_graph',
|
'id_graph',
|
||||||
$params_combined['id_graph']
|
$params_combined['id_graph'],
|
||||||
|
'field_order'
|
||||||
);
|
);
|
||||||
|
|
||||||
$series = db_get_all_rows_sql(
|
$series = db_get_all_rows_sql(
|
||||||
@ -3947,86 +3973,267 @@ function fullscale_data (
|
|||||||
$agent_module_id, $date_array,
|
$agent_module_id, $date_array,
|
||||||
$show_unknown = 0, $show_percentil = 0,
|
$show_unknown = 0, $show_percentil = 0,
|
||||||
$series_suffix,
|
$series_suffix,
|
||||||
$compare = false){
|
$compare = false,
|
||||||
|
$data_slice = false,
|
||||||
|
$type_mode_graph){
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
$data_uncompress =
|
$data_uncompress =
|
||||||
db_uncompress_module_data(
|
db_uncompress_module_data(
|
||||||
$agent_module_id,
|
$agent_module_id,
|
||||||
$date_array['start_date'],
|
$date_array['start_date'],
|
||||||
$date_array['final_date']
|
$date_array['final_date'],
|
||||||
|
$data_slice
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$previous_data = 0;
|
$previous_data = 0;
|
||||||
$min_value = PHP_INT_MAX-1;
|
//normal
|
||||||
$max_value = PHP_INT_MIN+1;
|
$min_value_total = PHP_INT_MAX;
|
||||||
|
$max_value_total = -PHP_INT_MAX;
|
||||||
|
//max
|
||||||
|
$max_value_min = PHP_INT_MAX;
|
||||||
|
$max_value_max = -PHP_INT_MAX;
|
||||||
|
//min
|
||||||
|
$min_value_min = PHP_INT_MAX;
|
||||||
|
$min_value_max = -PHP_INT_MAX;
|
||||||
|
//avg
|
||||||
|
$avg_value_min = PHP_INT_MAX;
|
||||||
|
$avg_value_max = -PHP_INT_MAX;
|
||||||
|
|
||||||
$flag_unknown = 0;
|
$flag_unknown = 0;
|
||||||
$array_percentil = array();
|
$array_percentil = array();
|
||||||
foreach ($data_uncompress as $k) {
|
|
||||||
foreach ($k["data"] as $v) {
|
|
||||||
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if($compare){ // * 1000 need js utimestam mlsecond
|
|
||||||
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$real_date = $v['utimestamp'] * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($v["datos"] === NULL) {
|
if($data_slice){
|
||||||
// Unknown
|
foreach ($data_uncompress as $k) {
|
||||||
if($show_unknown){
|
$sum_data = 0;
|
||||||
if(!$compare){
|
$count_data = 0;
|
||||||
if($flag_unknown){
|
$min_value = PHP_INT_MAX;
|
||||||
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
$max_value = -PHP_INT_MAX;
|
||||||
|
$flag_virtual_data = 0;
|
||||||
|
foreach ($k["data"] as $v) {
|
||||||
|
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
|
||||||
|
continue;
|
||||||
|
$flag_virtual_data = 1;
|
||||||
|
}
|
||||||
|
if($compare){ // * 1000 need js utimestam mlsecond
|
||||||
|
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$real_date = $v['utimestamp'] * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($v["datos"] === NULL) {
|
||||||
|
// Unknown
|
||||||
|
if($show_unknown){
|
||||||
|
if(!$compare){
|
||||||
|
if($flag_unknown){
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
||||||
|
$flag_unknown = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
|
$v["datos"] = $previous_data;
|
||||||
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
}
|
||||||
$flag_unknown = 1;
|
else {
|
||||||
|
//normal
|
||||||
|
$previous_data = $v["datos"];
|
||||||
|
if($show_unknown){
|
||||||
|
if(!$compare){
|
||||||
|
if($flag_unknown){
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
|
||||||
|
$flag_unknown = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
|
if(isset($v["datos"]) && $v["datos"]){
|
||||||
}
|
//max
|
||||||
else {
|
if($v['datos'] >= $max_value){
|
||||||
//normal
|
$max_value = $v['datos'];
|
||||||
$previous_data = $v["datos"];
|
|
||||||
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
|
|
||||||
if($show_unknown){
|
|
||||||
if(!$compare){
|
|
||||||
if($flag_unknown){
|
|
||||||
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
|
|
||||||
$flag_unknown = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//min
|
||||||
|
if($v['datos'] <= $min_value){
|
||||||
|
$min_value = $v['datos'];
|
||||||
|
}
|
||||||
|
//avg sum
|
||||||
|
$sum_data += $v["datos"];
|
||||||
}
|
}
|
||||||
|
//avg count
|
||||||
|
$count_data++;
|
||||||
|
|
||||||
|
if($show_percentil && !$compare){
|
||||||
|
$array_percentil[] = $v["datos"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$last_data = $v["datos"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($v["datos"]) && $v["datos"]){
|
if(!$flag_virtual_data){
|
||||||
//max
|
if($compare){ // * 1000 need js utimestam mlsecond
|
||||||
if($v['datos'] >= $max_value){
|
$real_date = ($k['data'][0]['utimestamp'] + $date_array['period']) * 1000;
|
||||||
$max_value = $v['datos'];
|
|
||||||
}
|
}
|
||||||
//min
|
else{
|
||||||
if($v['datos'] <= $min_value){
|
$real_date = $k['data'][0]['utimestamp'] * 1000;
|
||||||
$min_value = $v['datos'];
|
|
||||||
}
|
}
|
||||||
//avg sum
|
|
||||||
$sum_data += $v["datos"];
|
|
||||||
}
|
|
||||||
//avg count
|
|
||||||
$count_data++;
|
|
||||||
|
|
||||||
if($show_percentil && !$compare){
|
$data["sum" . $series_suffix]['data'][] = array($real_date , $sum_data/$count_data);
|
||||||
$array_percentil[] = $v["datos"];
|
if($type_mode_graph && !$params['baseline']){
|
||||||
}
|
$data["min" . $series_suffix]['data'][] = array($real_date , $min_value);
|
||||||
|
$data["max" . $series_suffix]['data'][] = array($real_date , $max_value);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value;
|
||||||
|
$data["sum" . $series_suffix]['slice_data'][$real_date]['avg'] = $sum_data/$count_data;
|
||||||
|
$data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value;
|
||||||
|
}
|
||||||
|
|
||||||
$last_data = $v["datos"];
|
//max_total
|
||||||
|
if($max_value >= $max_value_total){
|
||||||
|
$max_value_total = $max_value;
|
||||||
|
}
|
||||||
|
//min_total
|
||||||
|
if($min_value <= $min_value_total){
|
||||||
|
$min_value_total = $min_value;
|
||||||
|
}
|
||||||
|
//avg sum_total
|
||||||
|
$sum_data_total += $sum_data;
|
||||||
|
|
||||||
|
//avg count_total
|
||||||
|
$count_data_total++;
|
||||||
|
|
||||||
|
if($type_mode_graph && !$params['baseline']){
|
||||||
|
/*MIN*/
|
||||||
|
//max_min
|
||||||
|
if($min_value >= $min_value_max){
|
||||||
|
$min_value_max = $min_value;
|
||||||
|
}
|
||||||
|
//min_min
|
||||||
|
if($min_value <= $min_value_min){
|
||||||
|
$min_value_min = $min_value;
|
||||||
|
}
|
||||||
|
//avg sum_min
|
||||||
|
$sum_data_min += $min_value;
|
||||||
|
|
||||||
|
/*MAX*/
|
||||||
|
//max_max
|
||||||
|
if($max_value >= $max_value_max){
|
||||||
|
$max_value_max = $max_value;
|
||||||
|
}
|
||||||
|
//min_max
|
||||||
|
if($max_value <= $max_value_min){
|
||||||
|
$max_value_min = $max_value;
|
||||||
|
}
|
||||||
|
//avg sum_max
|
||||||
|
$sum_data_max += $max_value;
|
||||||
|
|
||||||
|
/*AVG*/
|
||||||
|
//max_max
|
||||||
|
if(($sum_data/$count_data) >= $avg_value_max){
|
||||||
|
$avg_value_max = $sum_data/$count_data;
|
||||||
|
}
|
||||||
|
//min_max
|
||||||
|
if(($sum_data/$count_data) <= $avg_value_min){
|
||||||
|
$avg_value_min = $sum_data/$count_data;
|
||||||
|
}
|
||||||
|
//avg sum_max
|
||||||
|
$sum_data_avg += $sum_data/$count_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$data["sum" . $series_suffix]['min'] = $min_value_total;
|
||||||
|
$data["sum" . $series_suffix]['max'] = $max_value_total;
|
||||||
|
$data["sum" . $series_suffix]['avg'] = $sum_data_total/$count_data_total;
|
||||||
|
|
||||||
|
if($type_mode_graph && !$params['baseline']){
|
||||||
|
$data["min" . $series_suffix]['min'] = $min_value_min;
|
||||||
|
$data["min" . $series_suffix]['max'] = $min_value_max;
|
||||||
|
$data["min" . $series_suffix]['avg'] = $sum_data_min/$count_data_total;
|
||||||
|
|
||||||
|
$data["max" . $series_suffix]['min'] = $max_value_min;
|
||||||
|
$data["max" . $series_suffix]['max'] = $max_value_max;
|
||||||
|
$data["max" . $series_suffix]['avg'] = $sum_data_max/$count_data_total;
|
||||||
|
|
||||||
|
$data["sum" . $series_suffix]['min'] = $avg_value_min;
|
||||||
|
$data["sum" . $series_suffix]['max'] = $avg_value_max;
|
||||||
|
$data["sum" . $series_suffix]['avg'] = $sum_data_avg/$count_data_total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
foreach ($data_uncompress as $k) {
|
||||||
|
foreach ($k["data"] as $v) {
|
||||||
|
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if($compare){ // * 1000 need js utimestam mlsecond
|
||||||
|
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$real_date = $v['utimestamp'] * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($v["datos"] === NULL) {
|
||||||
|
// Unknown
|
||||||
|
if($show_unknown){
|
||||||
|
if(!$compare){
|
||||||
|
if($flag_unknown){
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
||||||
|
$flag_unknown = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//normal
|
||||||
|
$previous_data = $v["datos"];
|
||||||
|
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
|
||||||
|
if($show_unknown){
|
||||||
|
if(!$compare){
|
||||||
|
if($flag_unknown){
|
||||||
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
|
||||||
|
$flag_unknown = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($v["datos"]) && $v["datos"]){
|
||||||
|
//max
|
||||||
|
if($v['datos'] >= $max_value){
|
||||||
|
$max_value = $v['datos'];
|
||||||
|
}
|
||||||
|
//min
|
||||||
|
if($v['datos'] <= $min_value){
|
||||||
|
$min_value = $v['datos'];
|
||||||
|
}
|
||||||
|
//avg sum
|
||||||
|
$sum_data += $v["datos"];
|
||||||
|
}
|
||||||
|
//avg count
|
||||||
|
$count_data++;
|
||||||
|
|
||||||
|
if($show_percentil && !$compare){
|
||||||
|
$array_percentil[] = $v["datos"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$last_data = $v["datos"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data["sum" . $series_suffix]['min'] = $min_value;
|
||||||
|
$data["sum" . $series_suffix]['max'] = $max_value;
|
||||||
|
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($show_percentil && !$compare){
|
if($show_percentil && !$compare){
|
||||||
@ -4064,12 +4271,19 @@ function fullscale_data (
|
|||||||
$date_array['final_date'] * 1000,
|
$date_array['final_date'] * 1000,
|
||||||
$last_data
|
$last_data
|
||||||
);
|
);
|
||||||
|
if($data_slice){
|
||||||
|
if($type_mode_graph && !$params['baseline']){
|
||||||
|
$data["min" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $min_value);
|
||||||
|
$data["max" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $max_value);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['min'] = $min_value;
|
||||||
|
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['avg'] = $sum_data/$count_data;
|
||||||
|
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['max'] = $max_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data["sum" . $series_suffix]['min'] = $min_value;
|
|
||||||
$data["sum" . $series_suffix]['max'] = $max_value;
|
|
||||||
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
|
|||||||
return ERR_GENERIC;
|
return ERR_GENERIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a module from an agent.
|
* Deletes a module from an agent.
|
||||||
*
|
*
|
||||||
@ -299,20 +299,20 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
|
|||||||
* @return True if the module was deleted. False if not.
|
* @return True if the module was deleted. False if not.
|
||||||
*/
|
*/
|
||||||
function modules_delete_agent_module ($id_agent_module) {
|
function modules_delete_agent_module ($id_agent_module) {
|
||||||
if (empty($id_agent_module))
|
if (empty($id_agent_module))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (is_array($id_agent_module)) {
|
if (is_array($id_agent_module)) {
|
||||||
$id_agents = db_get_all_rows_sql(
|
$id_agents = db_get_all_rows_sql(
|
||||||
sprintf('SELECT id_agente
|
sprintf('SELECT id_agente
|
||||||
FROM tagente_modulo
|
FROM tagente_modulo
|
||||||
WHERE id_agente_modulo IN (%s)
|
WHERE id_agente_modulo IN (%s)
|
||||||
GROUP BY id_agente', implode(',', $id_agent_module)));
|
GROUP BY id_agente', implode(',', $id_agent_module)));
|
||||||
|
|
||||||
foreach($id_agents as $k => $v) {
|
foreach($id_agents as $k => $v) {
|
||||||
$id_agents[$k] = $v['id_agente'];
|
$id_agents[$k] = $v['id_agente'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update update flags to server side
|
// Update update flags to server side
|
||||||
db_process_sql (sprintf('UPDATE tagente
|
db_process_sql (sprintf('UPDATE tagente
|
||||||
SET update_module_count=1, update_alert_count=1
|
SET update_module_count=1, update_alert_count=1
|
||||||
@ -321,18 +321,18 @@ function modules_delete_agent_module ($id_agent_module) {
|
|||||||
else {
|
else {
|
||||||
// Read module data
|
// Read module data
|
||||||
$id_agent = modules_get_agentmodule_agent($id_agent_module);
|
$id_agent = modules_get_agentmodule_agent($id_agent_module);
|
||||||
|
|
||||||
// Update update flags to server side
|
// Update update flags to server side
|
||||||
db_process_sql (sprintf('UPDATE tagente
|
db_process_sql (sprintf('UPDATE tagente
|
||||||
SET update_module_count=1, update_alert_count=1
|
SET update_module_count=1, update_alert_count=1
|
||||||
WHERE id_agente = %s', $id_agent));
|
WHERE id_agente = %s', $id_agent));
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = array ('id_agent_module' => $id_agent_module);
|
$where = array ('id_agent_module' => $id_agent_module);
|
||||||
|
|
||||||
$enterprise_include = enterprise_include_once(
|
enterprise_include_once("include/functions_agents.php");
|
||||||
'include/functions_config_agents.php');
|
$enterprise_include = enterprise_include_once('include/functions_config_agents.php');
|
||||||
|
|
||||||
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
|
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
|
||||||
if (is_array($id_agent_module)) {
|
if (is_array($id_agent_module)) {
|
||||||
foreach ($id_agent_module as $id_agent_module_item) {
|
foreach ($id_agent_module as $id_agent_module_item) {
|
||||||
@ -347,9 +347,9 @@ function modules_delete_agent_module ($id_agent_module) {
|
|||||||
modules_get_agentmodule_name($id_agent_module));
|
modules_get_agentmodule_name($id_agent_module));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alerts_delete_alert_agent_module (0, $where);
|
alerts_delete_alert_agent_module (0, $where);
|
||||||
|
|
||||||
db_process_sql_delete ('tgraph_source', $where);
|
db_process_sql_delete ('tgraph_source', $where);
|
||||||
db_process_sql_delete ('treport_content', $where);
|
db_process_sql_delete ('treport_content', $where);
|
||||||
db_process_sql_delete ('tevento',
|
db_process_sql_delete ('tevento',
|
||||||
@ -361,7 +361,7 @@ function modules_delete_agent_module ($id_agent_module) {
|
|||||||
array ('nombre' => 'delete_pending', 'delete_pending' => 1, 'disabled' => 1),
|
array ('nombre' => 'delete_pending', 'delete_pending' => 1, 'disabled' => 1),
|
||||||
$where);
|
$where);
|
||||||
db_process_sql_delete('ttag_module', $where);
|
db_process_sql_delete('ttag_module', $where);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1685,17 +1685,22 @@ function modules_get_previous_data ($id_agent_module, $utimestamp = 0, $string =
|
|||||||
$table = 'tagente_datos';
|
$table = 'tagente_datos';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf ('SELECT *
|
$sql = sprintf (
|
||||||
FROM ' . $table . '
|
"SELECT * FROM %s
|
||||||
WHERE id_agente_modulo = %d
|
WHERE id_agente_modulo = %d
|
||||||
AND utimestamp <= %d
|
AND utimestamp = ( SELECT max(utimestamp)
|
||||||
ORDER BY utimestamp DESC',
|
FROM tagente_datos
|
||||||
$id_agent_module, $utimestamp,
|
WHERE id_agente_modulo = %d
|
||||||
$utimestamp - SECONDS_2DAY
|
AND utimestamp <= %d )",
|
||||||
|
$table,
|
||||||
|
$id_agent_module,
|
||||||
|
$id_agent_module,
|
||||||
|
$utimestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
$search_in_history_db = db_search_in_history_db($utimestamp);
|
$search_in_history_db = db_search_in_history_db($utimestamp);
|
||||||
return db_get_row_sql ($sql, $search_in_history_db);
|
|
||||||
|
return db_get_row_sql($sql, $search_in_history_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -455,6 +455,16 @@ function servers_get_info ($id_server = -1) {
|
|||||||
$server["type"] = "syslog";
|
$server["type"] = "syslog";
|
||||||
$id_modulo = 0;
|
$id_modulo = 0;
|
||||||
break;
|
break;
|
||||||
|
case SERVER_TYPE_AUTOPROVISION:
|
||||||
|
$server["img"] = html_print_image ("images/autoprovision.png", true, array ("title" => __('Autoprovision server')));
|
||||||
|
$server["type"] = "autoprovision";
|
||||||
|
$id_modulo = 0;
|
||||||
|
break;
|
||||||
|
case SERVER_TYPE_MIGRATION:
|
||||||
|
$server["img"] = html_print_image ("images/migration.png", true, array ("title" => __('Migration server')));
|
||||||
|
$server["type"] = "migration";
|
||||||
|
$id_modulo = 0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$server["img"] = '';
|
$server["img"] = '';
|
||||||
$server["type"] = "unknown";
|
$server["type"] = "unknown";
|
||||||
|
@ -2711,12 +2711,19 @@ function visual_map_process_wizard_add_modules ($id_modules, $image,
|
|||||||
function get_donut_module_data ($id_module) {
|
function get_donut_module_data ($id_module) {
|
||||||
$mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module));
|
$mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module));
|
||||||
|
|
||||||
|
$no_data_to_show = false;
|
||||||
|
|
||||||
if (preg_match("/\r\n/", $mod_values)) {
|
if (preg_match("/\r\n/", $mod_values)) {
|
||||||
$values = explode("\r\n", $mod_values);
|
$values = explode("\r\n", $mod_values);
|
||||||
}
|
}
|
||||||
elseif (preg_match("/\n/", $mod_values)) {
|
elseif (preg_match("/\n/", $mod_values)) {
|
||||||
$values = explode("\n", $mod_values);
|
$values = explode("\n", $mod_values);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$values=array(__('No data to show').",1");
|
||||||
|
$no_data_to_show=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$colors = array();
|
$colors = array();
|
||||||
$colors[] = "#aa3333";
|
$colors[] = "#aa3333";
|
||||||
@ -2737,7 +2744,12 @@ function get_donut_module_data ($id_module) {
|
|||||||
if ($data[1] == 0) {
|
if ($data[1] == 0) {
|
||||||
$data[1] = __('No data');
|
$data[1] = __('No data');
|
||||||
}
|
}
|
||||||
$values_to_return[$index]['tag_name'] = $data[0] . ": " . $data[1];
|
|
||||||
|
if ($no_data_to_show)
|
||||||
|
$values_to_return[$index]['tag_name'] = $data[0];
|
||||||
|
else
|
||||||
|
$values_to_return[$index]['tag_name'] = $data[0] . ": " . $data[1];
|
||||||
|
|
||||||
$values_to_return[$index]['color'] = $colors[$index];
|
$values_to_return[$index]['color'] = $colors[$index];
|
||||||
$values_to_return[$index]['value'] = (int)$data[1];
|
$values_to_return[$index]['value'] = (int)$data[1];
|
||||||
$total += (int)$data[1];
|
$total += (int)$data[1];
|
||||||
|
@ -881,6 +881,7 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||||||
var grid_color = params.grid_color;
|
var grid_color = params.grid_color;
|
||||||
var background_color = params.backgroundColor;
|
var background_color = params.backgroundColor;
|
||||||
var legend_color = params.legend_color;
|
var legend_color = params.legend_color;
|
||||||
|
var update_legend = {};
|
||||||
|
|
||||||
//XXXXXX colocar
|
//XXXXXX colocar
|
||||||
var force_integer = 0;
|
var force_integer = 0;
|
||||||
@ -1553,6 +1554,12 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(series_type[index] != 'boolean'){
|
||||||
|
if(value.slice_data){
|
||||||
|
update_legend[index] = value.slice_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//in graph stacked unset percentil
|
//in graph stacked unset percentil
|
||||||
if( ! ( (type == 1) && ( /percentil/.test(index) ) == true ) &&
|
if( ! ( (type == 1) && ( /percentil/.test(index) ) == true ) &&
|
||||||
! ( (type == 3) && ( /percentil/.test(index) ) == true ) ){
|
! ( (type == 3) && ( /percentil/.test(index) ) == true ) ){
|
||||||
@ -1582,9 +1589,6 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||||||
// The first execution, the graph data is the base data
|
// The first execution, the graph data is the base data
|
||||||
datas = data_base;
|
datas = data_base;
|
||||||
|
|
||||||
// minTickSize
|
|
||||||
var count_data = datas[0].data.length;
|
|
||||||
|
|
||||||
var number_ticks = 8;
|
var number_ticks = 8;
|
||||||
if(vconsole){
|
if(vconsole){
|
||||||
number_ticks = 5;
|
number_ticks = 5;
|
||||||
@ -1962,39 +1966,75 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||||||
|
|
||||||
if(series.data[j]){
|
if(series.data[j]){
|
||||||
var y = series.data[j][1];
|
var y = series.data[j][1];
|
||||||
|
var x = series.data[j][0] -1 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var how_bigger = "";
|
y_array = format_unit_yaxes(y);
|
||||||
if (y > 1000000) {
|
|
||||||
how_bigger = "M";
|
|
||||||
y = y / 1000000;
|
|
||||||
}
|
|
||||||
else if (y > 1000) {
|
|
||||||
how_bigger = "K";
|
|
||||||
y = y / 1000;
|
|
||||||
}
|
|
||||||
else if(y < -1000000) {
|
|
||||||
how_bigger = "M";
|
|
||||||
y = y / 1000000;
|
|
||||||
}
|
|
||||||
else if (y < -1000) {
|
|
||||||
how_bigger = "K";
|
|
||||||
y = y / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
var label_aux = legend[series.label];
|
y = y_array['y'];
|
||||||
|
how_bigger = y_array['unit'];
|
||||||
|
|
||||||
|
var data_legend = [];
|
||||||
|
|
||||||
// The graphs of points type and unknown graphs will dont be updated
|
// The graphs of points type and unknown graphs will dont be updated
|
||||||
if (series_type[dataset[k]["label"]] != 'points' &&
|
if (series_type[dataset[k]["label"]] != 'points' &&
|
||||||
series_type[dataset[k]["label"]] != 'unknown' &&
|
series_type[dataset[k]["label"]] != 'unknown' &&
|
||||||
series_type[dataset[k]["label"]] != 'percentil'
|
series_type[dataset[k]["label"]] != 'percentil'
|
||||||
) {
|
) {
|
||||||
$('#legend_' + graph_id + ' .legendLabel')
|
if(Object.keys(update_legend).length == 0){
|
||||||
.eq(i).html(label_aux + ' value = ' +
|
var label_aux = legend[series.label];
|
||||||
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
|
|
||||||
how_bigger + ' ' + unit
|
$('#legend_' + graph_id + ' .legendLabel')
|
||||||
);
|
.eq(i).html(label_aux + ' value = ' +
|
||||||
|
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
|
||||||
|
how_bigger + ' ' + unit
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$.each(update_legend, function (index, value) {
|
||||||
|
if(!value[x]){
|
||||||
|
x = x +1;
|
||||||
|
}
|
||||||
|
if(value[x].min){
|
||||||
|
min_y_array = format_unit_yaxes(value[x].min);
|
||||||
|
min_y = min_y_array['y'];
|
||||||
|
min_bigger = min_y_array['unit'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
min_y = 0;
|
||||||
|
min_bigger = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(value[x].max){
|
||||||
|
max_y_array = format_unit_yaxes(value[x].max);
|
||||||
|
max_y = max_y_array['y'];
|
||||||
|
max_bigger = max_y_array['unit'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
max_y = 0;
|
||||||
|
max_bigger = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(value[x].avg){
|
||||||
|
avg_y_array = format_unit_yaxes(value[x].avg);
|
||||||
|
avg_y = avg_y_array['y'];
|
||||||
|
avg_bigger = avg_y_array['unit'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
avg_y = 0;
|
||||||
|
avg_bigger = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
data_legend[index] =
|
||||||
|
' Min: ' + (short_data ? number_format(min_y, 0, "", short_data) : parseFloat(min_y)) + min_bigger
|
||||||
|
+ ' Max: ' + (short_data ? number_format(max_y, 0, "", short_data) : parseFloat(max_y)) + max_bigger
|
||||||
|
+ ' Avg: ' + (short_data ? number_format(avg_y, 0, "", short_data) : parseFloat(avg_y)) + avg_bigger;
|
||||||
|
});
|
||||||
|
|
||||||
|
var label_aux = legend[series.label] + data_legend[series.label];
|
||||||
|
$('#legend_' + graph_id + ' .legendLabel').eq(i).html(label_aux);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#legend_' + graph_id + ' .legendLabel').eq(i).css('color', legend_color);
|
$('#legend_' + graph_id + ' .legendLabel').eq(i).css('color', legend_color);
|
||||||
@ -2317,6 +2357,33 @@ function pandoraFlotArea( graph_id, values, legend,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function format_unit_yaxes(y){
|
||||||
|
var how_bigger = [];
|
||||||
|
|
||||||
|
if (y > 1000000) {
|
||||||
|
how_bigger['unit'] = "M";
|
||||||
|
how_bigger['y'] = y / 1000000;
|
||||||
|
}
|
||||||
|
else if (y > 1000) {
|
||||||
|
how_bigger['unit'] = "K";
|
||||||
|
how_bigger['y'] = y / 1000;
|
||||||
|
}
|
||||||
|
else if(y < -1000000) {
|
||||||
|
how_bigger['unit'] = "M";
|
||||||
|
how_bigger['y'] = y / 1000000;
|
||||||
|
}
|
||||||
|
else if (y < -1000) {
|
||||||
|
how_bigger['unit'] = "K";
|
||||||
|
how_bigger['y'] = y / 1000;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
how_bigger['unit'] = "";
|
||||||
|
how_bigger['y'] = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return how_bigger;
|
||||||
|
}
|
||||||
|
|
||||||
function adjust_menu(graph_id, plot, parent_height, width, show_legend) {
|
function adjust_menu(graph_id, plot, parent_height, width, show_legend) {
|
||||||
if ($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
|
if ($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
|
||||||
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];
|
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<div style='height: 10px'>
|
<div style='height: 10px'>
|
||||||
<?php
|
<?php
|
||||||
$version = '7.0NG.724';
|
$version = '7.0NG.724';
|
||||||
$build = '180628';
|
$build = '180709';
|
||||||
$banner = "v$version Build $build";
|
$banner = "v$version Build $build";
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
@ -244,7 +244,7 @@ if (empty($export_btn) || $show_form) {
|
|||||||
$groups = users_get_groups ($config['id_user'], "RR", users_can_manage_group_all());
|
$groups = users_get_groups ($config['id_user'], "RR", users_can_manage_group_all());
|
||||||
|
|
||||||
$table->data[0][1] = html_print_select_groups($config['id_user'],
|
$table->data[0][1] = html_print_select_groups($config['id_user'],
|
||||||
"RR", users_can_manage_group_all(), "group", $group, '', '', 0, true, false, true,
|
"RR", true, "group", $group, '', '', 0, true, false, true,
|
||||||
'', false);
|
'', false);
|
||||||
|
|
||||||
//Agent selector
|
//Agent selector
|
||||||
|
@ -223,13 +223,9 @@ else {
|
|||||||
100,true);
|
100,true);
|
||||||
$table->data[1][0] = __('Group');
|
$table->data[1][0] = __('Group');
|
||||||
|
|
||||||
// Only display group "All" if user is administrator
|
|
||||||
// or has "AR" privileges
|
|
||||||
|
|
||||||
$display_all_group = (users_is_admin() || users_can_manage_group_all("AR"));
|
|
||||||
|
|
||||||
$table->data[1][1] = html_print_select_groups($config['id_user'], "AR",
|
$table->data[1][1] = html_print_select_groups($config['id_user'], "AR",
|
||||||
$display_all_group, 'id_group', $idGroup, '', '', '', true);
|
true, 'id_group', $idGroup, '', '', '', true);
|
||||||
|
|
||||||
$table->data[2][0] = __('Node radius');
|
$table->data[2][0] = __('Node radius');
|
||||||
$table->data[2][1] = html_print_input_text ('node_radius', $node_radius, '', 2,
|
$table->data[2][1] = html_print_input_text ('node_radius', $node_radius, '', 2,
|
||||||
|
@ -114,19 +114,9 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
|
|||||||
// ACL
|
// ACL
|
||||||
$permission = false;
|
$permission = false;
|
||||||
$agent_group = (int) agents_get_agent_group($agent_id);
|
$agent_group = (int) agents_get_agent_group($agent_id);
|
||||||
$strict_user = (bool) db_get_value("strict_acl", "tusuario",
|
$permission = check_acl($config['id_user'], $agent_group, "AR");
|
||||||
"id_user", $config['id_user']);
|
|
||||||
|
if (!$permission) {
|
||||||
if (!empty($agent_group)) {
|
|
||||||
if ($strict_user) {
|
|
||||||
$permission = tags_check_acl_by_module($id, $config['id_user'], 'RR') === true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$permission = check_acl($config['id_user'], $agent_group, "RR");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$permission) {
|
|
||||||
require ($config['homedir'] . "/general/noaccess.php");
|
require ($config['homedir'] . "/general/noaccess.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -305,7 +295,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
|
|||||||
$options[2] = 'x2';
|
$options[2] = 'x2';
|
||||||
$options[3] = 'x3';
|
$options[3] = 'x3';
|
||||||
$options[4] = 'x4';
|
$options[4] = 'x4';
|
||||||
$options[5] = __('full');
|
$options[5] = 'x5';
|
||||||
$data[1] = html_print_select ($options, "zoom", $zoom, '', '', 0, true, false, false);
|
$data[1] = html_print_select ($options, "zoom", $zoom, '', '', 0, true, false, false);
|
||||||
$table->data[] = $data;
|
$table->data[] = $data;
|
||||||
$table->rowclass[] = '';
|
$table->rowclass[] = '';
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 7.0NG.724
|
%define version 7.0NG.724
|
||||||
%define release 180628
|
%define release 180709
|
||||||
|
|
||||||
# User and Group under which Apache is running
|
# User and Group under which Apache is running
|
||||||
%define httpd_name httpd
|
%define httpd_name httpd
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 7.0NG.724
|
%define version 7.0NG.724
|
||||||
%define release 180628
|
%define release 180709
|
||||||
%define httpd_name httpd
|
%define httpd_name httpd
|
||||||
# User and Group under which Apache is running
|
# User and Group under which Apache is running
|
||||||
%define httpd_name apache2
|
%define httpd_name apache2
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package: pandorafms-server
|
package: pandorafms-server
|
||||||
Version: 7.0NG.724-180628
|
Version: 7.0NG.724-180709
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
pandora_version="7.0NG.724-180628"
|
pandora_version="7.0NG.724-180709"
|
||||||
|
|
||||||
package_cpan=0
|
package_cpan=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -60,6 +60,8 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use IO::Compress::Zip qw(zip $ZipError);
|
||||||
|
use IO::Uncompress::Unzip qw(unzip $UnzipError);
|
||||||
use threads;
|
use threads;
|
||||||
use Thread::Semaphore;
|
use Thread::Semaphore;
|
||||||
use POSIX ":sys_wait_h";
|
use POSIX ":sys_wait_h";
|
||||||
@ -959,6 +961,15 @@ sub serve_connection {
|
|||||||
print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
|
print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
|
||||||
send_file ($1);
|
send_file ($1);
|
||||||
}
|
}
|
||||||
|
elsif ($command =~ /^ZSEND <(.*)> SIZE (\d+)$/) {
|
||||||
|
print_info ("Request to send compressed file '$1' size ${2}b from " . $t_client_socket->sockhost ());
|
||||||
|
zrecv_file ($1, $2);
|
||||||
|
}
|
||||||
|
# Client wants to receive a file
|
||||||
|
elsif ($command =~ /^ZRECV <(.*)>$/) {
|
||||||
|
print_info ("Request to receive compressed file '$1' from " . $t_client_socket->sockhost ());
|
||||||
|
zsend_file ($1);
|
||||||
|
}
|
||||||
# Quit
|
# Quit
|
||||||
elsif ($command =~ /^QUIT$/) {
|
elsif ($command =~ /^QUIT$/) {
|
||||||
print_info ("Connection closed from " . $t_client_socket->sockhost ());
|
print_info ("Connection closed from " . $t_client_socket->sockhost ());
|
||||||
@ -1070,6 +1081,61 @@ sub recv_file {
|
|||||||
print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zrecv_file
|
||||||
|
## Receive a compressed file of size $_[1] and save it in $t_directory as $_[0].
|
||||||
|
################################################################################
|
||||||
|
sub zrecv_file {
|
||||||
|
my $base_name = $_[0];
|
||||||
|
my $data = '';
|
||||||
|
my $file;
|
||||||
|
my $size = $_[1];
|
||||||
|
my $zdata = '';
|
||||||
|
|
||||||
|
# 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 ("ZSEND 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 ("ZSEND ERR (file is too big)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
|
||||||
|
|
||||||
|
# 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 ("ZSEND ERR (file already exists)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
send_data ("ZSEND OK\n");
|
||||||
|
|
||||||
|
# Receive file
|
||||||
|
$zdata = recv_data_block ($size);
|
||||||
|
if (!unzip(\$zdata => \$data)) {
|
||||||
|
print_log ("Uncompress error: $UnzipError");
|
||||||
|
send_data ("ZSEND ERR\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write it to disk
|
||||||
|
open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
|
||||||
|
binmode (FILE);
|
||||||
|
print (FILE $data);
|
||||||
|
close (FILE);
|
||||||
|
|
||||||
|
send_data ("ZSEND OK\n");
|
||||||
|
print_info ("Received compressed file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
## SUB send_file
|
## SUB send_file
|
||||||
## Send a file to the client
|
## Send a file to the client
|
||||||
@ -1122,6 +1188,57 @@ sub send_file {
|
|||||||
print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
|
print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## SUB zsend_file
|
||||||
|
## Send a file to the client
|
||||||
|
################################################################################
|
||||||
|
sub zsend_file {
|
||||||
|
my $base_name = $_[0];
|
||||||
|
my $data = '';
|
||||||
|
my $file;
|
||||||
|
my $response;
|
||||||
|
my $size;
|
||||||
|
|
||||||
|
# Check file name
|
||||||
|
if ($base_name =~ /[$t_invalid_chars]/) {
|
||||||
|
print_log ("Requested compressed file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name");
|
||||||
|
send_data ("ZRECV ERR (file has an invalid file name)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if (! -f $file) {
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " does not exist");
|
||||||
|
send_data ("ZRECV ERR (file does not exist)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read the file and compress its contents
|
||||||
|
if (! zip($file => \$data)) {
|
||||||
|
send_data ("QUIT\n");
|
||||||
|
error ("Compression error: $ZipError");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = length($data);
|
||||||
|
send_data ("ZRECV SIZE $size\n");
|
||||||
|
|
||||||
|
# Wait for client response
|
||||||
|
$response = recv_command ($t_block_size);
|
||||||
|
if ($response ne "ZRECV OK") {
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " not sent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the file
|
||||||
|
send_data ($data);
|
||||||
|
|
||||||
|
print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " sent");
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common functions
|
# Common functions
|
||||||
################################################################################
|
################################################################################
|
||||||
|
Binary file not shown.
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
|||||||
|
|
||||||
# version: Defines actual version of Pandora Server for this module only
|
# version: Defines actual version of Pandora Server for this module only
|
||||||
my $pandora_version = "7.0NG.724";
|
my $pandora_version = "7.0NG.724";
|
||||||
my $pandora_build = "180628";
|
my $pandora_build = "180709";
|
||||||
our $VERSION = $pandora_version." ".$pandora_build;
|
our $VERSION = $pandora_version." ".$pandora_build;
|
||||||
|
|
||||||
# Setup hash
|
# Setup hash
|
||||||
|
@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
|
|||||||
|
|
||||||
# version: Defines actual version of Pandora Server for this module only
|
# version: Defines actual version of Pandora Server for this module only
|
||||||
my $pandora_version = "7.0NG.724";
|
my $pandora_version = "7.0NG.724";
|
||||||
my $pandora_build = "180628";
|
my $pandora_build = "180709";
|
||||||
our $VERSION = $pandora_version." ".$pandora_build;
|
our $VERSION = $pandora_version." ".$pandora_build;
|
||||||
|
|
||||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_server
|
%define name pandorafms_server
|
||||||
%define version 7.0NG.724
|
%define version 7.0NG.724
|
||||||
%define release 180628
|
%define release 180709
|
||||||
|
|
||||||
Summary: Pandora FMS Server
|
Summary: Pandora FMS Server
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
%define name pandorafms_server
|
%define name pandorafms_server
|
||||||
%define version 7.0NG.724
|
%define version 7.0NG.724
|
||||||
%define release 180628
|
%define release 180709
|
||||||
|
|
||||||
Summary: Pandora FMS Server
|
Summary: Pandora FMS Server
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
# **********************************************************************
|
# **********************************************************************
|
||||||
|
|
||||||
PI_VERSION="7.0NG.724"
|
PI_VERSION="7.0NG.724"
|
||||||
PI_BUILD="180628"
|
PI_BUILD="180709"
|
||||||
|
|
||||||
MODE=$1
|
MODE=$1
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
|
@ -34,7 +34,7 @@ use PandoraFMS::Config;
|
|||||||
use PandoraFMS::DB;
|
use PandoraFMS::DB;
|
||||||
|
|
||||||
# version: define current version
|
# version: define current version
|
||||||
my $version = "7.0NG.724 PS180628";
|
my $version = "7.0NG.724 PS180709";
|
||||||
|
|
||||||
# Pandora server configuration
|
# Pandora server configuration
|
||||||
my %conf;
|
my %conf;
|
||||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||||||
Encode::Locale::decode_argv;
|
Encode::Locale::decode_argv;
|
||||||
|
|
||||||
# version: define current version
|
# version: define current version
|
||||||
my $version = "7.0NG.724 PS180628";
|
my $version = "7.0NG.724 PS180709";
|
||||||
|
|
||||||
# save program name for logging
|
# save program name for logging
|
||||||
my $progname = basename($0);
|
my $progname = basename($0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user