#!/usr/bin/perl use strict; my $ds = 4; # change the name(s) of the new data sources here my $newlinkname = 'newlink'; my @dsnames = ($newlinkname.'_in', $newlinkname.'_out', $newlinkname.'_v6_in', $newlinkname.'_v6_out'); my $default_val = 'NaN'; my $type = 'ABSOLUTE'; my $heartbeat = '300'; my $rrdmin = 'NaN'; my $rrdmax = 'NaN'; my $cdp_prep_end = ''; my $row_end = ''; my $name = ''; my $name_end = ''; my $field = ' ' . $default_val . ' '; my $found_ds = 0; my $num_sources = 0; my $last; my $fields = " "; my $datasource; my $x; while () { if (($_ =~ s/$row_end$/$fields$row_end/) && $found_ds) { # need to hit types first, if we don't, we're screwed print $_; } elsif (/$cdp_prep_end/) { for (my $j = 0; $j < $ds; $j++) { print "\t\t\t\n" . "\t\t\t 0.0000000000e+00 \n" . "\t\t\t 0.0000000000e+00 \n" . "\t\t\t NaN \n" . "\t\t\t 0 \n" . "\t\t\t\n"; } print $_; } elsif (/$name_end$/) { ($datasource) = /$name (\w+)/; $found_ds++; print $_; } elsif (/Round Robin Archives/) { # print out additional datasource definitions ($num_sources) = ($datasource =~ /(\d+)/); for ($x = 0; $x < $ds; $x++) { $fields .= $field; print "\n\t\n"; print "\t\t " . $dsnames[$x] . " <\/name>\n"; print "\t\t $type <\/type>\n"; print "\t\t $heartbeat <\/minimal_heartbeat>\n"; print "\t\t $rrdmin <\/min>\n"; print "\t\t $rrdmax <\/max>\n\n"; print "\t\t\n"; print "\t\t U <\/last_ds>\n"; print "\t\t NaN <\/value>\n"; print "\t\t 0 <\/unknown_sec>\n"; print "\t<\/ds>\n\n"; } print $_; } else { print $_; } $last = $_; }