2013-06-19 Miguel de Dios <miguel.dedios@artica.es>

* 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.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8349 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-06-19 08:53:56 +00:00
parent f540aa956b
commit 75cf25b665
3 changed files with 50 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2013-06-19 Miguel de Dios <miguel.dedios@artica.es>
* 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 <sergio.martin@artica.es>
* lib/PandoraFMS/Core.pm: Fixed comments addition in the

View File

@ -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

View File

@ -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) {