#!/usr/bin/perl -w use strict; use warnings FATAL => 'all'; use RRDs; $| = 1; my $rrd = shift || die; my $mode = shift || ''; my @types = qw(att sn); if ($mode eq 'power') { @types = (@types, $mode); } elsif ($mode eq 'power-only') { @types = qw(power); } foreach my $type (@types) { foreach my $direction (qw(up down)) { foreach my $data_type (qw(min max avg last)) { my $cf = uc $data_type; $cf =~ s/^AVG$/AVERAGE/; my $vdef_cf = $cf; $vdef_cf =~ s/^(MIN|MAX)$/$1IMUM/; my $rrd_var = sprintf "%s_%s_%s", $type, $direction, $data_type; printf "DEF:1_%s=%s:%s_%s:%s\n", $rrd_var, $rrd, $type, $direction, $cf; printf "VDEF:%s=1_%s,%s\n", $rrd_var, $rrd_var, $vdef_cf; } } }