diff --git a/api/boinc_api.C b/api/boinc_api.C index 84738bd9c1..35f6e74388 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -287,28 +287,6 @@ int boinc_get_init_data(APP_INIT_DATA& app_init_data) { return 0; } -// resolve XML soft links -// -int boinc_resolve_filename(char *virtual_name, char *physical_name, int len) { - FILE *fp; - char buf[512]; - - safe_strncpy(physical_name, virtual_name, len); - - // Open the file and load the first line - fp = fopen(virtual_name, "r"); - if (!fp) return 0; - - fgets(buf, 512, fp); - fclose(fp); - - // If it's the XML tag, return its value, - // otherwise, return the original file name - // - parse_str(buf, "", physical_name, len); - return 0; -} - bool boinc_time_to_checkpoint() { #ifdef __APPLE_CC__ YieldToAnyThread(); diff --git a/client/hostinfo.h b/client/hostinfo.h index 3868181c95..c706141d4b 100644 --- a/client/hostinfo.h +++ b/client/hostinfo.h @@ -63,7 +63,6 @@ extern bool host_is_running_on_batteries(); extern int get_host_info(HOST_INFO&); extern void clear_host_info(HOST_INFO&); -extern void get_host_disk_info( double &total_space, double &free_space ); extern int get_local_domain_name(char* p, int len); extern int get_local_ip_addr_str(char* p, int len); diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index ae2d4a3f89..ed96c4a835 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -32,9 +32,6 @@ #ifdef HAVE_SYS_MOUNT_H #include #endif -#ifdef HAVE_SYS_STATVFS_H -#include -#endif #ifdef HAVE_SYS_VFS_H #include #endif @@ -42,12 +39,6 @@ #include #endif -#ifdef HAVE_SYS_STATVFS_H -#define STATFS statvfs -#else -#define STATFS statfs -#endif - #ifdef _WIN32 #include #include @@ -74,6 +65,7 @@ #endif #include "client_types.h" +#include "filesys.h" #include "error_numbers.h" #include "util.h" @@ -92,7 +84,7 @@ char* ip_addr_string(int ip_addr) { // Returns the number of seconds difference from UTC // -int get_timezone( void ) { +int get_timezone() { tzset(); // TODO: take daylight savings time into account #ifdef HAVE_GMTOFF @@ -161,24 +153,10 @@ void parse_cpuinfo(HOST_INFO& host) { } #endif -// Returns total and free space on current disk (in bytes) -// -void get_host_disk_info( double &total_space, double &free_space ) { -#ifdef STATFS - struct STATFS fs_info; - - STATFS(".", &fs_info); - total_space = (double)fs_info.f_bsize * (double)fs_info.f_blocks; - free_space = (double)fs_info.f_bsize * (double)fs_info.f_bavail; -#else -#error Need to specify a method to obtain free/total disk space -#endif -} - -// General function to get all relevant host information +// get all relevant host information // int get_host_info(HOST_INFO& host) { - get_host_disk_info( host.d_total, host.d_free ); + get_filesystem_info(host.d_total, host.d_free); #ifdef linux parse_cpuinfo(host); diff --git a/doc/create_project.html b/doc/create_project.html index 54bdcb93f6..09714f4715 100644 --- a/doc/create_project.html +++ b/doc/create_project.html @@ -84,6 +84,7 @@ Monitoring the performance of a BOINC project Tools for monitoring the system as a whole. diff --git a/doc/db_dump.html b/doc/db_dump.html index ecaa2b1f98..cc3ee1066d 100644 --- a/doc/db_dump.html +++ b/doc/db_dump.html @@ -146,6 +146,8 @@ g%27%3E</name_html> <name>Eric Heien</name> <total_credit>4897.904591</total_credit> <expavg_credit>9820.631754</expavg_credit> + <country>United States</country> +<create_time>1046220857</ncreate_time> <teamid>14</teamid> <host> <id>27</id> diff --git a/doc/watchdog.html b/doc/watchdog.html new file mode 100644 index 0000000000..6c519ab691 --- /dev/null +++ b/doc/watchdog.html @@ -0,0 +1,30 @@ +

Watchdogs

+ +

+A watchdog is a mechanism for detecting system states +(e.g. full filesystems, database failures, etc.) +that require immediate attention by project staff. +Typically the desired response to such a condition is +to notify a pager, sending a short text description. + +

+BOINC provides a framework for defining watchdogs: + +

    +
  • +A set of watchdog scripts are run from cron. +Each script checks for an error condition, +and present, it appends a descriptive line to an error log file. +An example is wd_nresults_changing.php, +which makes sure that the number of results changes. + +
  • +The script wd.php, also run from cron, +scans the error log files. +If any has been updated since the last run, +it sends email to a set of recipients, +containing the last line of the file. + +
+ +These files are in the sched/ directory. diff --git a/lib/app_ipc.C b/lib/app_ipc.C index 4a253dc815..cbb745d318 100755 --- a/lib/app_ipc.C +++ b/lib/app_ipc.C @@ -1,6 +1,7 @@ #include #include "parse.h" +#include "error_numbers.h" #include "util.h" #include "app_ipc.h" @@ -209,3 +210,39 @@ int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi) { return -1; } +// create a file (new_link) which contains an XML +// reference to existing file. +// +int boinc_link(char *existing, char *new_link) { + FILE *fp; + + fp = fopen(new_link, "w"); + if (!fp) return ERR_FOPEN; + fprintf(fp, "%s\n", existing); + fclose(fp); + + return 0; +} + +// resolve XML soft link +// +int boinc_resolve_filename(char *virtual_name, char *physical_name, int len) { + FILE *fp; + char buf[512]; + + safe_strncpy(physical_name, virtual_name, len); + + // Open the file and load the first line + fp = fopen(virtual_name, "r"); + if (!fp) return 0; + + fgets(buf, 512, fp); + fclose(fp); + + // If it's the XML tag, return its value, + // otherwise, return the original file name + // + parse_str(buf, "", physical_name, len); + return 0; +} + diff --git a/lib/app_ipc.h b/lib/app_ipc.h index 317ae8e677..b7ca273b5a 100755 --- a/lib/app_ipc.h +++ b/lib/app_ipc.h @@ -8,6 +8,7 @@ // - main init file // - fd init file // - graphics init file +// - conversion of symbolic links // Shared memory is arranged as follows: // 4 1K segments @@ -91,5 +92,6 @@ int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi); #define STDERR_FILE "stderr.txt" extern char* xml_graphics_modes[5]; +extern int boinc_link(char* existing, char* new_link); #endif diff --git a/lib/filesys.C b/lib/filesys.C index 6b52c0343c..f86ff4b90d 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -39,6 +39,15 @@ #include #endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif +#ifdef HAVE_SYS_STATVFS_H +#define STATFS statvfs +#else +#define STATFS statfs +#endif + #ifdef _WIN32 #include #include @@ -177,21 +186,7 @@ int file_size(char* path, double& size) { return 0; } -// create a file (new_link) which contains an XML -// reference to existing file. -// -int boinc_link(char *existing, char *new_link) { - FILE *fp; - - fp = fopen(new_link, "w"); - if (!fp) return ERR_FOPEN; - fprintf(fp, "%s\n", existing); - fclose(fp); - - return 0; -} - -// Goes through directory specified by dirpath and removes all files from it +// removes all files from specified directory // int clean_out_dir(char* dirpath) { char filename[256], path[256]; @@ -217,8 +212,7 @@ int clean_out_dir(char* dirpath) { return 0; } -// Goes recursively through directory specified by dirpath and returns the -// total size of files in it and its subdirectories +// return total size of files in directory and its subdirectories // int dir_size(char* dirpath, double& size) { char filename[256], subdir[256]; @@ -282,3 +276,42 @@ void full_path(char* relname, char* path) { strcat(path, relname); } #endif + + +// get total and free space on current filesystem (in bytes) +// +int get_filesystem_info(double &total_space, double &free_space) { +#ifdef _WIN32 + FreeFn pGetDiskFreeSpaceEx; + pGetDiskFreeSpaceEx = (FreeFn)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetDiskFreeSpaceExA"); + if(pGetDiskFreeSpaceEx) { + ULARGE_INTEGER TotalNumberOfFreeBytes; + ULARGE_INTEGER TotalNumberOfBytes; + pGetDiskFreeSpaceEx(NULL, NULL, &TotalNumberOfBytes, &TotalNumberOfFreeBytes); + unsigned int uMB; + uMB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024); + free_space = uMB * 1024.0 * 1024.0; + uMB = TotalNumberOfBytes.QuadPart / (1024 * 1024); + total_space = uMB * 1024.0 * 1024.0; + } else { + DWORD dwSectPerClust; + DWORD dwBytesPerSect; + DWORD dwFreeClusters; + DWORD dwTotalClusters; + GetDiskFreeSpace(NULL, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters); + free_space = (double)dwFreeClusters * dwSectPerClust * dwBytesPerSect; + total_space = (double)dwTotalClusters * dwSectPerClust * dwBytesPerSect; + } +#else +#ifdef STATFS + struct STATFS fs_info; + + STATFS(".", &fs_info); + total_space = (double)fs_info.f_bsize * (double)fs_info.f_blocks; + free_space = (double)fs_info.f_bsize * (double)fs_info.f_bavail; +#else +#error Need to specify a method to obtain free/total disk space +#endif +#endif + return 0; +} diff --git a/lib/filesys.h b/lib/filesys.h index eb63e01d7f..96f033c5c2 100755 --- a/lib/filesys.h +++ b/lib/filesys.h @@ -38,7 +38,6 @@ extern int dir_scan(char*, DIRREF, int); extern void dir_close(DIRREF); extern int file_delete(char*); extern int file_size(char*, double&); -extern int boinc_link(char *existing, char *new_link); extern int clean_out_dir(char*); extern int dir_size(char* dirpath, double&); extern int boinc_rename(char* old, char* newf); @@ -47,3 +46,4 @@ extern int boinc_rmdir(char*); #ifdef _WIN32 extern void full_path(char* relname, char* path); #endif +extern int get_filesystem_info(double& total, double& free); diff --git a/sched/Makefile.am b/sched/Makefile.am index 40500cb96c..e71a16161a 100644 --- a/sched/Makefile.am +++ b/sched/Makefile.am @@ -9,6 +9,7 @@ noinst_PROGRAMS = \ assimilator db_dump update_stats start_servers EXTRA_PROGRAMS = fcgi +EXTRA_DIST = watch_tcp wd.php wd_nresults_changing.php cgi_SOURCES = \ handle_request.C \