Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CloudForecast 1min graph and configurable radar interval
diff --git a/lib/CloudForecast/Data.pm b/lib/CloudForecast/Data.pm
index 78c9f73..9c2983a 100644
--- a/lib/CloudForecast/Data.pm
+++ b/lib/CloudForecast/Data.pm
@@ -647,6 +647,8 @@ sub init_rrd {
}
}
+ my $interval = $self->global_config->{interval} || 300;
+
if ( ! -f $file ) {
my @ds = map { sprintf "DS:%s:%s:600:0:U", $_->[0], $_->[1] } @base_schema;
CloudForecast::Log->debug('create rrd file:' . $file);
@@ -655,13 +657,13 @@ sub init_rrd {
$file,
'--step', '60',
@ds,
+ 'RRA:AVERAGE:0.5:1:46080',
'RRA:AVERAGE:0.5:5:9216',
- 'RRA:AVERAGE:0.5:30:1536',
- 'RRA:AVERAGE:0.5:120:768',
- 'RRA:AVERAGE:0.5:1440:794',
- 'RRA:MAX:0.5:30:1536',
- 'RRA:MAX:0.5:120:768',
- 'RRA:MAX:0.5:1440:794'
+ 'RRA:AVERAGE:0.5:60:768',
+ 'RRA:AVERAGE:0.5:1440:1100',
+ 'RRA:MAX:0.5:5:9216',
+ 'RRA:MAX:0.5:60:768',
+ 'RRA:MAX:0.5:1440:1100'
);
my $ERR=RRDs::error;
die $ERR if $ERR;
@@ -678,13 +680,13 @@ sub init_rrd {
$extend_file,
'--step', '60',
sprintf("DS:%s:%s:600:0:U", $extend_schema{$schema}->[0],$extend_schema{$schema}->[1]),
+ 'RRA:AVERAGE:0.5:1:46080',
'RRA:AVERAGE:0.5:5:9216',
- 'RRA:AVERAGE:0.5:30:1536',
- 'RRA:AVERAGE:0.5:120:768',
- 'RRA:AVERAGE:0.5:1440:794',
- 'RRA:MAX:0.5:30:1536',
- 'RRA:MAX:0.5:120:768',
- 'RRA:MAX:0.5:1440:794'
+ 'RRA:AVERAGE:0.5:60:768',
+ 'RRA:AVERAGE:0.5:1440:1100',
+ 'RRA:MAX:0.5:5:46080',
+ 'RRA:MAX:0.5:60:9216',
+ 'RRA:MAX:0.5:1440:1100'
);
my $ERR=RRDs::error;
die $ERR if $ERR;
diff --git a/lib/CloudForecast/Radar.pm b/lib/CloudForecast/Radar.pm
index 0cff7af..e7e0248 100644
--- a/lib/CloudForecast/Radar.pm
+++ b/lib/CloudForecast/Radar.pm
@@ -38,8 +38,10 @@ sub run {
push @watchdog_pid, $configloader->watchdog;
}
+ my $interval = $global_config->{interval} || 300;
+
my $now = time;
- my $next = $now - ( $now % 300 ) + 300;
+ my $next = $now - ( $now % $interval ) + $interval;
my $pid;
my @signals_received;
@@ -76,7 +78,7 @@ sub run {
$now = time;
if ( $now >= $next ) {
CloudForecast::Log->warn( sprintf( "(%s) radar start ", scalar localtime $next) );
- $next = $now - ( $now % 300 ) + 300;
+ $next = $now - ( $now % $interval ) + $interval;
if ( $pid ) {
CloudForecast::Log->warn( "Previous radar exists, skipping this time");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment