mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
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:
parent
f540aa956b
commit
75cf25b665
@ -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>
|
2013-06-14 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/Core.pm: Fixed comments addition in the
|
* lib/PandoraFMS/Core.pm: Fixed comments addition in the
|
||||||
|
@ -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.
|
# Directory where XML data files will be placed, by default /tmp.
|
||||||
# When sending files to a local Tentacle server make sure this directory
|
# When sending files to a local Tentacle server make sure this directory
|
||||||
# and Pandora FMS Server's incomingdir are different.
|
# 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.
|
# Pandora FMS XML Stress log file, logs to stdout by default.
|
||||||
log_file pandora_xml_stress.log
|
log_file pandora_xml_stress.log
|
||||||
@ -72,7 +72,13 @@ altitude_base 0
|
|||||||
position_radius 10
|
position_radius 10
|
||||||
|
|
||||||
# Address of the Tentacle server where XML files will be sent (optional).
|
# 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.
|
# Port of the Tentacle server, by default 41121.
|
||||||
# server_port 41121
|
# server_port 41121
|
||||||
|
@ -272,12 +272,13 @@ sub generate_xml_files ($$$$$$) {
|
|||||||
|
|
||||||
# Save the XML data file
|
# Save the XML data file
|
||||||
# The temporal dir is normaly the /var/spool/pandora/data_in
|
# The temporal dir is normaly the /var/spool/pandora/data_in
|
||||||
my $xml_file = $temporal . '/' . $agent_name . '_' . $utimestamp . '.data';
|
my $xml_fullpath_file = $temporal . '/' . $agent_name . '_' . $utimestamp . '.data';
|
||||||
open (FILE, ">", $xml_file) || die ("[error] Could not write to '$xml_file': $!.\n\n");
|
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;
|
print FILE $xml_data;
|
||||||
close (FILE);
|
close (FILE);
|
||||||
|
|
||||||
copy_xml_file ($conf, $xml_file);
|
copy_xml_file ($conf, $xml_fullpath_file, $xml_file);
|
||||||
$XMLFiles++;
|
$XMLFiles++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,16 +446,29 @@ sub update_src_pointers ($) {
|
|||||||
# Returns the value of a configuration token.
|
# Returns the value of a configuration token.
|
||||||
################################################################################
|
################################################################################
|
||||||
sub copy_xml_file ($$) {
|
sub copy_xml_file ($$) {
|
||||||
my ($conf, $file) = @_;
|
my ($conf, $fullpath_file, $file) = @_;
|
||||||
|
|
||||||
my $server_ip = get_conf_token ($conf, 'server_ip', '');
|
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');
|
if ($local_copy) {
|
||||||
my $tentacle_opts = get_conf_token ($conf, 'tentacle_opts', '');
|
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);
|
unlink ($file);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -567,39 +581,39 @@ sub md5_init () {
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
sub md5 ($) {
|
sub md5 ($) {
|
||||||
my $str = shift;
|
my $str = shift;
|
||||||
|
|
||||||
# Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating
|
# Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating
|
||||||
|
|
||||||
# Initialize variables
|
# Initialize variables
|
||||||
my $h0 = 0x67452301;
|
my $h0 = 0x67452301;
|
||||||
my $h1 = 0xEFCDAB89;
|
my $h1 = 0xEFCDAB89;
|
||||||
my $h2 = 0x98BADCFE;
|
my $h2 = 0x98BADCFE;
|
||||||
my $h3 = 0x10325476;
|
my $h3 = 0x10325476;
|
||||||
|
|
||||||
# Pre-processing
|
# Pre-processing
|
||||||
my $msg = unpack ("B*", pack ("A*", $str));
|
my $msg = unpack ("B*", pack ("A*", $str));
|
||||||
my $bit_len = length ($msg);
|
my $bit_len = length ($msg);
|
||||||
|
|
||||||
# Append "1" bit to message
|
# Append "1" bit to message
|
||||||
$msg .= '1';
|
$msg .= '1';
|
||||||
|
|
||||||
# Append "0" bits until message length in bits ≡ 448 (mod 512)
|
# Append "0" bits until message length in bits ≡ 448 (mod 512)
|
||||||
$msg .= '0' while ((length ($msg) % 512) != 448);
|
$msg .= '0' while ((length ($msg) % 512) != 448);
|
||||||
|
|
||||||
# Append bit /* bit, not byte */ length of unpadded message as 64-bit little-endian integer to message
|
# Append bit /* bit, not byte */ length of unpadded message as 64-bit little-endian integer to message
|
||||||
$msg .= unpack ("B64", pack ("VV", $bit_len));
|
$msg .= unpack ("B64", pack ("VV", $bit_len));
|
||||||
|
|
||||||
# Process the message in successive 512-bit chunks
|
# Process the message in successive 512-bit chunks
|
||||||
for (my $i = 0; $i < length ($msg); $i += 512) {
|
for (my $i = 0; $i < length ($msg); $i += 512) {
|
||||||
|
|
||||||
my @w;
|
my @w;
|
||||||
my $chunk = substr ($msg, $i, 512);
|
my $chunk = substr ($msg, $i, 512);
|
||||||
|
|
||||||
# Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <= 15
|
# Break chunk into sixteen 32-bit little-endian words w[i], 0 <= i <= 15
|
||||||
for (my $j = 0; $j < length ($chunk); $j += 32) {
|
for (my $j = 0; $j < length ($chunk); $j += 32) {
|
||||||
push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32))));
|
push (@w, unpack ("V", pack ("B32", substr ($chunk, $j, 32))));
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialize hash value for this chunk
|
# Initialize hash value for this chunk
|
||||||
my $a = $h0;
|
my $a = $h0;
|
||||||
my $b = $h1;
|
my $b = $h1;
|
||||||
@ -607,7 +621,7 @@ sub md5 ($) {
|
|||||||
my $d = $h3;
|
my $d = $h3;
|
||||||
my $f;
|
my $f;
|
||||||
my $g;
|
my $g;
|
||||||
|
|
||||||
# Main loop
|
# Main loop
|
||||||
for (my $y = 0; $y < 64; $y++) {
|
for (my $y = 0; $y < 64; $y++) {
|
||||||
if ($y <= 15) {
|
if ($y <= 15) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user