2013-05-20 Ramon Novoa <rnovoa@artica.es>

* util/pandora_xml_stress.pl,
	  util/pandora_xml_stress.conf: Added support for data attenuation on
	  certain days.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8163 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2013-05-20 11:20:39 +00:00
parent b906f0b9ae
commit f249018d0a
3 changed files with 36 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2013-05-20 Ramon Novoa <rnovoa@artica.es>
* util/pandora_xml_stress.pl,
util/pandora_xml_stress.conf: Added support for data attenuation on
certain days.
2013-05-16 Ramon Novoa <rnovoa@artica.es>
* bin/pandora_server: Added information about the loading of the

View File

@ -1,4 +1,4 @@
o Sample configuration file for pandora_xmlstress
# Sample configuration file for pandora_xmlstress
# (c) 2012, http://pandorafms.org
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -87,6 +87,8 @@ module_exec type=RANDOM;variation=20;min=50;max=500
module_unit conns
module_min_critical 450
module_min_warning 400
module_attenuation 0.33
module_attenuation_wdays 0 6
module_end
module_begin
@ -104,6 +106,8 @@ module_description Network throughtput for incoming data
module_exec type=RANDOM;variation=50;min=0;max=1000000
module_unit kbit/sec
module_min_critical 900000
module_attenuation 0.5
module_attenuation_wdays 0 6
module_end
module_begin
@ -113,6 +117,8 @@ module_description Network throughtput for Outgoing data
module_exec type=RANDOM;variation=50;min=0;max=1000000
module_unit kbit/sec
module_min_critical 900000
module_attenuation 0.1
module_attenuation_wdays 0 6
module_end
module_begin

View File

@ -137,7 +137,9 @@ sub generate_xml_files ($$$$$$) {
my $ag_altitude = $altitude_base + (rand ($position_radius) - $position_radius/2)/100;
# XML header
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
my @localtime = localtime ($utimestamp);
my $wday = $localtime[6];
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", @localtime);
my $xml_data = "<?xml version='$xml_version' encoding='$encoding'?>\n";
my $sign = int rand(2);
$ag_timezone_offset += ($sign*(-1)+(1-$sign)) * int rand($ag_timezone_offset_range);
@ -152,6 +154,8 @@ sub generate_xml_files ($$$$$$) {
my $module_type = get_conf_token ($module, 'module_type', 'generic_data');
my $module_description = get_conf_token ($module, 'module_description', '');
my $module_unit = get_conf_token ($module, 'module_unit', '');
my $attenuation = get_conf_token ($module, 'module_attenuation', '0');
my @attenuation_wdays = get_conf_token_array ($module, 'module_attenuation_wdays', ' ');
#my $module_min = get_conf_token ($module, 'module_min', '0');
#my $module_max = get_conf_token ($module, 'module_max', '255');
@ -237,6 +241,11 @@ sub generate_xml_files ($$$$$$) {
}
# Data attenuation
if ($attenuation != 0 && ($#attenuation_wdays < 0 || $wday ~~ @attenuation_wdays)) {
$rnd_data *= $attenuation;
}
# Save previous data
$module->{'module_data'} = $rnd_data;
$xml_data .= "\t\t<data><![CDATA[$rnd_data]]></data>\n";
@ -448,6 +457,19 @@ sub get_conf_token ($$$) {
return $hash_ref->{$token};
}
################################################################################
# Returns the value of a configuration token.
################################################################################
sub get_conf_token_array ($$$) {
my ($hash_ref, $token, $separator) = @_;
my @tokens = ();
return @tokens unless ref ($hash_ref) and defined ($hash_ref->{$token});
@tokens = split($separator, $hash_ref->{$token});
return @tokens;
}
################################################################################
# Returns the parameter of a generator configuration of module.
################################################################################