svn path=/trunk/boinc/; revision=1451
This commit is contained in:
David Anderson 2003-06-14 20:24:29 +00:00
parent 506b405cb4
commit 3726ecf6eb
11 changed files with 128 additions and 67 deletions

View File

@ -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 <soft_link> XML tag, return its value,
// otherwise, return the original file name
//
parse_str(buf, "<soft_link>", physical_name, len);
return 0;
}
bool boinc_time_to_checkpoint() {
#ifdef __APPLE_CC__
YieldToAnyThread();

View File

@ -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);

View File

@ -32,9 +32,6 @@
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#ifdef HAVE_SYS_STATVFS_H
#include <sys/statvfs.h>
#endif
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
@ -42,12 +39,6 @@
#include <sys/vmmeter.h>
#endif
#ifdef HAVE_SYS_STATVFS_H
#define STATFS statvfs
#else
#define STATFS statfs
#endif
#ifdef _WIN32
#include <afxwin.h>
#include <winsock.h>
@ -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);

View File

@ -84,6 +84,7 @@ Monitoring the performance of a BOINC project
Tools for monitoring the system as a whole.
</font>
<ul>
<li> <a href=watchdog.html>Watchdogs</a>
<li> <a href=stripchart.html>Stripcharts: a tool for viewing time-varying data </a>
<li> <a href=stripchart_data.html>Recording data for Stripcharts</a>
</ul>

View File

@ -146,6 +146,8 @@ g%27%3E&lt;/name_html>
&lt;name>Eric Heien&lt;/name>
&lt;total_credit>4897.904591&lt;/total_credit>
&lt;expavg_credit>9820.631754&lt;/expavg_credit>
&lt;country>United States&lt;/country>
&lt;create_time>1046220857&lt;/ncreate_time>
&lt;teamid>14&lt;/teamid>
&lt;host>
&lt;id>27&lt;/id>

30
doc/watchdog.html Normal file
View File

@ -0,0 +1,30 @@
<h2>Watchdogs</h2>
<p>
A <b>watchdog</b> 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.
<p>
BOINC provides a framework for defining watchdogs:
<ul>
<li>
A set of <b>watchdog scripts</b> 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 <b>wd_nresults_changing.php</b>,
which makes sure that the number of results changes.
<li>
The script <b>wd.php</b>, 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.
</ul>
These files are in the sched/ directory.

View File

@ -1,6 +1,7 @@
#include <string.h>
#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, "<soft_link>%s</soft_link>\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 <soft_link> XML tag, return its value,
// otherwise, return the original file name
//
parse_str(buf, "<soft_link>", physical_name, len);
return 0;
}

View File

@ -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

View File

@ -39,6 +39,15 @@
#include <sys/resource.h>
#endif
#ifdef HAVE_SYS_STATVFS_H
#include <sys/statvfs.h>
#endif
#ifdef HAVE_SYS_STATVFS_H
#define STATFS statvfs
#else
#define STATFS statfs
#endif
#ifdef _WIN32
#include <io.h>
#include <winsock.h>
@ -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, "<soft_link>%s</soft_link>\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;
}

View File

@ -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);

View File

@ -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 \