Created
September 29, 2014 06:04
-
-
Save skihero/bf372e08a4c204869ac8 to your computer and use it in GitHub Desktop.
create_rrd_database snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub create_rrd_database { | |
my $self = shift; | |
my ($RRDdatabase_path, $metric_id, $begin, $interval, $metric_name, $my_len_storage_rrd, $data_source_type) = @_; | |
my $lsource_type; | |
if (defined($data_source_type) && defined($rrd_dst[$data_source_type])) { | |
$lsource_type = $rrd_dst[$data_source_type]; | |
} else { | |
$lsource_type = $rrd_dst[0]; | |
} | |
RRDs::create($RRDdatabase_path . "/" . $metric_id . ".rrd", "-b ".$begin, "-s ".$interval, "DS:" . substr($metric_name, 0, 19) . ":" . $lsource_type . ":".$interval.":U:U", "RRA:AVERAGE:0.5:1:".$my_len_storage_rrd, "RRA:AVERAGE:0.5:12:".($my_len_storage_rrd / 12)); | |
my $ERR = RRDs::error; | |
if ($ERR) { | |
$self->{logger}->writeLogError("ERROR while creating " . $RRDdatabase_path.$metric_id . ".rrd : $ERR"); | |
} else { | |
chmod 0664, "${RRDdatabase_path}/${metric_id}.rrd"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment