Commit e8ee55c7 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add debugging option (-d) to prevent emailing output. Nicer for

development.
parent 0aa3ea21
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
#
# Audit the DB, looking for things we want to catch. Run once a day from cron.
#
#
sub usage() {
print STDOUT "Usage: audit [-d]\n".
"Use the -d option to see debugging output instead of emailing it.\n";
exit(-1);
}
my $optlist = "d";
my $debug = 0;
#
# Configure variables
......@@ -39,6 +46,21 @@ if ($UID != 0) {
exit(-1);
}
#
# Parse command arguments. Once we return from getopts, all that should
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (@ARGV) {
usage();
}
if (defined($options{"d"})) {
$debug++;
}
#
# Form a temp name.
#
......@@ -48,9 +70,11 @@ my $query_result;
#
# Reopen both stdout and stderr so that we can record all the output for
# later mailing.
#
#open(STDERR, ">> $logname") or die("opening $logname for STDERR: $!");
#open(STDOUT, ">> $logname") or die("opening $logname for STDOUT: $!");
#
if (! $debug) {
open(STDERR, ">> $logname") or die("opening $logname for STDERR: $!");
open(STDOUT, ">> $logname") or die("opening $logname for STDOUT: $!");
}
#
# Look for experiments running longer than 1 day, using real nodes.
......@@ -95,12 +119,13 @@ if ($query_result->numrows) {
#
# Send email if anything was reported.
#
if (-s $logname) {
if (!$debug && -s $logname) {
SENDMAIL($TBOPS, "Testbed Audit Results", "Testbed Audit Results",
$TBOPS, undef, ($logname));
}
unlink("$logname");
unlink("$logname")
if (-e $logname);
exit 0;
sub fatal($) {
......@@ -108,6 +133,7 @@ sub fatal($) {
print STDERR "$msg\n";
SENDMAIL($TBOPS, "Testbed Audit Failed", $msg, undef, undef, ($logname));
unlink("$logname");
unlink("$logname")
if (-e $logname);
exit(1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment