Skip to content

Instantly share code, notes, and snippets.

@skihero
Created September 29, 2014 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skihero/bf372e08a4c204869ac8 to your computer and use it in GitHub Desktop.
Save skihero/bf372e08a4c204869ac8 to your computer and use it in GitHub Desktop.
create_rrd_database snippet
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