From d0a0df86e805be51a693d73ba87687abb020b32a Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 18 Feb 2013 16:24:39 +0000 Subject: [PATCH] 2013-02-18 Miguel de Dios * util/pandora_xml_stress.pl: fixed the output the string module data in the XML. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7672 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++ pandora_server/util/pandora_xml_stress.pl | 38 ++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 2f53097602..0c7f991929 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2013-02-18 Miguel de Dios + + * util/pandora_xml_stress.pl: fixed the output the string module + data in the XML. + 2013-02-18 Sergio Martin * lib/PandoraFMS/Core.pm diff --git a/pandora_server/util/pandora_xml_stress.pl b/pandora_server/util/pandora_xml_stress.pl index 3dfdeb9df6..7954a4d89f 100755 --- a/pandora_server/util/pandora_xml_stress.pl +++ b/pandora_server/util/pandora_xml_stress.pl @@ -213,17 +213,18 @@ sub generate_xml_files ($$$$$$) { $rnd_data = generate_curve_data ($utimestamp, $module_min, $module_max, $module_time_wave_length, $module_time_offset); } - }elsif ($generation_type eq 'SOURCE') { - $rnd_data = generate_data_from_source($module_name, $module_src, \%modules_src_pointers); - + } + elsif ($generation_type eq 'SOURCE') { + $rnd_data = generate_data_from_source($module_name, $module_src, \%modules_src_pointers); + } # Save previous data $module->{'module_data'} = $rnd_data; - $xml_data .= "\t\t$rnd_data\n"; + $xml_data .= "\t\t\n"; $xml_data .= "\t\n"; } - + $xml_data .= "\n"; # Fix the temporal path @@ -306,7 +307,7 @@ sub generate_curve_data ($$$$$$) { my $return = ($module_max - $module_min)/2 * sin( ($utimestamp * pi) / $module_time_wave_length + (pi * ($module_time_offset / $module_time_wave_length))) + ($module_min + $module_max) / 2; - + return $return; } @@ -318,8 +319,8 @@ sub generate_scatter_data ($$$$$$) { # And check the probability now my $other_rnd = int rand(100); - - if ( $prob >= $other_rnd) { + + if ($prob >= $other_rnd) { return int (rand ($max - $min + 1) + $min); } else { @@ -332,11 +333,11 @@ sub generate_scatter_data ($$$$$$) { ################################################################################ sub generate_data_from_source ($$$) { my ($module_name, $module_src, $pointers) = @_; - + my $data = 0; my $pointer; - + if (-e $module_src) { #Get data and split to an array @@ -347,12 +348,13 @@ sub generate_data_from_source ($$$) { $module_name =~ s/\ /\_/; $pointer = $pointers->{$module_name}; - + $pointer = $pointer % ($#data_array+1); - + $data = $data_array[$pointer]; - } else { + } + else { #There was an error, set last to 0 and return data return $data; } @@ -376,9 +378,9 @@ sub init_src_pointers ($) { my $type = get_generation_parameter($mod, 'type', 'RANDOM'); if ($type eq 'SOURCE') { - + $module_name =~ s/\ /\_/; - + $pointers{$module_name} = 0; } } @@ -392,7 +394,7 @@ sub init_src_pointers ($) { sub update_src_pointers ($) { my ($pointers) = shift; - + foreach my $p (keys %{$pointers}) { #Add 1 to the pointer @@ -408,7 +410,7 @@ sub copy_xml_file ($$) { my $server_ip = get_conf_token ($conf, 'server_ip', ''); return if ($server_ip eq ''); - + my $server_port = get_conf_token ($conf, 'server_port', '41121'); my $tentacle_opts = get_conf_token ($conf, 'tentacle_opts', ''); @@ -451,7 +453,7 @@ sub get_generation_parameter($$$) { sub log_message ($$) { my ($conf, $message) = @_; my $utimestamp = time (); - + my $log_file = get_conf_token ($conf, 'log_file', ''); # Log to stdout