From 768f3bfe0bbdc9e2b9a8ddbcefec4695b1fce3e4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 15 Feb 2010 01:00:32 +0000 Subject: [PATCH] - client: include CPU usage of client in BOINC total. Also include manager if its name includes "boinc" (can't figure out another way) svn path=/trunk/boinc/; revision=20566 --- checkin_notes | 8 ++++++++ lib/procinfo_mac.cpp | 4 ++-- lib/procinfo_unix.cpp | 5 +++-- lib/procinfo_win.cpp | 7 ++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/checkin_notes b/checkin_notes index c2390d99fa..5a9677d6bb 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1175,3 +1175,11 @@ David 13 Feb 2010 html/user edit_user_info_form/action.php + +David 14 Feb 2010 + - client: include CPU usage of client in BOINC total. + Also include manager if its name includes "boinc" + (can't figure out another way) + + lib/ + procinfo*.cpp diff --git a/lib/procinfo_mac.cpp b/lib/procinfo_mac.cpp index 6ae41ced23..53405305ba 100644 --- a/lib/procinfo_mac.cpp +++ b/lib/procinfo_mac.cpp @@ -38,7 +38,7 @@ using std::vector; // build table of all processes in system // int procinfo_setup(vector& pi) { - + int pid = getpid(); FILE* fd; PROCINFO p; int c, real_mem, virtual_mem, hours; @@ -106,7 +106,7 @@ int procinfo_setup(vector& pi) { p.working_set_size = (double)real_mem * 1024.; p.swap_size = (double)virtual_mem * 1024.; p.user_time += 60. * (float)hours; - p.is_boinc_app = false; + p.is_boinc_app = (p.id == pid || strstr(p.command, "boinc")); pi.push_back(p); } diff --git a/lib/procinfo_unix.cpp b/lib/procinfo_unix.cpp index 077b151748..fec2e05668 100644 --- a/lib/procinfo_unix.cpp +++ b/lib/procinfo_unix.cpp @@ -170,6 +170,7 @@ int procinfo_setup(vector& pi) { PROCINFO p; char pidpath[1024]; char buf[1024]; + int pid = getpid(); dir = opendir("/proc"); if (!dir) return 0; @@ -205,7 +206,7 @@ int procinfo_setup(vector& pi) { p.page_fault_count = prusage.pr_majf + prusage.pr_minf; } fclose(fd); - p.is_boinc_app = false; + p.is_boinc_app = (p.id == pid || strstr(p.command, "boinc")); pi.push_back(p); } } @@ -230,7 +231,7 @@ int procinfo_setup(vector& pi) { p.user_time = ps.utime / 100.; p.kernel_time = ps.stime / 100.; strlcpy(p.command, ps.comm, sizeof(p.command)); - p.is_boinc_app = false; + p.is_boinc_app = (p.id == pid || strstr(p.command, "boinc")); pi.push_back(p); } #endif diff --git a/lib/procinfo_win.cpp b/lib/procinfo_win.cpp index a80be7877d..390dd3ed1d 100644 --- a/lib/procinfo_win.cpp +++ b/lib/procinfo_win.cpp @@ -67,6 +67,11 @@ int get_procinfo_XP(vector& pi) { ULONG cbBuffer = 128*1024; // 128k initial buffer PVOID pBuffer = NULL; PSYSTEM_PROCESSES pProcesses = NULL; + statid DWORD pid = 0; + + if (!pid) { + pid = GetCurrentProcessId(); + } #if 0 printf("FILETIME: %d\n", sizeof(FILETIME)); printf("LARGE_INTEGER: %d\n", sizeof(LARGE_INTEGER)); @@ -97,7 +102,7 @@ int get_procinfo_XP(vector& pi) { sizeof(p.command), NULL, NULL ); - p.is_boinc_app = false; + p.is_boinc_app = (p.id == pid) || (strcmp(p.command, "boinc") != NULL); pi.push_back(p); if (!pProcesses->NextEntryDelta) { break;