2013-02-18 Miguel de Dios <miguel.dedios@artica.es>

* 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
This commit is contained in:
mdtrooper 2013-02-18 16:24:39 +00:00
parent 87358525d4
commit 0fedf42ef7
2 changed files with 25 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2013-02-18 Miguel de Dios <miguel.dedios@artica.es>
* util/pandora_xml_stress.pl: fixed the output the string module
data in the XML.
2013-02-18 Sergio Martin <sergio.martin@artica.es> 2013-02-18 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/Core.pm * lib/PandoraFMS/Core.pm

View File

@ -213,17 +213,18 @@ sub generate_xml_files ($$$$$$) {
$rnd_data = generate_curve_data ($utimestamp, $module_min, $module_max, $rnd_data = generate_curve_data ($utimestamp, $module_min, $module_max,
$module_time_wave_length, $module_time_offset); $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 # Save previous data
$module->{'module_data'} = $rnd_data; $module->{'module_data'} = $rnd_data;
$xml_data .= "\t\t<data>$rnd_data</data>\n"; $xml_data .= "\t\t<data><![CDATA[$rnd_data]]></data>\n";
$xml_data .= "\t</module>\n"; $xml_data .= "\t</module>\n";
} }
$xml_data .= "</agent_data>\n"; $xml_data .= "</agent_data>\n";
# Fix the temporal path # Fix the temporal path
@ -306,7 +307,7 @@ sub generate_curve_data ($$$$$$) {
my $return = ($module_max - $module_min)/2 * my $return = ($module_max - $module_min)/2 *
sin( ($utimestamp * pi) / $module_time_wave_length + sin( ($utimestamp * pi) / $module_time_wave_length +
(pi * ($module_time_offset / $module_time_wave_length))) + ($module_min + $module_max) / 2; (pi * ($module_time_offset / $module_time_wave_length))) + ($module_min + $module_max) / 2;
return $return; return $return;
} }
@ -318,8 +319,8 @@ sub generate_scatter_data ($$$$$$) {
# And check the probability now # And check the probability now
my $other_rnd = int rand(100); my $other_rnd = int rand(100);
if ( $prob >= $other_rnd) { if ($prob >= $other_rnd) {
return int (rand ($max - $min + 1) + $min); return int (rand ($max - $min + 1) + $min);
} }
else { else {
@ -332,11 +333,11 @@ sub generate_scatter_data ($$$$$$) {
################################################################################ ################################################################################
sub generate_data_from_source ($$$) { sub generate_data_from_source ($$$) {
my ($module_name, $module_src, $pointers) = @_; my ($module_name, $module_src, $pointers) = @_;
my $data = 0; my $data = 0;
my $pointer; my $pointer;
if (-e $module_src) { if (-e $module_src) {
#Get data and split to an array #Get data and split to an array
@ -347,12 +348,13 @@ sub generate_data_from_source ($$$) {
$module_name =~ s/\ /\_/; $module_name =~ s/\ /\_/;
$pointer = $pointers->{$module_name}; $pointer = $pointers->{$module_name};
$pointer = $pointer % ($#data_array+1); $pointer = $pointer % ($#data_array+1);
$data = $data_array[$pointer]; $data = $data_array[$pointer];
} else { }
else {
#There was an error, set last to 0 and return data #There was an error, set last to 0 and return data
return $data; return $data;
} }
@ -376,9 +378,9 @@ sub init_src_pointers ($) {
my $type = get_generation_parameter($mod, 'type', 'RANDOM'); my $type = get_generation_parameter($mod, 'type', 'RANDOM');
if ($type eq 'SOURCE') { if ($type eq 'SOURCE') {
$module_name =~ s/\ /\_/; $module_name =~ s/\ /\_/;
$pointers{$module_name} = 0; $pointers{$module_name} = 0;
} }
} }
@ -392,7 +394,7 @@ sub init_src_pointers ($) {
sub update_src_pointers ($) { sub update_src_pointers ($) {
my ($pointers) = shift; my ($pointers) = shift;
foreach my $p (keys %{$pointers}) { foreach my $p (keys %{$pointers}) {
#Add 1 to the pointer #Add 1 to the pointer
@ -408,7 +410,7 @@ sub copy_xml_file ($$) {
my $server_ip = get_conf_token ($conf, 'server_ip', ''); my $server_ip = get_conf_token ($conf, 'server_ip', '');
return if ($server_ip eq ''); return if ($server_ip eq '');
my $server_port = get_conf_token ($conf, 'server_port', '41121'); my $server_port = get_conf_token ($conf, 'server_port', '41121');
my $tentacle_opts = get_conf_token ($conf, 'tentacle_opts', ''); my $tentacle_opts = get_conf_token ($conf, 'tentacle_opts', '');
@ -451,7 +453,7 @@ sub get_generation_parameter($$$) {
sub log_message ($$) { sub log_message ($$) {
my ($conf, $message) = @_; my ($conf, $message) = @_;
my $utimestamp = time (); my $utimestamp = time ();
my $log_file = get_conf_token ($conf, 'log_file', ''); my $log_file = get_conf_token ($conf, 'log_file', '');
# Log to stdout # Log to stdout