diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 2fb590657d..b65e3263cd 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2013-06-19 Miguel de Dios + + * util/pandora_xml_stress.pl: fixed the send across tentacle, now + when it can not send the file almost the log have a error entry. + And added local send method. + + * util/pandora_xml_stress.conf: added confs for local send method. + 2013-06-14 Sergio Martin * lib/PandoraFMS/Core.pm: Fixed comments addition in the diff --git a/pandora_server/util/pandora_xml_stress.conf b/pandora_server/util/pandora_xml_stress.conf index 87a8b81714..6650f9874a 100644 --- a/pandora_server/util/pandora_xml_stress.conf +++ b/pandora_server/util/pandora_xml_stress.conf @@ -11,7 +11,7 @@ agent_file /usr/share/pandora_server/util/pandora_xml_stress.agents # Directory where XML data files will be placed, by default /tmp. # When sending files to a local Tentacle server make sure this directory # and Pandora FMS Server's incomingdir are different. -temporal /var/spool/pandora/data_in +temporal /tmp # Pandora FMS XML Stress log file, logs to stdout by default. log_file pandora_xml_stress.log @@ -72,7 +72,13 @@ altitude_base 0 position_radius 10 # Address of the Tentacle server where XML files will be sent (optional). -# server_ip 192.168.50.1 +server_ip 127.0.0.1 + +# Local copy XML files, by default 0 +local_copy 1 + +# Local dir for to copy XML files in local send method, by defaul /var/spool/pandora/data_in +#local_dir /var/spool/pandora/data_in # Port of the Tentacle server, by default 41121. # server_port 41121 diff --git a/pandora_server/util/pandora_xml_stress.pl b/pandora_server/util/pandora_xml_stress.pl index 8842d49b85..8c2fd142e0 100755 --- a/pandora_server/util/pandora_xml_stress.pl +++ b/pandora_server/util/pandora_xml_stress.pl @@ -272,12 +272,13 @@ sub generate_xml_files ($$$$$$) { # Save the XML data file # The temporal dir is normaly the /var/spool/pandora/data_in - my $xml_file = $temporal . '/' . $agent_name . '_' . $utimestamp . '.data'; - open (FILE, ">", $xml_file) || die ("[error] Could not write to '$xml_file': $!.\n\n"); + my $xml_fullpath_file = $temporal . '/' . $agent_name . '_' . $utimestamp . '.data'; + my $xml_file = $agent_name . '_' . $utimestamp . '.data'; + open (FILE, ">", $xml_fullpath_file) || die ("[error] Could not write to '$xml_fullpath_file': $!.\n\n"); print FILE $xml_data; close (FILE); - copy_xml_file ($conf, $xml_file); + copy_xml_file ($conf, $xml_fullpath_file, $xml_file); $XMLFiles++; } @@ -445,16 +446,29 @@ sub update_src_pointers ($) { # Returns the value of a configuration token. ################################################################################ sub copy_xml_file ($$) { - my ($conf, $file) = @_; + my ($conf, $fullpath_file, $file) = @_; my $server_ip = get_conf_token ($conf, 'server_ip', ''); - return if ($server_ip eq ''); + my $local_copy = get_conf_token($conf, 'local_copy', 0); - my $server_port = get_conf_token ($conf, 'server_port', '41121'); - my $tentacle_opts = get_conf_token ($conf, 'tentacle_opts', ''); + if ($local_copy) { + my $local_dir = get_conf_token($conf, 'local_dir', '/var/spool/pandora/data_in'); + + move("$fullpath_file", "$local_dir/$file"); + } + else { + return if ($server_ip eq ''); + + my $server_port = get_conf_token ($conf, 'server_port', '41121'); + my $tentacle_opts = get_conf_token ($conf, 'tentacle_opts', ''); + + # Send the file and delete it + `tentacle_client -a $server_ip -p $server_port $tentacle_opts "$fullpath_file" > /dev/null 2>&1`; + if ($? != 0) { + log_message ($conf, "\tERROR:\tTry to send XML file (" . $file . ") with tentacle\n"); + } + } - # Send the file and delete it - `tentacle_client -a $server_ip -p $server_port $tentacle_opts "$file" > /dev/null 2>&1`; unlink ($file); } @@ -567,39 +581,39 @@ sub md5_init () { ############################################################################### sub md5 ($) { my $str = shift; - + # Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating - + # Initialize variables my $h0 = 0x67452301; my $h1 = 0xEFCDAB89; my $h2 = 0x98BADCFE; my $h3 = 0x10325476; - + # Pre-processing my $msg = unpack ("B*", pack ("A*", $str)); my $bit_len = length ($msg); - + # Append "1" bit to message $msg .= '1'; - + # Append "0" bits until message length in bits ≡ 448 (mod 512) $msg .= '0' while ((length ($msg) % 512) != 448); - + # Append bit /* bit, not byte */ length of unpadded message as 64-bit little-endian integer to message $msg .= unpack ("B64", pack ("VV", $bit_len)); - + # Process the message in successive 512-bit chunks for (my $i = 0; $i < length ($msg); $i += 512) { - + my @w; my $chunk = substr ($msg, $i, 512); - + # Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <= 15 for (my $j = 0; $j < length ($chunk); $j += 32) { push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32)))); } - + # Initialize hash value for this chunk my $a = $h0; my $b = $h1; @@ -607,7 +621,7 @@ sub md5 ($) { my $d = $h3; my $f; my $g; - + # Main loop for (my $y = 0; $y < 64; $y++) { if ($y <= 15) {