mirror of https://github.com/BOINC/boinc.git
log grepping/showing
svn path=/trunk/boinc/; revision=1639
This commit is contained in:
parent
c276b739f2
commit
693650b406
|
@ -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
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ function host_short_header() {
|
|||
function show_host_short($host) {
|
||||
echo "
|
||||
<tr>
|
||||
<td><a href=db_action?table=host&id=$host->id>$host->id</a></td>
|
||||
<td><a href=db_action.php?table=host&id=$host->id>$host->id</a></td>
|
||||
<td>$host->last_ip_addr</td>
|
||||
<td>$host->domain_name</td>
|
||||
<td>$host->p_vendor $host->p_model</td>
|
||||
|
@ -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", "<a href=db_action?table=result&detail=low&hostid=$host->id&sort_by=sent_time>click here</a>");
|
||||
row("Results", "<a href=db_action.php?table=result&detail=low&hostid=$host->id&sort_by=sent_time>click here</a>");
|
||||
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("","<a href=db_action.php?table=result&wu_id=$wu->id>Show associated results</a>");
|
||||
row("","<a href=show_log.php?s=$wu->name>Grep logs for</a>");
|
||||
end_table();
|
||||
echo "<p>";
|
||||
}
|
||||
|
@ -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("","<a href=show_log.php?s=$result->name>Grep logs</a>");
|
||||
end_table();
|
||||
echo "<p>";
|
||||
}
|
||||
|
@ -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", "<a href=db_action?table=host&userid=$user->id&detail=low>click</a>");
|
||||
row("Hosts", "<a href=db_action.php?table=host&userid=$user->id&detail=low>click</a>");
|
||||
end_table();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php {
|
||||
|
||||
// $Id$
|
||||
|
||||
// grep logs for a particular string
|
||||
|
||||
require_once("util.inc");
|
||||
|
||||
$log_dir = parse_config("<log_dir>");
|
||||
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 "<form action=show_log.php>";
|
||||
echo " String: <input name=s value='$s'>";
|
||||
echo " Files: <input name=f value='$f'>";
|
||||
echo " <input type=submit value=Grep></form>";
|
||||
|
||||
passthru("cd $log_dir && ./grep_logs -html '$s' $f 2>&1");
|
||||
|
||||
page_tail();
|
||||
} ?>
|
|
@ -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, "</file_info>")) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "<pre>"; }
|
||||
while (<ARGV>) {
|
||||
chomp;
|
||||
if (/$s/) {
|
||||
if ($ARGV ne $prev_file) {
|
||||
$prev_file = $ARGV;
|
||||
if ($html) {
|
||||
print "</pre><h2>$ARGV</h2><pre>";
|
||||
} else {
|
||||
print "\n\n$ARGV:\n";
|
||||
}
|
||||
}
|
||||
my $n = sprintf("%05d", $.);
|
||||
if ($html) {
|
||||
s%.*debug.*%<font color=grey>$&</font>%i;
|
||||
s%.*critical|error.*%<font color=red>$&</font>%i;
|
||||
s%$s%<b>$&</b>%g if $s;
|
||||
print "<font size=-1><a name=$. href=show_log.php?f=$ARGV#$.>$n</a></font> $_\n";
|
||||
} else {
|
||||
print " $n: $_\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($html) { print "</pre>"; }
|
|
@ -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
|
||||
|
|
|
@ -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__':
|
||||
|
|
Loading…
Reference in New Issue