mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
2012-09-28 Dario Rodriguez <dario.rodriguez@artica.es>
* util/pandora_xml_stress.conf, util/pandora_xml_stress.pl, util/pandora_xml_stress_module_source.txt: Added new features to pandora_xml_stress program. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7007 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f701cdc957
commit
1c6ce0ca4f
@ -1,3 +1,10 @@
|
|||||||
|
2012-09-28 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
|
* util/pandora_xml_stress.conf,
|
||||||
|
util/pandora_xml_stress.pl,
|
||||||
|
util/pandora_xml_stress_module_source.txt: Added new
|
||||||
|
features to pandora_xml_stress program.
|
||||||
|
|
||||||
2012-09-26 Hirofumi Kosaka <kosaka@rworks.jp>
|
2012-09-26 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||||
|
|
||||||
* util/pandora_db.pl: bug fix: 'audit_purge' was used to purge
|
* util/pandora_db.pl: bug fix: 'audit_purge' was used to purge
|
||||||
|
@ -145,3 +145,10 @@ module_type generic_data_string
|
|||||||
module_description Messages from the system in logfile format
|
module_description Messages from the system in logfile format
|
||||||
module_exec type=RANDOM;variation=60;min=40;max=40
|
module_exec type=RANDOM;variation=60;min=40;max=40
|
||||||
module_end
|
module_end
|
||||||
|
|
||||||
|
module_begin
|
||||||
|
module_name Module source
|
||||||
|
module_type generic_data
|
||||||
|
module_description Module data generated from source
|
||||||
|
module_exec type=SOURCE;src=/usr/share/pandora_server/util/pandora_xml_stress_module_source.txt
|
||||||
|
module_end
|
||||||
|
@ -81,6 +81,7 @@ sub load_config ($\%\@) {
|
|||||||
close (FILE);
|
close (FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Generate XML files.
|
# Generate XML files.
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -113,6 +114,8 @@ sub generate_xml_files ($$$$$$) {
|
|||||||
die ("[error] Invalid time_to: $time_to\n\n") unless ($time_to =~ /(\d+)\-(\d+)\-(\d+) +(\d+):(\d+):(\d+)/);
|
die ("[error] Invalid time_to: $time_to\n\n") unless ($time_to =~ /(\d+)\-(\d+)\-(\d+) +(\d+):(\d+):(\d+)/);
|
||||||
my $utimestamp_to = timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900);
|
my $utimestamp_to = timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900);
|
||||||
|
|
||||||
|
my %modules_src_pointers = init_src_pointers($modules);
|
||||||
|
|
||||||
# Generate data files
|
# Generate data files
|
||||||
my $utimestamp = $utimestamp_from;
|
my $utimestamp = $utimestamp_from;
|
||||||
while ($utimestamp <= $utimestamp_to) {
|
while ($utimestamp <= $utimestamp_to) {
|
||||||
@ -164,6 +167,7 @@ sub generate_xml_files ($$$$$$) {
|
|||||||
my $module_avg = get_generation_parameter($module, 'avg', '127');
|
my $module_avg = get_generation_parameter($module, 'avg', '127');
|
||||||
my $module_time_wave_length = get_generation_parameter($module, 'time_wave_length', '0');
|
my $module_time_wave_length = get_generation_parameter($module, 'time_wave_length', '0');
|
||||||
my $module_time_offset = get_generation_parameter($module, 'time_offset', '0');
|
my $module_time_offset = get_generation_parameter($module, 'time_offset', '0');
|
||||||
|
my $module_src = get_generation_parameter($module, 'src', 'source.txt');
|
||||||
|
|
||||||
# Generate module data
|
# Generate module data
|
||||||
$xml_data .= "\t<module>\n";
|
$xml_data .= "\t<module>\n";
|
||||||
@ -208,6 +212,9 @@ 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Save previous data
|
# Save previous data
|
||||||
@ -233,6 +240,9 @@ sub generate_xml_files ($$$$$$) {
|
|||||||
$XMLFiles++;
|
$XMLFiles++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Update src pointers for a new xml
|
||||||
|
update_src_pointers(\%modules_src_pointers);
|
||||||
|
|
||||||
# First run, let the server create the new agent before sending more data
|
# First run, let the server create the new agent before sending more data
|
||||||
if ($utimestamp == $utimestamp_from) {
|
if ($utimestamp == $utimestamp_from) {
|
||||||
threads->yield ();
|
threads->yield ();
|
||||||
@ -316,6 +326,79 @@ sub generate_scatter_data ($$$$$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Generates data from a txt source
|
||||||
|
################################################################################
|
||||||
|
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
|
||||||
|
open (FD , "<", $module_src);
|
||||||
|
my @data_array = <FD>;
|
||||||
|
close(FD);
|
||||||
|
|
||||||
|
$module_name =~ s/\ /\_/;
|
||||||
|
|
||||||
|
$pointer = $pointers->{$module_name};
|
||||||
|
|
||||||
|
$pointer = $pointer % ($#data_array+1);
|
||||||
|
|
||||||
|
$data = $data_array[$pointer];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
#There was an error, set last to 0 and return data
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Initialize SRC pointer for src modules
|
||||||
|
################################################################################
|
||||||
|
sub init_src_pointers ($) {
|
||||||
|
my ($modules) = shift;
|
||||||
|
|
||||||
|
my %pointers;
|
||||||
|
|
||||||
|
foreach my $mod (@{$modules}) {
|
||||||
|
# Skip unnamed modules
|
||||||
|
my $module_name = get_conf_token ($mod, 'module_name', '');
|
||||||
|
next if ($module_name eq '');
|
||||||
|
|
||||||
|
my $type = get_generation_parameter($mod, 'type', 'RANDOM');
|
||||||
|
|
||||||
|
if ($type eq 'SOURCE') {
|
||||||
|
|
||||||
|
$module_name =~ s/\ /\_/;
|
||||||
|
|
||||||
|
$pointers{$module_name} = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return %pointers;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Updates SRC pointer for src modules
|
||||||
|
################################################################################
|
||||||
|
sub update_src_pointers ($) {
|
||||||
|
|
||||||
|
my ($pointers) = shift;
|
||||||
|
|
||||||
|
foreach my $p (keys %{$pointers}) {
|
||||||
|
|
||||||
|
#Add 1 to the pointer
|
||||||
|
$pointers->{$p}++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Returns the value of a configuration token.
|
# Returns the value of a configuration token.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
38
pandora_server/util/pandora_xml_stress_module_source.txt
Normal file
38
pandora_server/util/pandora_xml_stress_module_source.txt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
14
|
||||||
|
12
|
||||||
|
14
|
Loading…
x
Reference in New Issue
Block a user