stripcharts

svn path=/trunk/boinc/; revision=790
This commit is contained in:
David Anderson 2002-12-24 03:03:45 +00:00
parent 86812c0d41
commit 7b22233809
18 changed files with 146 additions and 123 deletions

View File

@ -2768,3 +2768,38 @@ David Dec 19 2002
win/
wingui.cpp,h
David Dec 23 2002
- Made stripcharts work with BOINC test framework
The script "test_loop.php" now generates a data file of
CPU load that can be graphed using stripchart.
TODO: add other data sources
- added "country" field to team
- expanded team description from 256 chars to blob
- turned off debug output from file upload handler, scheduler
- removed "time" args from various Project member functions
in test.inc. Use sleep().
db/
db.h
db_mysql.C
schema.sql
html_user/
db.inc
team_create_form.php
sched/
file_upload_handler.C
handle_request.C
result_retry.C
stripchart/
stripchart.cgi
stripchart.cnf
samples/
datafiles
test/
test.inc
test_download_backoff.php
test_loop.php
test_masterurl_failure.php
test_sched_failure.php

19
db/db.h
View File

@ -112,15 +112,13 @@ struct USER {
int teamid; // if user is part of a team
};
#define TEAM_TYPE_COMPANY_SMALL 1
#define TEAM_TYPE_COMPANY_MEDIUM 2
#define TEAM_TYPE_COMPANY_LARGE 3
#define TEAM_TYPE_CLUB 4
#define TEAM_TYPE_PRIMARY 5
#define TEAM_TYPE_SECONDARY 6
#define TEAM_TYPE_UNIVERSITY 7
#define TEAM_TYPE_JUNIOR_COLLEGE 8
#define TEAM_TYPE_GOVERNMENT 9
#define TEAM_TYPE_CLUB 1
#define TEAM_TYPE_COMPANY 2
#define TEAM_TYPE_PRIMARY 3
#define TEAM_TYPE_SECONDARY 4
#define TEAM_TYPE_JUNIOR_COLLEGE 5
#define TEAM_TYPE_UNIVERSITY 6
#define TEAM_TYPE_GOVERNMENT 7
struct TEAM {
int id;
@ -130,8 +128,9 @@ struct TEAM {
char url[256];
int type; // Team type (see above)
char name_html[256];
char description[256];
char description[MAX_BLOB_SIZE];
int nusers;
char country[256];
};
struct HOST {

View File

@ -146,7 +146,8 @@ void struct_to_str(void* vp, char* q, int type) {
sprintf(q,
"id=%d, userid=%d, name='%s', "
"name_lc='%s', url='%s', "
"type=%d, name_html='%s', description='%s', nusers=%d",
"type=%d, name_html='%s', description='%s', nusers=%d, "
"country='%s'",
tp->id,
tp->userid,
tp->name,
@ -155,7 +156,8 @@ void struct_to_str(void* vp, char* q, int type) {
tp->type,
tp->name_html,
tp->description,
tp->nusers
tp->nusers,
tp->country
);
break;
case TYPE_HOST:
@ -326,6 +328,7 @@ void row_to_struct(MYSQL_ROW& r, void* vp, int type) {
strcpy2(tp->name_html, r[i++]);
strcpy2(tp->description, r[i++]);
tp->nusers = atoi(r[i++]);
strcpy2(tp->country, r[i++]);
break;
case TYPE_HOST:
hp = (HOST*)vp;

View File

@ -61,8 +61,9 @@ create table team (
url varchar(254),
type integer not null,
name_html varchar(254),
description varchar(254),
description blob,
nusers integer not null,
country varchar(254),
total_credit double not null, /* temp */
expavg_credit double not null, /* temp */
primary key (id)

View File

@ -3,8 +3,6 @@
// database-related functions.
// Presentation code (HTML) shouldn't be here
// TODO: add support for host, user, password
function db_init() {
$retval = mysql_pconnect();
if (!$retval) {

View File

@ -27,7 +27,8 @@ You'll become the founding member of the team.
<table>
<tr>
<td valign=top>Team name (text version)
<br><font size=2>This name will be printed as-is and is the name
<br><font size=2>This name will be printed as text.
It's the name
you should use <br>when searching for your Team.
</td>
<td valign=top><input name=name type=text size=50>
@ -52,26 +53,31 @@ If you don't know HTML, just leave this box blank.
</tr><tr>
<td valign=top>Type of team:</td>
<td valign=top>
<input type=radio name=type value=4 checked>Club
<input type=radio name=type value=1 checked> Club
<br>
<input type=radio name=type value=1>Small Company (< 50 employees)
<input type=radio name=type value=2> Company
<br>
<input type=radio name=type value=2>Medium Company (50-1000 employees)
<input type=radio name=type value=3> Primary School
<br>
<input type=radio name=type value=3>Large Company (> 1000 employees)
<input type=radio name=type value=4> Secondary School
<br>
<input type=radio name=type value=5>Primary School
<input type=radio name=type value=5> Junior College
<br>
<input type=radio name=type value=6>Secondary School
<input type=radio name=type value=6> University or Department
<br>
<input type=radio name=type value=8>Junior College
<br>
<input type=radio name=type value=7>University or Department
<br>
<input type=radio name=type value=9>Government Agency
</td>
<input type=radio name=type value=7> Government Agency
</td>
</tr>
<tr><td>Country</td>
<td>
<select name=country>
<?php
print_country_select("None");
?>
</select>
</td></tr>
<tr><td valign=top><br></td><td valign=top>
<input type=submit name=new value="Create Team">
</td></tr>

View File

@ -34,7 +34,7 @@
CONFIG config;
#define DEBUG
//#define DEBUG
#define MAX_FILES 32

View File

@ -425,10 +425,12 @@ int send_work(
);
if (retval) continue;
#if 0
fprintf(stderr,
"BOINC scheduler: sending result name %s, id %d\n",
result.name, result.id
);
#endif
// copy the result so we don't overwrite its XML fields
//

View File

@ -257,7 +257,7 @@ update_wu:
return did_something;
}
void main_loop() {
void main_loop(bool one_pass) {
APP app;
bool did_something;
int retval;
@ -277,6 +277,7 @@ void main_loop() {
while (1) {
did_something = do_pass(app);
if (one_pass) break;
if (!did_something) sleep(1);
check_trigger();
}
@ -284,7 +285,7 @@ void main_loop() {
int main(int argc, char** argv) {
int i, retval;
bool asynch = false;
bool asynch = false, one_pass=false;
char path[256];
retval = config.parse_file();
@ -310,6 +311,8 @@ int main(int argc, char** argv) {
max_done = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-asynch")) {
asynch = true;
} else if (!strcmp(argv[i], "-one_pass")) {
one_pass = true;
} else if (!strcmp(argv[i], "-nredundancy")) {
nredundancy = atoi(argv[++i]);;
}
@ -319,5 +322,5 @@ int main(int argc, char** argv) {
exit(0);
}
}
main_loop();
main_loop(one_pass);
}

View File

@ -1,5 +1,5 @@
# This is the list of data sources for stripchart, in the colon-delimited format:
# full path to data file:title for the graph:column number in the data file:flags to stripchart
# path to data file:title for the graph:column number in the data file:flags to stripchart
#
# examples:
# /disks/matt/data_files/connections:connection drops:3
@ -8,4 +8,4 @@
# To put in a horizontal rule for ease of selection, use the line:
# x:----------------------------------:x
#
/disks/matt/data_files/get_load:machine load:3
get_load_out:machine load:3

View File

@ -124,7 +124,7 @@ sub to_unix_time {
if ($query->param("flags") ne "") {
$flags = $query->param("flags");
$outfile = "/tmp/tempout$$" . "." . rand(100000);
print "Content-type: image/gif\n\n";
print "Pragma: nocache\nCache-Control: no-cache\nContent-type: image/gif\n\n";
`$stripchartexe $flags > $outfile`;
open (OUTFILE,"$outfile");
while ($dummy=read(OUTFILE,$buffer,1024)) { print $buffer }

View File

@ -5,9 +5,10 @@ use Time::Local;
# What version is this?
$majorversion = 2; $minorversion = 1;
# Where is gnuplot located?
# Directory where gnuplot is
# $gnuplot = "/usr/local/gnuplot-3.7";
$gnuplot = "/disks/asimov/a/users/hiramc/local/src/gnuplot-3.7";
#$gnuplot = "/disks/asimov/a/users/hiramc/local/src/gnuplot-3.7";
$gnuplot = "/usr/local/bin"
# Temporary files
$suffix = rand(10000);
@ -29,9 +30,9 @@ $plotheight = 180;
@monthabbs = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
# Where are these unix commands located?
$tailexe = "/usr/ucb/tail";
$catexe = "/usr/bin/cat";
$grepexe = "/usr/bin/grep";
$tailexe = "tail";
$catexe = "cat";
$grepexe = "grep";
# How many seconds in a day?
$daysecs = 86400;
@ -51,11 +52,11 @@ $defaultflags = "-s";
# Where is the list of datafiles for stripchart.cgi?
# Note: there is a sample copy in the samples directory:
$datafilelist = "/disks/jill/a/inet_services/www/share/cgi-bin/lib/datafiles";
$datafilelist = "datafiles";
# Where is the list of user-definied cgi queries?
# Note: this file gets created by the cgi - must put it somewhere that the cgi user can write to
$queryfilelist = "/disks/jill/a/inet_services/www/share/cgi-bin/lib/querylist";
$queryfilelist = "querylist";
# What time is it right now?
$rightnow = time;

View File

@ -105,6 +105,7 @@ class Project {
var $user_name;
var $master_url;
var $resource_share;
var $source_dir;
function Project() {
$this->name = "test";
@ -116,6 +117,7 @@ class Project {
$this->generate_keys = false;
$this->shmem_key = get_env_var("BOINC_SHMEM_KEY");
$this->resource_share = 1;
$this->source_dir = get_env_var("BOINC_SRC_DIR");
}
function add_user($user) {
@ -137,8 +139,8 @@ class Project {
// Set up the database and directory structures for a project
//
function Install($scheduler_file = null) {
$source_dir = $this->source_dir;
$base_dir = get_env_var("BOINC_PROJECTS_DIR");
$source_dir = get_env_var("BOINC_SRC_DIR");
$cgi_url = get_env_var("BOINC_CGI_URL")."/".$this->name;
$this->download_url = get_env_var("BOINC_HTML_URL")."/".$this->name."/download";
//link download1...downloadn to download. Get this from reading the reading how many <urls>s in the template. For uploads
@ -242,7 +244,6 @@ class Project {
}
PassThru("cp $source_dir/sched/cgi $this->project_dir/cgi/");
// would have to be able to add more of these, copy several to cgi dir
PassThru("cp $source_dir/sched/file_upload_handler $this->project_dir/cgi/");
PassThru("cp $source_dir/sched/make_work $this->project_dir/cgi/");
PassThru("cp $source_dir/sched/feeder $this->project_dir/cgi/");
@ -250,7 +251,6 @@ class Project {
PassThru("cp $source_dir/sched/validate_test $this->project_dir/cgi/");
PassThru("cp $source_dir/sched/file_deleter $this->project_dir/cgi/");
PassThru("cp $source_dir/sched/assimilator $this->project_dir/cgi/");
PassThru("cp $source_dir/html_ops/stripchart.cgi $this->project_dir/cgi/");
$f = fopen("$this->project_dir/cgi/config.xml", "w");
fputs($f, "<config>\n");
fputs($f, " <db_name>$this->db_name</db_name>\n");
@ -299,115 +299,69 @@ class Project {
echo "The admin URL for project $this->name is $admin_url\n";
}
// moves the masterindex file to temp after $time seconds (if not null).
// moves the masterindex file to temp
// This is used to test exponential backoff on the client side.
//
function delete_masterindex($time=null) {
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
function delete_masterindex() {
PassThru("mv $this->project_dir/html_user/index.php $this->project_dir/html_user/temp");
}
// moves temp back to the masterindex after $time seconds(if not null).
// moves temp back to the masterindex
// This is used to test exponential backoff on the client side.
//
function reestablish_masterindex($time=null) {
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
function reestablish_masterindex() {
PassThru("mv $this->project_dir/html_user/temp $this->project_dir/html_user/index.php");
}
// delete the cgi file for this project after $time if not null.
// delete the cgi file for this project
// This is used to test exponential backoff on the client side.
//
function delete_scheduler($time=null,$cgi_num = null) {
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
function delete_scheduler($cgi_num = null) {
PassThru("rm $this->project_dir/cgi/cgi$cgi_num");
}
// copies the cgi file back into the cgi directory.
// This is used to test exponential backoff on the client side.
//
function reinstall_scheduler($time=null,$cgi_num=null) {
$source_dir = get_env_var("BOINC_SRC_DIR");
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
PassThru("cp $source_dir/sched/cgi $this->project_dir/cgi/cgi$cgi_num");
function reinstall_scheduler($cgi_num=null) {
PassThru("cp $this->source_dir/sched/cgi $this->project_dir/cgi/cgi$cgi_num");
}
// moves the download directory to temp.
// This is used to test exponential backoff on the client side.
// This is used to test exponential backoff
//
function delete_downloaddir($time = null,$download_dir_num = null) {
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
function delete_downloaddir($download_dir_num = null) {
PassThru("mv $this->project_dir/download$download_dir_num $this->project_dir/download_moved$download_dir_num");
}
// reinstalls the download directory.
// This is used to test exponential backoff on the client side.
// This is used to test exponential backoff
//
function reinstall_downloaddir($time = null ,$download_dir_num = null) {
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
function reinstall_downloaddir($download_dir_num = null) {
PassThru("mv $this->project_dir/download_moved$download_dir_num $this->project_dir/download$download_dir_num");
}
function remove_file_upload_handler($time = null,$handler_num = null) {
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
function remove_file_upload_handler($handler_num = null) {
PassThru("rm $this->project_dir/cgi/file_upload_handler$handler_num");
}
function reinstall_file_upload_handler($time = null,$handler_num = null) {
$source_dir = get_env_var("BOINC_SRC_DIR");
if($time != null) {
echo "\nsleeping for $time seconds";
PassThru("sleep $time");
}
PassThru("cp $source_dir/sched/file_upload_handler $this->project_dir/cgi/file_upload_handler$handler_num");
function reinstall_file_upload_handler($handler_num = null) {
PassThru("cp $this->source_dir/sched/file_upload_handler $this->project_dir/cgi/file_upload_handler$handler_num");
}
// blocks until a file_upload_handler is running in the system,
// kills it and returns
//
function kill_file_upload_handler() {
while(true) {
$pid = exec("pgrep -n file_up");
if($pid != null) break;
}
PassThru("kill -9 $pid");
}
function start_feeder(){
PassThru("cd $this->project_dir/cgi; ./feeder -asynch > feeder_out");
}
function result_retry($app, $nerror = 5, $ndet = 5, $nredundancy = 5){
PassThru("cd $this->project_dir/cgi; ./result_retry -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy > result_retry_out");
PassThru("cd $this->project_dir/cgi; ./result_retry -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy > result_retry_out");
}
function start_result_retry($app, $nerror = 5,$ndet = 5, $nredundancy = 5){
PassThru("cd $this->project_dir/cgi; ./result_retry -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy -asynch > result_retry_out");
PassThru("cd $this->project_dir/cgi; ./result_retry -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy -asynch > result_retry_out");
}
function start_make_work($work){
$result_template_path = realpath($work->result_template);
@ -446,6 +400,19 @@ class Project {
PassThru("cd $this->project_dir/cgi; ./assimilator -one_pass -app $app->name > assimilator_out");
}
// start collecting data for stripcharts
//
function start_stripchart() {
$source_dir = $this->source_dir;
PassThru("cp $source_dir/stripchart/stripchart.cgi $this->project_dir/cgi/");
PassThru("cp $source_dir/stripchart/stripchart $this->project_dir/cgi/");
PassThru("cp $source_dir/stripchart/stripchart.cnf $this->project_dir/cgi/");
PassThru("cp $source_dir/stripchart/samples/datafiles $this->project_dir/cgi/");
PassThru("cp $source_dir/stripchart/samples/get_load $this->project_dir/cgi/");
PassThru("cp $source_dir/stripchart/samples/get_load_loop $this->project_dir/cgi/");
PassThru("cd $this->project_dir/cgi; get_load_loop > get_load_out &");
}
// this should stop the feeder and any other daemons
//
function stop() {
@ -671,7 +638,9 @@ class Work {
PassThru("cp $x $project->project_dir/download");
}
if (false) { // doesn't belong here; needs comment
// simulate multiple data servers by making symbolic links
// to the download directory
//
$f = fopen($this->wu_template,"r");
while(true) {
$temp = fgets($f,1000);
@ -686,6 +655,9 @@ if (false) { // doesn't belong here; needs comment
}
}
// simulate multiple data servers by making copies of
// the file upload handler
//
fclose($f);
$source_dir = get_env_var("BOINC_SRC_DIR");
$append = null;
@ -706,8 +678,7 @@ if (false) { // doesn't belong here; needs comment
}
}
fclose($f);
}
$cmd = "create_work -db_name $project->db_name -download_dir $project->project_dir/download -upload_url $project->upload_url -download_url $project->download_url -keyfile $project->key_dir/upload_private -appname $app->name -rsc_iops $this->rcs_iops -rsc_fpops $this->rsc_fpops -rsc_disk $this->rsc_disk -wu_template $this->wu_template -result_template $this->result_template -redundancy $this->redundancy -wu_name $this->wu_template -delay_bound $this->delay_bound";
for ($i=0; $i<sizeof($this->input_files); $i++) {

View File

@ -41,11 +41,12 @@
//delete the download_dir immediately
$project->delete_downloaddir();
$pid = $host->run_asynch("-exit_when_idle");
//reinstall download_dir after 100 seconds
$project->reinstall_downloaddir(100,null);
echo "sleeping 100 secs\n";
sleep(100);
$project->reinstall_downloaddir(null);
$status = 0;
//wait until the host has stopped running
pcntl_waitpid($pid,$status,0);
pcntl_waitpid($pid, $status, 0);
$project->stop();
$result->state = RESULT_STATE_DONE;

View File

@ -33,6 +33,7 @@
$project->start_feeder();
$project->start_make_work($work);
$project->start_validate($app, 3);
$project->start_stripchart();
$host->run("");
//$project->stop();

View File

@ -38,9 +38,11 @@
$work->install($project);
$project->start_feeder();
$project->delete_masterindex(null);
$project->delete_masterindex();
$pid = $host->run_asynch("-exit_when_idle");
$project->reestablish_masterindex(100);
echo "sleeping for 100 seconds\n";
sleep(100);
$project->reestablish_masterindex();
$status = 0;
pcntl_waitpid($pid,$status,0);
$project->stop();

View File

@ -38,11 +38,11 @@
$work->install($project);
$project->start_feeder();
//delete the scheduler immediately
$project->delete_scheduler();
$pid = $host->run_asynch("-exit_when_idle");
//reinstall scheduler after 500 seconds
$project->reinstall_scheduler(100);
echo "sleeping for 100 seconds\n";
sleep(100);
$project->reinstall_scheduler();
$status = 0;
//wait until the host has stopped running
pcntl_waitpid($pid,$status,0);

View File

@ -38,15 +38,15 @@
$work->install($project);
$project->start_feeder();
//delete the download_dir immediately
$project->remove_file_upload_handler();
$pid = $host->run_asynch("-exit_when_idle");
//reinstall download_dir after 100 seconds
$project->reinstall_file_upload_handler(20,null);
echo "sleeping 20 secs\n";
sleep(20);
$project->reinstall_file_upload_handler(null);
$status = 0;
//wait until the host has stopped running
pcntl_waitpid($pid,$status,0);
pcntl_waitpid($pid, $status,0);
$project->stop();
$result->state = RESULT_STATE_DONE;