diff --git a/checkin_notes b/checkin_notes index 97050e8569..26e5beafc0 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5222,3 +5222,18 @@ Karl 2003/07/01-02 update_stats.C validate.C validate_test.C + +Karl 2003/07/02 + - added grepping for WU/results in log files. Can also just view log + file(s). Spiffy colorization and hyperlinks. + + html_ops/ + db.inc + db_action.php + show_log.php (new) + sched/ + grep_logs (new) + test/ + boinc.py + test_backend.py + diff --git a/html/ops/db.inc b/html/ops/db.inc index cd3411c974..3c208a8057 100644 --- a/html/ops/db.inc +++ b/html/ops/db.inc @@ -136,7 +136,7 @@ function host_short_header() { function show_host_short($host) { echo " - id>$host->id + id>$host->id $host->last_ip_addr $host->domain_name $host->p_vendor $host->p_model @@ -186,7 +186,7 @@ function show_host($host) { row("% of time client on", 100*$host->on_frac." %"); row("% of time host connected", 100*$host->connected_frac." %"); row("% of time user active", 100*$host->active_frac." %"); - row("Results", "id&sort_by=sent_time>click here"); + row("Results", "id&sort_by=sent_time>click here"); end_table(); } @@ -239,6 +239,7 @@ function show_workunit($wu, $hide_xml_doc) { row("File delete state", file_delete_state_str($wu->file_delete_state)); row("Assimilation state", assimilate_state_str($wu->assimilate_state)); row("","id>Show associated results"); + row("","name>Grep logs for"); end_table(); echo "

"; } @@ -312,6 +313,7 @@ function show_result($result, $hide_xml_docs, $hide_stderr, $hide_times) { row("Validate state", validate_state_str($result->validate_state)); row("claimed credit", $result->claimed_credit); row("Granted credit", $result->granted_credit); + row("","name>Grep logs"); end_table(); echo "

"; } @@ -366,7 +368,7 @@ function show_user($user) { row("Average credit", $user->expavg_credit); row("Last average time", time_str($user->expavg_time)); row("Default venue", $user->venue); - row("Hosts", "id&detail=low>click"); + row("Hosts", "id&detail=low>click"); end_table(); } diff --git a/html/ops/db_action.php b/html/ops/db_action.php index de80c11d90..461c26cf72 100644 --- a/html/ops/db_action.php +++ b/html/ops/db_action.php @@ -162,26 +162,26 @@ function append_sql_query($original,$addition,$first) { start_table(); switch($table) { case "result": result_short_header(); break; - case "host": host_short_header(); break; + case "host": host_short_header(); break; } } $result = mysql_query($main_query); while ($res = mysql_fetch_object($result)) { if ($detail == "low") { switch ($table) { - case "result": show_result_short($res); break; - case "host": show_host_short($res); break; + case "result": show_result_short($res); break; + case "host": show_host_short($res); break; } } else { switch ($table) { - case "platform": show_platform($res); break; - case "app": show_app($res); break; - case "app_version": show_app_version($res, $hide_xml_docs); break; - case "host": show_host($res); break; - case "workunit": show_workunit($res, $hide_xml_docs); break; - case "result": show_result($res, $hide_xml_docs, $hide_stderr, $hide_times); break; - case "team": show_team($res); break; - case "user": show_user($res); break; + case "platform": show_platform($res); break; + case "app": show_app($res); break; + case "app_version": show_app_version($res, $hide_xml_docs); break; + case "host": show_host($res); break; + case "workunit": show_workunit($res, $hide_xml_docs); break; + case "result": show_result($res, $hide_xml_docs, $hide_stderr, $hide_times); break; + case "team": show_team($res); break; + case "user": show_user($res); break; } } } diff --git a/html/ops/show_log.php b/html/ops/show_log.php new file mode 100644 index 0000000000..10cfecee97 --- /dev/null +++ b/html/ops/show_log.php @@ -0,0 +1,32 @@ +"); + if (!$log_dir) { + exit("Error: couldn't get log_dir from config file."); + } + + if (!$f || !preg_match("/^ *([a-z_*]+[.]out *)+$/", $f)) { + $f = '*.out'; + } + + if ($s) { + page_head("Grep logs for \"$s\""); + } else { + page_head("Show logs"); + } + + echo "

"; + echo " String: "; + echo " Files: "; + echo "
"; + + passthru("cd $log_dir && ./grep_logs -html '$s' $f 2>&1"); + + page_tail(); +} ?> diff --git a/sched/file_deleter.C b/sched/file_deleter.C index 6f82478796..01f9d7e897 100644 --- a/sched/file_deleter.C +++ b/sched/file_deleter.C @@ -40,6 +40,7 @@ int wu_delete_files(WORKUNIT& wu) { char* p; char filename[256], pathname[256], buf[MAX_BLOB_SIZE]; bool no_delete=false; + int count_deleted = 0; safe_strcpy(buf, wu.xml_doc); @@ -55,12 +56,14 @@ int wu_delete_files(WORKUNIT& wu) { } else if (match_tag(p, "")) { if (!no_delete) { sprintf(pathname, "%s/%s", config.download_dir, filename); - log_messages.printf(SchedMessages::NORMAL, "[%s] deleting %s\n", wu.name, pathname); + log_messages.printf(SchedMessages::DEBUG, "[%s] deleting %s\n", wu.name, pathname); unlink(pathname); + ++count_deleted; } } p = strtok(0, "\n"); } + log_messages.printf(SchedMessages::NORMAL, "[%s] deleted %d file(s)\n", wu.name, count_deleted); return 0; } @@ -68,7 +71,6 @@ int result_delete_files(RESULT& result) { char* p; char filename[256], pathname[256], buf[MAX_BLOB_SIZE]; bool no_delete=false; - int count_deleted = 0; safe_strcpy(buf, result.xml_doc_in); @@ -91,7 +93,7 @@ int result_delete_files(RESULT& result) { p = strtok(0, "\n"); } - log_messages.printf(SchedMessages::NORMAL, "[%s] deleted %d files\n", result.name, count_deleted); + log_messages.printf(SchedMessages::NORMAL, "[%s] deleted %d file(s)\n", result.name, count_deleted); return 0; } diff --git a/sched/grep_logs b/sched/grep_logs new file mode 100755 index 0000000000..1aeda0dc72 --- /dev/null +++ b/sched/grep_logs @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +# $Id$ +# greplogs - grep logs for a string. + +use strict; +use warnings; + +my $html = 0; +die unless @ARGV; +if ($ARGV[0] eq '-html') { + shift; + $html = 1; +} + +my $s = shift; die unless defined $s; + +my $prev_file = ''; + +if ($html) { print "
"; }
+while () {
+    chomp;
+    if (/$s/) {
+        if ($ARGV ne $prev_file) {
+            $prev_file = $ARGV;
+            if ($html) {
+                print "

$ARGV

";
+            } else {
+                print "\n\n$ARGV:\n";
+            }
+        }
+        my $n = sprintf("%05d", $.);
+        if ($html) {
+            s%.*debug.*%$&%i;
+            s%.*critical|error.*%$&%i;
+            s%$s%$&%g if $s;
+            print "$n  $_\n";
+        } else {
+            print "  $n: $_\n";
+        }
+    }
+}
+if ($html) { print "
"; } diff --git a/test/boinc.py b/test/boinc.py index e5311b640d..8040723734 100644 --- a/test/boinc.py +++ b/test/boinc.py @@ -440,7 +440,7 @@ class Project: map(lambda (s): self.copy(os.path.join('sched', s), 'cgi/'), [ 'cgi', 'file_upload_handler', 'make_work', 'feeder', 'timeout_check', 'validate_test', - 'file_deleter', 'assimilator', 'start_servers', 'kill_server' ]) + 'file_deleter', 'assimilator', 'start_servers', 'kill_server', 'grep_logs' ]) verbose_echo(1, "Setting up database") map(self.run_db_script, [ 'drop.sql', 'schema.sql', 'constraints.sql' ]) @@ -526,11 +526,14 @@ class Project: htconfig = self.dir('html_user', '.htconfig.xml') htconfig2 = self.dir('html_ops', '.htconfig.xml') + htconfig3 = self.dir('html_ops', 'config.xml') f = open(htconfig, 'w') + self.log_dir = self.dir('cgi'); print >>f, map_xml(self, - [ 'db_name', 'db_passwd', 'download_url', 'cgi_url'] ) + [ 'db_name', 'db_passwd', 'download_url', 'cgi_url', 'log_dir'] ) f.close() shutil.copy(htconfig, htconfig2) + shutil.copy(htconfig, htconfig3) # edit "index.php" in the user HTML directory to have the right file # as the source for scheduler_urls; default is schedulers.txt diff --git a/test/test_backend.py b/test/test_backend.py index 3c4bbeeb62..a67df8ee3b 100755 --- a/test/test_backend.py +++ b/test/test_backend.py @@ -42,9 +42,9 @@ class ProjectBackend(ProjectUC): self.start_servers() def check(self): - # Give the server 30 seconds to finish assimilating/deleting + # Give the server 20 seconds to finish assimilating/deleting # TODO: use wait on all processes. - verbose_sleep("Sleeping to allow server daemons to finish", 30) + verbose_sleep("Sleeping to allow server daemons to finish", 20) self.check_results(ResultUC(), self.num) if __name__ == '__main__':