-if ($> == 0) {
- if (@ARGV != 2) {
- print STDERR "Running as root, please provide UID as 2th argument!\n";
- exit(1);
- }
-
- print "Running as root, switching to ".$ARGV[1]."\n";
- $< = $> = $ARGV[1];
-}
-
-if (-e "${rrdfile}") {
- print "Reading old ${rrdfile} to preserve data...\n";
-
- my $rrdinfo = RRDs::info("${rrdfile}");
- if (RRDs::error) {
- print "Error while getting info: " . RRDs::error . "\n";
- exit 1;
- }
-
- (my $start, my $ostep, my $names, my $data) =
- RRDs::fetch("${rrdfile}",
- "-s " . (time() - ($rrdinfo->{'rra[0].rows'} * $rrdinfo->{'step'})),
- "AVERAGE");