diff --git a/checkin_notes b/checkin_notes index 2f6ad9718d..0f52a3a7d6 100755 --- a/checkin_notes +++ b/checkin_notes @@ -22993,3 +22993,36 @@ Bruce 20 Jan 2005 client/ Makefile.am +David 20 Jan 2005 + - Added cross-project IDs for hosts. + This lets statistics sites show work per host, summed over projects. + + Implementation: + Hosts generate their own "internal" CPIDs, + using an MD5 of time/domain/IP/disk_free. + This should be unique across that user's hosts. + It's stored in the HOST_INFO structure and sent to server. + The server hashes the internal CPID with the user's email address + and stores the resulting "external" CPID in the host table. + It is included by db_dump in elements. + + PROJECT NOTE: if you use this server code you will need + to apply update_1_20_2005() from html/ops/db_update.php to existing DBs + + client/ + client_stats.h + hostinfo_unix.C + win/ + hostinfo_win.cpp + db/ + boinc_db.C,h + schema.sql + html/ops/ + db_update.php + lib/ + hostinfo.C,h + sched/ + db_dump.C + handle_request.C + server_types.C + start diff --git a/client/client_state.h b/client/client_state.h index 815c9148da..3db8a3041b 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -183,6 +183,7 @@ public: private: int parse_account_files(); int parse_preferences_for_user_files(); + // --------------- cs_apps.C: public: bool must_schedule_cpus; @@ -318,6 +319,7 @@ public: void check_all(); +#if 0 // ------------------ cs_data.C: // mechanisms for managing data saved on host // @@ -344,6 +346,8 @@ private: double offender(PROJECT*); double proj_potentially_free(PROJECT*); FILE_INFO* get_priority_or_lru(PROJECT*, int); +#endif + }; extern CLIENT_STATE gstate; diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index 2f167794d3..b12bdb5c3e 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -463,6 +463,9 @@ int HOST_INFO::get_host_info() { #error Need to specify a method to obtain OS name/version #endif + if (!strlen(host_cpid)) { + generate_host_cpid(); + } return 0; } diff --git a/client/win/hostinfo_win.cpp b/client/win/hostinfo_win.cpp index ce58684309..87defbbc4b 100755 --- a/client/win/hostinfo_win.cpp +++ b/client/win/hostinfo_win.cpp @@ -361,6 +361,10 @@ int HOST_INFO::get_host_info() { } RegCloseKey(hKey); + + if (!strlen(host_cpid)) { + generate_host_cpid(); + } return 0; } diff --git a/db/boinc_db.C b/db/boinc_db.C index 09a7bab020..57aadfeacd 100644 --- a/db/boinc_db.C +++ b/db/boinc_db.C @@ -338,6 +338,7 @@ void DB_HOST::db_print(char* buf){ ESCAPE(domain_name); ESCAPE(serialnum); ESCAPE(last_ip_addr); + ESCAPE(host_cpid); ESCAPE(p_vendor); ESCAPE(p_model); ESCAPE(os_name); @@ -358,7 +359,8 @@ void DB_HOST::db_print(char* buf){ "n_bwup=%.15e, n_bwdown=%.15e, " "credit_per_cpu_sec=%.15e, " "venue='%s', nresults_today=%d, " - "avg_turnaround=%f", + "avg_turnaround=%f, " + "host_cpid='%s' ", create_time, userid, rpc_seqno, rpc_time, total_credit, expavg_credit, expavg_time, @@ -374,7 +376,8 @@ void DB_HOST::db_print(char* buf){ n_bwup, n_bwdown, credit_per_cpu_sec, venue, nresults_today, - avg_turnaround + avg_turnaround, + host_cpid ); UNESCAPE(domain_name); UNESCAPE(serialnum); @@ -383,6 +386,7 @@ void DB_HOST::db_print(char* buf){ UNESCAPE(p_model); UNESCAPE(os_name); UNESCAPE(os_version); + UNESCAPE(host_cpid); } void DB_HOST::db_parse(MYSQL_ROW &r) { @@ -426,6 +430,7 @@ void DB_HOST::db_parse(MYSQL_ROW &r) { strcpy2(venue, r[i++]); nresults_today = atoi(r[i++]); avg_turnaround = atof(r[i++]); + strcpy2(host_cpid, r[i++]); } void DB_WORKUNIT::db_print(char* buf){ diff --git a/db/boinc_db.h b/db/boinc_db.h index c3f2ed8e4c..5e0eaec7e5 100755 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -261,6 +261,7 @@ struct HOST { char venue[256]; // home/work/school int nresults_today; // results sent since midnight double avg_turnaround; // recent average result turnaround time + char host_cpid[256]; // host cross-project ID int parse(FILE*); int parse_time_stats(FILE*); diff --git a/db/schema.sql b/db/schema.sql index 35891d4836..436bb03c44 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -167,6 +167,7 @@ create table host ( venue varchar(254) not null, nresults_today integer not null, avg_turnaround double not null, + host_cpid varchar(254), primary key (id) ) type=InnoDB; diff --git a/html/ops/db_update.php b/html/ops/db_update.php index d8b0bdd793..6dd1b5d4bc 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -233,6 +233,10 @@ function update_1_19_2005() { ); } +function update_1_20_2005() { + mysql_query("alter table host add host_cpid varchar(254)"; +} + //update_10_25_2004(); ?> diff --git a/lib/hostinfo.C b/lib/hostinfo.C index 57a04ee4ed..629cdbfbe4 100644 --- a/lib/hostinfo.C +++ b/lib/hostinfo.C @@ -32,6 +32,7 @@ #include "util.h" #include "parse.h" +#include "md5_file.h" #include "error_numbers.h" #include "hostinfo.h" @@ -43,6 +44,7 @@ void HOST_INFO::clear_host_info() { strcpy(domain_name, ""); strcpy(serialnum, ""); strcpy(ip_addr, ""); + strcpy(host_cpid, ""); p_ncpus = 0; strcpy(p_vendor, ""); @@ -77,6 +79,7 @@ int HOST_INFO::parse(MIOFILE& in) { else if (parse_int(buf, "", timezone)) continue; else if (parse_str(buf, "", domain_name, sizeof(domain_name))) continue; else if (parse_str(buf, "", ip_addr, sizeof(ip_addr))) continue; + else if (parse_str(buf, "", host_cpid, sizeof(host_cpid))) continue; else if (parse_int(buf, "", p_ncpus)) continue; else if (parse_str(buf, "", p_vendor, sizeof(p_vendor))) continue; else if (parse_str(buf, "", p_model, sizeof(p_model))) continue; @@ -117,6 +120,7 @@ int HOST_INFO::write(MIOFILE& out) { " %d\n" " %s\n" " %s\n" + " %s\n" " %d\n" " %s\n" " %s\n" @@ -138,6 +142,7 @@ int HOST_INFO::write(MIOFILE& out) { timezone, domain_name, ip_addr, + host_cpid, p_ncpus, p_vendor, p_model, @@ -206,4 +211,14 @@ int HOST_INFO::write_cpu_benchmarks(FILE* out) { return 0; } +// make a host cross-project ID. +// Should be unique across hosts with very high probability +// +void HOST_INFO::generate_host_cpid() { + char buf[1024]; + + sprintf(buf, "%f%s%s%f", dtime(), domain_name, ip_addr, d_free); + md5_block((const unsigned char*) buf, strlen(buf), host_cpid); +} + const char *BOINC_RCSID_edf7e5c147 = "$Id$"; diff --git a/lib/hostinfo.h b/lib/hostinfo.h index f8060762ba..372ba0982a 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -35,6 +35,7 @@ struct HOST_INFO { char domain_name[256]; char serialnum[256]; char ip_addr[256]; + char host_cpid[64]; int p_ncpus; char p_vendor[256]; @@ -66,6 +67,7 @@ struct HOST_INFO { bool users_idle(bool check_all_logins, double idle_time_to_run); int get_host_info(); void clear_host_info(); + void generate_host_cpid(); }; #ifdef _WIN32 diff --git a/sched/db_dump.C b/sched/db_dump.C index 809f527479..a562a703dd 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -341,7 +341,8 @@ void write_host(HOST& host, FILE* f, bool detail) { " %f\n" " %f\n" " %f\n" - " %f\n", + " %f\n" + " %s\n", host.create_time, host.rpc_time, host.timezone, @@ -356,7 +357,8 @@ void write_host(HOST& host, FILE* f, bool detail) { host.d_free, host.n_bwup, host.n_bwdown, - host.avg_turnaround + host.avg_turnaround, + host.host_cpid ); } fprintf(f, diff --git a/sched/handle_request.C b/sched/handle_request.C index aa03cefe70..b8c2a148d7 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -256,11 +256,16 @@ static int modify_host_struct(SCHEDULER_REQUEST& sreq, HOST& host) { return 0; } -static int update_host_record(HOST& xhost) { +static int update_host_record(HOST& xhost, USER& user) { DB_HOST host; int retval; + char buf[1024]; host = xhost; + if (strlen(host.host_cpid)) { + sprintf(buf, "%s%s", host.host_cpid, user.email_addr); + md5_block((const unsigned char*)buf, strlen(buf), host.host_cpid); + } retval = host.update(); if (retval) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "host.update() failed: %d\n", retval); @@ -865,7 +870,7 @@ void process_request( handle_msgs_to_host(sreq, reply); } - update_host_record(reply.host); + update_host_record(reply.host, reply.user); leave: if (!have_no_work) { diff --git a/sched/server_types.C b/sched/server_types.C index b488639284..88282b38b5 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -476,6 +476,7 @@ int HOST::parse(FILE* fin) { else if (parse_str(buf, "", domain_name, sizeof(domain_name))) continue; else if (parse_str(buf, "", serialnum, sizeof(serialnum))) continue; else if (parse_str(buf, "", last_ip_addr, sizeof(last_ip_addr))) continue; + else if (parse_str(buf, "", host_cpid, sizeof(host_cpid))) continue; else if (parse_int(buf, "", p_ncpus)) continue; else if (parse_str(buf, "", p_vendor, sizeof(p_vendor))) continue; else if (parse_str(buf, "", p_model, sizeof(p_model))) continue; diff --git a/sched/start b/sched/start index e515be8615..316634048b 100755 --- a/sched/start +++ b/sched/start @@ -670,7 +670,7 @@ for opt,v in opts: command = command_enable_start elif opt == '-c' or opt == '--cron': command = command_cron_start - elif opt == '-c' or opt == '--cron-task': + elif opt == '--cron-task': command = command_tasks_start elif opt == '-d' or opt == '--disable' or opt == '--stop' or opt == '-k' or opt == '--kill': command = command_disable_stop