Added a script that maintains a set of sanatized scheduler logs

for users, helpers, and admins to view on the web.
A second script removes these log files if more than one week
      old.
The logs are 'sanatized' by removing IP addresses and authenticators.
These scripts should be controlled by using the standard start/stop
      scripts.  To do this, make entries in config.xml.  The files both
      contain comments at the top detailing how to do this.

svn path=/trunk/boinc/; revision=9049
This commit is contained in:
Bruce Allen 2005-12-07 04:19:17 +00:00
parent 877f39921f
commit 6d7199af08
4 changed files with 94 additions and 1 deletions

View File

@ -14262,3 +14262,19 @@ Charlie 6 Dec 2005
clientgui/
BOINCGUIApp.cpp
Bruce 7 Dec 2005
- Added a script that maintains a set of sanatized scheduler logs
for users, helpers, and admins to view on the web.
- A second script removes these log files if more than one week
old.
- The logs are 'sanatized' by removing IP addresses and authenticators.
- These scripts should be controlled by using the standard start/stop
scripts. To do this, make entries in config.xml. The files both
contain comments at the top detailing how to do this.
tools/
makelog.sh
cleanlogs.sh
Makefile.am

View File

@ -4,7 +4,7 @@ include $(top_srcdir)/Makefile.incl
bin_PROGRAMS = create_work sign_executable dir_hier_path dir_hier_move
EXTRA_DIST = make_project add xadd update_versions dbcheck_files_exist upgrade
EXTRA_DIST = make_project add xadd update_versions dbcheck_files_exist upgrade makelog.sh cleanlogs.sh
# TODO: use libboinc for these:

18
tools/cleanlogs.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# This script ensures that only one week of the scheduler logs are
# archived for users to study.
# To run this script as part of the standard BOINC backend services
# (once every 24 hours) just include this:
# <task>
# <cmd> cleanlogs.sh </cmd>
# <output>cleanlogs.sh.log</output>
# <period>24 hr</period>
# </task>
# in your project's config.xml file
cd ../html/user/sched_logs/ || exit 1
find . -type d -name "20*" -mtime 7 | xargs rm -rf || exit 2
echo "`date '+%Y-%m-%d %H:%M:'`" "cleaned scheduler logs"
exit 0

59
tools/makelog.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
# This daemon (endless loop) constructs user-readable scheduler
# logs once per minute. It runs with a 3-minute latency.
# To run this script as part of the standard BOINC backend
# components, just include:
# <daemon>
# <cmd> makelog.sh </cmd>
# </daemon>
# in your config.xml file
export lastmin=dontmatch
while [ true ] ; do
# we extract the logs from 3 minutes ago, because the cgi
# process can run for a couple of minutes.
export currmin=`date --date="-3 minute" '+%Y-%m-%d %H:%M'`
# create correct filename, directory name, path, etc.
export oneword=`echo $currmin | sed 's/ /_/'`
export filename=${oneword}.txt
export dirname=`echo $filename | cut -b 1-13`
export dirpath=../html/user/sched_logs/${dirname}
if [ ! -d $dirpath ] ; then
mkdir $dirpath
fi
export filepath=${dirpath}/${filename}
# if the minute has changed, or the one-minute log file does not exist,
# then create it. One must consider both cases otherwise log rotation
# can screw things up.
if [ "${currmin}" != "${lastmin}" -o ! -f "${filepath}" ] ; then
# put some text into the start of the 'human readable' log file
echo "Note that all times in this file are in UTC. To compare with your BOINC logs" > $filepath
echo "you will need to convert your local time into UTC. To make comparison easier you" >> $filepath
echo "may also want to consider using a high-precision time protocol such as NTP to set your" >> $filepath
echo "computers clock. This will allow comparisons of the time stamps to fractions of" >> $filepath
echo "a second." >> $filepath
echo " " >> $filepath
echo "Note also that these files are created with three-minute latency." >> $filepath
echo " " >> $filepath
echo " " >> $filepath
# now grep for all log entries from 3 minutes ago. Use sed to hide any sensitive info
# such as authenticator and IP address. Must
grep --no-filename "${currmin}" ../log_*/cgi.log ../log_*/cgi.log.0 | sed 's/authenticator .*//g; s/\[auth [^]]*\]//g; s/from [0-9.]*//g; s/auth [0-9a-f]*\,//g; s/\[IP [0-9.]*\]//g; s/IP [0-9.]*\,//g' >> $filepath
export lastmin=$currmin
else
# if the minute has not changed and log file exists, sleep a bit and
# try again
sleep 15;
fi
done
# this is an infinite loop, so we should never get here!!