Commit b3f4e8bd authored by Kevin Atkinson's avatar Kevin Atkinson

Fix dumperrorlog so it can run on other sites. The ops errorlog

database is only used for Utah's emulab.  In the process many other
changes where made to dumperrorlog to fix bugs and make it more
correct/robust.  I also avoided the need to explicitly lock any tables.
parent 71fe299d
...@@ -1452,6 +1452,7 @@ done ...@@ -1452,6 +1452,7 @@ done
# #
...@@ -1486,6 +1487,7 @@ done ...@@ -1486,6 +1487,7 @@ done
# #
# Defaults for for above variables. # Defaults for for above variables.
# #
TBERRORLOGDBNAME="errorlog"
TBADMINGROUP="flux" TBADMINGROUP="flux"
CLIENT_ETCDIR="/etc/emulab" CLIENT_ETCDIR="/etc/emulab"
CLIENT_BINDIR="/usr/local/etc/emulab" CLIENT_BINDIR="/usr/local/etc/emulab"
...@@ -1602,6 +1604,10 @@ cat >> confdefs.h <<EOF ...@@ -1602,6 +1604,10 @@ cat >> confdefs.h <<EOF
#define TBDBNAME "$TBDBNAME" #define TBDBNAME "$TBDBNAME"
EOF EOF
cat >> confdefs.h <<EOF
#define TBERRORLOGDBNAME "$TBERRORLOGDBNAME"
EOF
cat >> confdefs.h <<EOF cat >> confdefs.h <<EOF
#define TBADMINGROUP "$TBADMINGROUP" #define TBADMINGROUP "$TBADMINGROUP"
EOF EOF
...@@ -2128,17 +2134,17 @@ for ac_hdr in ulxmlrpcpp/ulxr_config.h ...@@ -2128,17 +2134,17 @@ for ac_hdr in ulxmlrpcpp/ulxr_config.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2132: checking for $ac_hdr" >&5 echo "configure:2138: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2137 "configure" #line 2143 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } { (eval echo configure:2148: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
...@@ -2177,17 +2183,17 @@ for ac_hdr in linux/videodev.h ...@@ -2177,17 +2183,17 @@ for ac_hdr in linux/videodev.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2181: checking for $ac_hdr" >&5 echo "configure:2187: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2186 "configure" #line 2192 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2191: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } { (eval echo configure:2197: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
...@@ -2220,7 +2226,7 @@ done ...@@ -2220,7 +2226,7 @@ done
# Extract the first word of "gtk-config", so it can be a program name with args. # Extract the first word of "gtk-config", so it can be a program name with args.
set dummy gtk-config; ac_word=$2 set dummy gtk-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2224: checking for $ac_word" >&5 echo "configure:2230: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_GTK_CONFIG'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_prog_GTK_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
...@@ -2299,7 +2305,7 @@ fi ...@@ -2299,7 +2305,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh. # ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:2303: checking for a BSD compatible install" >&5 echo "configure:2309: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
...@@ -2360,7 +2366,7 @@ esac ...@@ -2360,7 +2366,7 @@ esac
# Extract the first word of "rsync", so it can be a program name with args. # Extract the first word of "rsync", so it can be a program name with args.
set dummy rsync; ac_word=$2 set dummy rsync; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2364: checking for $ac_word" >&5 echo "configure:2370: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_RSYNC'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_path_RSYNC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
...@@ -2767,6 +2773,7 @@ s%@SUDO@%$SUDO%g ...@@ -2767,6 +2773,7 @@ s%@SUDO@%$SUDO%g
s%@SSH@%$SSH%g s%@SSH@%$SSH%g
s%@optional_subdirs@%$optional_subdirs%g s%@optional_subdirs@%$optional_subdirs%g
s%@TBDBNAME@%$TBDBNAME%g s%@TBDBNAME@%$TBDBNAME%g
s%@TBERRORLOGDBNAME@%$TBERRORLOGDBNAME%g
s%@TBADMINGROUP@%$TBADMINGROUP%g s%@TBADMINGROUP@%$TBADMINGROUP%g
s%@DELAYCAPACITY@%$DELAYCAPACITY%g s%@DELAYCAPACITY@%$DELAYCAPACITY%g
s%@IPBASE@%$IPBASE%g s%@IPBASE@%$IPBASE%g
......
...@@ -102,6 +102,7 @@ AC_SUBST(optional_subdirs) ...@@ -102,6 +102,7 @@ AC_SUBST(optional_subdirs)
# to appear in config.h. # to appear in config.h.
# #
AC_SUBST(TBDBNAME) AC_SUBST(TBDBNAME)
AC_SUBST(TBERRORLOGDBNAME)
AC_SUBST(TBADMINGROUP) AC_SUBST(TBADMINGROUP)
AC_SUBST(DELAYCAPACITY) AC_SUBST(DELAYCAPACITY)
AC_SUBST(IPBASE) AC_SUBST(IPBASE)
...@@ -239,6 +240,7 @@ AC_SUBST(TBERRORSEMAIL_NOSLASH) ...@@ -239,6 +240,7 @@ AC_SUBST(TBERRORSEMAIL_NOSLASH)
# #
# Defaults for for above variables. # Defaults for for above variables.
# #
TBERRORLOGDBNAME="errorlog"
TBADMINGROUP="flux" TBADMINGROUP="flux"
CLIENT_ETCDIR="/etc/emulab" CLIENT_ETCDIR="/etc/emulab"
CLIENT_BINDIR="/usr/local/etc/emulab" CLIENT_BINDIR="/usr/local/etc/emulab"
...@@ -342,6 +344,7 @@ else ...@@ -342,6 +344,7 @@ else
AC_DEFINE_UNQUOTED(TBROOT, "$prefix") AC_DEFINE_UNQUOTED(TBROOT, "$prefix")
fi fi
AC_DEFINE_UNQUOTED(TBDBNAME, "$TBDBNAME") AC_DEFINE_UNQUOTED(TBDBNAME, "$TBDBNAME")
AC_DEFINE_UNQUOTED(TBERRORLOGDBNAME, "$TBERRORLOGDBNAME")
AC_DEFINE_UNQUOTED(TBADMINGROUP, "$TBADMINGROUP") AC_DEFINE_UNQUOTED(TBADMINGROUP, "$TBADMINGROUP")
AC_DEFINE_UNQUOTED(IPBASE, "$IPBASE") AC_DEFINE_UNQUOTED(IPBASE, "$IPBASE")
AC_DEFINE_UNQUOTED(JAILIPBASE, "$JAILIPBASE") AC_DEFINE_UNQUOTED(JAILIPBASE, "$JAILIPBASE")
......
...@@ -27,13 +27,14 @@ my $max_rows = 300000; ...@@ -27,13 +27,14 @@ my $max_rows = 300000;
# #
# Configure variables # Configure variables
# #
my $TB = "@prefix@"; my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@"; my $TBOPS = "@TBOPSEMAIL@";
my $ISMAINSITE = @TBMAINSITE@; my $ISUTAHEMULAB = "@OURDOMAIN@" eq 'emulab.net';
my $USERNODE = "@USERNODE@"; my $USERNODE = "@USERNODE@";
my $PROXY = "$TB/sbin/dumperrorlog.proxy"; my $PROXY = "$TB/sbin/dumperrorlog.proxy";
my $SCP = "/usr/bin/scp"; my $SCP = "/usr/bin/scp";
my $SSHTB = "$TB/bin/sshtb"; my $SSHTB = "$TB/bin/sshtb";
my $ERRORLOGDB = "@TBERRORLOGDBNAME@";
# un-taint path # un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin'; $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin';
...@@ -106,18 +107,13 @@ if (! $debug) { ...@@ -106,18 +107,13 @@ if (! $debug) {
my $query_result = my $query_result =
DBQueryFatal("select idx from emulab_indicies ". DBQueryFatal("select idx from emulab_indicies ".
"where name='lastlog_seqnum'"); "where name='lastlog_seqnum'");
my ($lastseq) = $query_result->fetchrow_array(); my ($minseq) = $query_result->fetchrow_array();
if (!defined($lastseq)) { if (!defined($minseq)) {
DBQueryFatal("insert into emulab_indicies (name, idx) ". DBQueryFatal("insert into emulab_indicies (name, idx) ".
"values ('lastlog_seqnum', 0)"); "values ('lastlog_seqnum', 0)");
$lastseq = 0; $minseq = 0;
} }
#
# Limit number of rows to keep from locking the log table too long
#
my $maxseq = $lastseq + $max_rows;
# #
# And the last experiment index we sent over. # And the last experiment index we sent over.
# #
...@@ -149,25 +145,30 @@ if (!defined($NOTICE)) { ...@@ -149,25 +145,30 @@ if (!defined($NOTICE)) {
fatal("No priority named 'NOTICE' in the priorities table!"); fatal("No priority named 'NOTICE' in the priorities table!");
} }
print "Copying log entries ($lastseq,$maxseq]\n"; #
# Now get the largest log index to copy
#
$query_result =
DBQueryFatal("select MAX(seq) from log ".
"where seq > $minseq " .
" and seq <= $minseq + $max_rows ");
my $maxseq = $query_result->fetchrow_array();
$maxseq = $minseq unless defined $maxseq;
print "Copying log entries ($minseq,$maxseq]\n";
print "Exptidx ($exptidx_min, $exptidx_max]\n"; print "Exptidx ($exptidx_min, $exptidx_max]\n";
# #
# Only the main site does this archiving stuff. # Might not be any new entries ...
# #
if ($ISMAINSITE) { if ($minseq != $maxseq) {
#
# Must lock the table of course
#
DBQueryFatal("lock tables log write");
# #
# Backup old outfile # Backup old outfile
# #
if (-e "${tempfile}.log") { if (-e "${tempfile}.log") {
unlink("${tempfile}.log.save") unlink("${tempfile}.log.save")
if (-e "${tempfile}.log.save"); if (-e "${tempfile}.log.save");
system("/bin/mv -f ${tempfile}.log ${tempfile}.log.save"); system("/bin/mv -f ${tempfile}.log ${tempfile}.log.save");
} }
...@@ -175,35 +176,16 @@ if ($ISMAINSITE) { ...@@ -175,35 +176,16 @@ if ($ISMAINSITE) {
# Grab all of the new entries and store to the file # Grab all of the new entries and store to the file
# #
DBQueryFatal("select * from log ". DBQueryFatal("select * from log ".
"where seq > $lastseq " . "where seq > $minseq " .
"and seq <= $maxseq " . "and seq <= $maxseq " .
"into outfile '${tempfile}.log' "); "into outfile '${tempfile}.log' ");
# system("echo \"load data infile '${tempfile}.log' replace into table log\" ".
# Now we need to find out what the last index really was. " | mysql $ERRORLOGDB");
# fatal("Could not load into archive DB!")
my $firstseq = $lastseq; if ($?);
$query_result =
DBQueryFatal("select seq from log ".
"where seq > $lastseq " .
" and seq <= $maxseq ".
"order by seq desc limit 1");
# Save for later.
($lastseq) = $query_result->fetchrow_array();
DBQueryFatal("unlock tables");
#
# Might not be any new entries ...
#
if (defined($lastseq)) {
system("echo \"load data infile '${tempfile}.log' replace into table log\" ".
" | mysql errorlog");
fatal("Could not load into archive DB!")
if ($?);
# if ($ISUTAHEMULAB) {
# XXX This awful hack will go away when Kevin is happy with # XXX This awful hack will go away when Kevin is happy with
# the error logging code. # the error logging code.
# #
...@@ -212,74 +194,77 @@ if ($ISMAINSITE) { ...@@ -212,74 +194,77 @@ if ($ISMAINSITE) {
# Copy the file over to ops and load it into the DB over there. # Copy the file over to ops and load it into the DB over there.
# #
system("$SCP -p ${tempfile}.log ". system("$SCP -p ${tempfile}.log ".
" ${USERNODE}:/var/db/mysql/errorlog") == 0 " ${USERNODE}:/var/db/mysql/$ERRORLOGDB") == 0
or fatal("Could not copy $tempfile to $USERNODE!"); or fatal("Could not copy $tempfile to $USERNODE!");
system("$SSHTB -host $USERNODE $PROXY log") == 0 system("$SSHTB -host $USERNODE $PROXY log") == 0
or fatal("Could not load log entries into ops DB!"); or fatal("Could not load log entries into ops DB!");
} }
}
# #
# Now the other tables Kevin needs # Now the other tables Kevin needs
# #
foreach my $tablename ("scripts", "priorities", "causes", "session_info", foreach my $tablename ("scripts", "priorities", "causes", "session_info",
"errors", "users", "experiments", "errors", "users", "experiments",
"report_error", "report_context", "report_error", "report_context",
"report_assign_violation") { "report_assign_violation") {
unlink("${tempfile}.${tablename}") if -e "${tempfile}.${tablename}"; unlink("${tempfile}.${tablename}") if -e "${tempfile}.${tablename}";
if (($tablename eq "errors" || if (($tablename eq "errors" ||
$tablename eq "session_info") && !$force) { $tablename eq "session_info") && !$force) {
DBQueryFatal("select * from $tablename where session>=$firstseq and session<=$lastseq ". DBQueryFatal("select * from $tablename where session>=$minseq and session<=$maxseq ".
"into outfile '${tempfile}.${tablename}' "); "into outfile '${tempfile}.${tablename}' ");
} }
elsif ($tablename eq "report_error" || elsif ($tablename eq "report_error" ||
$tablename eq "report_context" || $tablename eq "report_context" ||
$tablename eq "report_assign_violation") { $tablename eq "report_assign_violation") {
DBQueryFatal("select * from $tablename where seq>=$firstseq and seq<=$lastseq ". DBQueryFatal("select * from $tablename where seq>=$minseq and seq<=$maxseq ".
"into outfile '${tempfile}.${tablename}' "); "into outfile '${tempfile}.${tablename}' ");
} }
elsif ($tablename eq "users") { elsif ($tablename eq "users") {
DBQueryFatal("select uid,unix_uid from $tablename ". DBQueryFatal("select uid,unix_uid from $tablename ".
"into outfile '${tempfile}.${tablename}' "); "into outfile '${tempfile}.${tablename}' ");
} }
elsif ($tablename eq "experiments") { elsif ($tablename eq "experiments") {
next if next if
($exptidx_max == $exptidx_min); ($exptidx_max == $exptidx_min);
DBQueryFatal("select exptidx,pid,eid from experiment_stats ". DBQueryFatal("select exptidx,pid,eid from experiment_stats ".
"where exptidx > $exptidx_min and ". "where exptidx > $exptidx_min and ".
" exptidx <= $exptidx_max ". " exptidx <= $exptidx_max ".
"into outfile '${tempfile}.${tablename}' "); "into outfile '${tempfile}.${tablename}' ");
} }
else { else {
DBQueryFatal("select * from $tablename ". DBQueryFatal("select * from $tablename ".
"into outfile '${tempfile}.${tablename}' "); "into outfile '${tempfile}.${tablename}' ");
} }
system("echo \"load data infile '${tempfile}.${tablename}' ".
" replace into table $tablename\" | mysql errorlog");
fatal("Could not load $tablename into archive DB!")
if ($?);
system("echo \"load data infile '${tempfile}.${tablename}' ".
" replace into table $tablename\" | mysql $ERRORLOGDB");
fatal("Could not load $tablename into archive DB!")
if ($?);
if ($ISUTAHEMULAB) {
# #
# Copy the file over to ops and load it into the DB over there. # Copy the file over to ops and load it into the DB over there.
# #
system("$SCP -p ${tempfile}.${tablename} ". system("$SCP -p ${tempfile}.${tablename} ".
" ${USERNODE}:/var/db/mysql/errorlog") == 0 " ${USERNODE}:/var/db/mysql/$ERRORLOGDB") == 0
or fatal("Could not copy ${tempfile}.${tablename} to $USERNODE!"); or fatal("Could not copy ${tempfile}.${tablename} to $USERNODE!");
system("$SSHTB -host $USERNODE $PROXY $tablename") == 0 system("$SSHTB -host $USERNODE $PROXY $tablename") == 0
or fatal("Could not load $tablename entries into ops DB!"); or fatal("Could not load $tablename entries into ops DB!");
unlink("${tempfile}.${tablename}"); unlink("${tempfile}.${tablename}");
} }
} }
# Okay, now that we have really archived them away, update the # Okay, now that we have really archived them away, update the
# seq number. # seq number.
DBQueryFatal("update emulab_indicies set idx='$lastseq' ". DBQueryFatal("update emulab_indicies set idx='$maxseq' ".
"where name='lastlog_seqnum'"); "where name='lastlog_seqnum'");
# Okay, now that we have really sent over the experiment_stats stuff. # Okay, now that we have really sent over the experiment_stats stuff.
...@@ -320,3 +305,4 @@ sub fatal($) ...@@ -320,3 +305,4 @@ sub fatal($)
die("*** $0:\n". die("*** $0:\n".
" $msg\n"); " $msg\n");
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# If you add a variable, be sure to go and update configure.in. # If you add a variable, be sure to go and update configure.in.
# #
TBDBNAME=tbdb TBDBNAME=tbdb
TBERRORLOGDBNAME=errorlog
TBADMINGROUP=flux TBADMINGROUP=flux
TBOPSEMAIL=testbed-ops@flux.utah.edu TBOPSEMAIL=testbed-ops@flux.utah.edu
TBLOGSEMAIL=testbed-logs@flux.utah.edu TBLOGSEMAIL=testbed-logs@flux.utah.edu
......
...@@ -18,6 +18,27 @@ Note that some instructions may have steps that need to occur at a few ...@@ -18,6 +18,27 @@ Note that some instructions may have steps that need to occur at a few
different points in the install process - these are marked with the different points in the install process - these are marked with the
earliest time one of the steps needs to occur. earliest time one of the steps needs to occur.
20080905: After install
In order to reduce the size of the main database data in the
"log" table is now moved to the errorlog database and old
entries are removed.
First off create the errorlog database:
mysqladmin create errorlog
mysql errorlog < sql/database-create-errorlog.sql
Than install a crontab entry to run dumperrorlog every hour
by adding the following line to /etc/crontab, be sure to
preserve the embedded tabs:
12 * * * * root /usr/testbed/sbin/dumperrorlog
dumperrorlog will only move 300,000 rows at a time in order
to avoid locking the log table for too long. Thus it will
take a while for it to get caught up.
20080805: Optional, After install. 20080805: Optional, After install.
As a result of moving the documentation to the WIKI there As a result of moving the documentation to the WIKI there
......
...@@ -23,6 +23,7 @@ my $PREFIX = '@prefix@'; ...@@ -23,6 +23,7 @@ my $PREFIX = '@prefix@';
my $SRCDIR = '@srcdir@'; my $SRCDIR = '@srcdir@';
my $TOP_SRCDIR = '@top_srcdir@'; my $TOP_SRCDIR = '@top_srcdir@';
my $DBNAME = "@TBDBNAME@"; my $DBNAME = "@TBDBNAME@";
my $ERRORLOG_DBNAME = "@TBERRORLOGDBNAME@";
my $ELABINELAB = @ELABINELAB@; my $ELABINELAB = @ELABINELAB@;
my $WINSUPPORT = @WINSUPPORT@; my $WINSUPPORT = @WINSUPPORT@;
my $MAILMANSUPPORT = @MAILMANSUPPORT@; my $MAILMANSUPPORT = @MAILMANSUPPORT@;
...@@ -882,6 +883,21 @@ Phase "database", "Setting up database", sub { ...@@ -882,6 +883,21 @@ Phase "database", "Setting up database", sub {
ExecQuietFatal("$MYSQL $DBNAME < ". ExecQuietFatal("$MYSQL $DBNAME < ".
"$TOP_SRCDIR/sql/knowlbase-create.sql"); "$TOP_SRCDIR/sql/knowlbase-create.sql");
}; };
Phase "$ERRORLOG_DBNAME", "Creating $ERRORLOG_DBNAME", sub {
if (!ExecQuiet("$MYSQLSHOW $ERRORLOG_DBNAME")) {
PhaseSkip("$ERRORLOG_DBNAME already exists");
}
ExecQuietFatal("$MYSQLADMIN create $ERRORLOG_DBNAME");
};
Phase "tables", "Creating tables in $ERRORLOG_DBNAME", sub {
if (!ExecQuiet("$MYSQLDUMP -d $ERRORLOG_DBNAME users")) {
PhaseSkip("Tables have already been created");
}
if ($FBSD_MAJOR == 4) {
ExecQuietFatal("cp $TOP_SRCDIR/sql/database-create-old-errorlog.sql $TOP_SRCDIR/sql/database-create-errorlog.sql")
}
ExecQuietFatal("$MYSQL $ERRORLOG_DBNAME < $TOP_SRCDIR/sql/database-create-errorlog.sql");
};
}; };
Phase "rc.conf", "Adding testbed content to $RCCONF", sub { Phase "rc.conf", "Adding testbed content to $RCCONF", sub {
...@@ -1014,6 +1030,7 @@ Phase "cron", "Adding cron jobs", sub { ...@@ -1014,6 +1030,7 @@ Phase "cron", "Adding cron jobs", sub {
DoneIfEdited($CRONTAB); DoneIfEdited($CRONTAB);
AppendToFileFatal($CRONTAB, AppendToFileFatal($CRONTAB,
"0 \t6\t*\t*\t*\troot\t$PREFIX/sbin/audit", "0 \t6\t*\t*\t*\troot\t$PREFIX/sbin/audit",
"12 \t*\t*\t*\t*\troot\t$PREFIX/sbin/dumperrorlog",
"0 \t1\t*\t*\t*\troot\t$PREFIX/sbin/dbcheck", "0 \t1\t*\t*\t*\troot\t$PREFIX/sbin/dbcheck",
"45 \t1\t*\t*\t*\troot\t$PREFIX/sbin/backup", "45 \t1\t*\t*\t*\troot\t$PREFIX/sbin/backup",
"*/5\t*\t*\t*\t*\troot\t$PREFIX/sbin/node_status", "*/5\t*\t*\t*\t*\troot\t$PREFIX/sbin/node_status",
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# The easy way: do 'gmake all' # The easy way: do 'gmake all'
# You can also run the individual targets too. # You can also run the individual targets too.
all: db-create db-fill sitevars old-db-create all: db-create db-create-errorlog db-fill sitevars old-db-create old-db-create-errorlog
db-create: db-create:
@rm -f ./.tmp-db-create.sql ./.tmp-create-diff @rm -f ./.tmp-db-create.sql ./.tmp-create-diff
...@@ -28,6 +28,18 @@ db-create: ...@@ -28,6 +28,18 @@ db-create:
fi fi
@rm -f ./.tmp-create-diff ./.tmp-db-create.sql @rm -f ./.tmp-create-diff ./.tmp-db-create.sql
db-create-errorlog:
@rm -f ./.tmp-db-create-errorlog.sql ./.tmp-create-diff-errorlog
@mysqldump -d errorlog > ./.tmp-db-create-errorlog.sql
@-diff ./database-create-errorlog.sql ./.tmp-db-create-errorlog.sql > ./.tmp-create-diff-errorlog
@if test -s ./.tmp-create-diff-errorlog; \
then \
cat ./.tmp-create-diff-errorlog; \
echo "NOTE: Don't forget to update database-migrate.txt!"; \
mv ./.tmp-db-create-errorlog.sql ./database-create-errorlog.sql; \
fi
@rm -f ./.tmp-create-diff-errorlog ./.tmp-db-create-errorlog.sql
old-db-create: old-db-create:
cp ./database-create.sql ./.tmp-db-create.sql cp ./database-create.sql ./.tmp-db-create.sql
sed -i '' -e 's/ENGINE=MyISAM DEFAULT CHARSET=latin1/TYPE=MyISAM/' ./.tmp-db-create.sql sed -i '' -e 's/ENGINE=MyISAM DEFAULT CHARSET=latin1/TYPE=MyISAM/' ./.tmp-db-create.sql
...@@ -35,6 +47,13 @@ old-db-create: ...@@ -35,6 +47,13 @@ old-db-create:
mv ./.tmp-db-create.sql ./database-create-old.sql mv ./.tmp-db-create.sql ./database-create-old.sql
@rm -f ./.tmp-db-create.sql @rm -f ./.tmp-db-create.sql
old-db-create-errorlog:
cp ./database-create-errorlog.sql ./.tmp-db-create-errorlog.sql
sed -i '' -e 's/ENGINE=MyISAM DEFAULT CHARSET=latin1/TYPE=MyISAM/' ./.tmp-db-create-errorlog.sql
sed -i '' -e 's/ default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP//' ./.tmp-db-create-errorlog.sql
mv ./.tmp-db-create-errorlog.sql ./database-create-old-errorlog.sql
@rm -f ./.tmp-db-create-errorlog.sql
db-fill: db-fill:
@/usr/testbed/sbin/wap /usr/testbed/sbin/export_tables \ @/usr/testbed/sbin/wap /usr/testbed/sbin/export_tables \
> database-fill.sql > database-fill.sql
...@@ -53,3 +72,4 @@ fwrules: ...@@ -53,3 +72,4 @@ fwrules:
@echo "*** Use 'gmake insertrules' in the firewall subdir to do this" @echo "*** Use 'gmake insertrules' in the firewall subdir to do this"
dist: db-fill-dist dist: db-fill-dist
-- MySQL dump 10.10
--
-- Host: localhost Database: errorlog
-- ------------------------------------------------------
-- Server version 5.0.20-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `causes`
--
DROP TABLE IF EXISTS `causes`;
CREATE TABLE `causes` (
`cause` varchar(16) NOT NULL default '',
`cause_desc` varchar(32) NOT NULL default '',
PRIMARY KEY (`cause`),
UNIQUE KEY `cause_desc` (`cause_desc`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `errors`
--
DROP TABLE IF EXISTS `errors`;
CREATE TABLE `errors` (
`session` int(10) unsigned NOT NULL default '0',
`rank` tinyint(1) NOT NULL default '0',
`stamp` int(10) unsigned NOT NULL default '0',
`exptidx` int(11) NOT NULL default '0',
`script` smallint(3) NOT NULL default '0',
`cause` varchar(16) NOT NULL default '',
`confidence` float NOT NULL default '0',
`inferred` tinyint(1) default NULL,
`need_more_info` tinyint(1) default NULL,