00001 // This file is part of BOINC. 00002 // http://boinc.berkeley.edu 00003 // Copyright (C) 2008 University of California 00004 // 00005 // BOINC is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation, 00008 // either version 3 of the License, or (at your option) any later version. 00009 // 00010 // BOINC is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 // See the GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #ifndef _HOSTINFO_ 00019 #define _HOSTINFO_ 00020 00021 // Description of a host's hardware and software. 00022 // This is used a few places: 00023 // - it's part of the client's state file, client_state.xml 00024 // - it's passed in the reply to the get_host_info GUI RPC 00025 // - it's included in scheduler RPC requests 00026 // 00027 // Other host-specific info is kept in 00028 // TIME_STATS (on/connected/active fractions) 00029 // NET_STATS (average network bandwidths) 00030 00031 #include "miofile.h" 00032 00033 class HOST_INFO { 00034 public: 00035 int timezone; // local STANDARD time - UTC time (in seconds) 00036 char domain_name[256]; 00037 char serialnum[256]; 00038 char ip_addr[256]; 00039 char host_cpid[64]; 00040 00041 int p_ncpus; 00042 char p_vendor[256]; 00043 char p_model[256]; 00044 char p_features[1024]; 00045 double p_fpops; 00046 double p_iops; 00047 double p_membw; 00048 double p_calculated; // when benchmarks were last run, or zero 00049 00050 double m_nbytes; // Total amount of memory in bytes 00051 double m_cache; 00052 double m_swap; // Total amount of swap space in bytes 00053 00054 double d_total; // Total amount of disk in bytes 00055 double d_free; // Total amount of free disk in bytes 00056 00057 char os_name[256]; 00058 char os_version[256]; 00059 00060 HOST_INFO(); 00061 int parse(MIOFILE&); 00062 int write(MIOFILE&, bool suppress_net_info); 00063 int parse_cpu_benchmarks(FILE*); 00064 int write_cpu_benchmarks(FILE*); 00065 void print(); 00066 00067 bool host_is_running_on_batteries(); 00068 #ifdef __APPLE__ 00069 bool users_idle(bool check_all_logins, double idle_time_to_run, double *actual_idle_time=NULL); 00070 #else 00071 bool users_idle(bool check_all_logins, double idle_time_to_run); 00072 #endif 00073 int get_host_info(); 00074 int get_local_network_info(); 00075 void clear_host_info(); 00076 void make_random_string(const char* salt, char* out); 00077 void generate_host_cpid(); 00078 }; 00079 00080 #ifdef __APPLE__ 00081 #ifdef __cplusplus 00082 extern "C" { 00083 #endif 00084 #include <mach/port.h> 00085 typedef mach_port_t NXEventHandle; 00086 NXEventHandle NXOpenEventStatus(void); 00087 extern double NXIdleTime(NXEventHandle handle); 00088 #ifdef __cplusplus 00089 } // extern "C" 00090 #endif 00091 00092 extern NXEventHandle gEventHandle; 00093 #endif 00094 00095 #endif
1.5.6