2004-02-02 23:34:39 +00:00
< ? php
2008-08-05 22:43:14 +00:00
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2004-02-02 23:34:39 +00:00
2004-11-01 23:10:02 +00:00
require_once ( " ../inc/credit.inc " );
2009-02-05 21:19:19 +00:00
require_once ( " ../inc/stats_sites.inc " );
2007-10-27 20:38:12 +00:00
require_once ( " ../inc/boinc_db.inc " );
2014-08-11 21:57:34 +00:00
require_once ( " ../inc/user.inc " );
2004-11-01 23:10:02 +00:00
2006-01-16 17:34:54 +00:00
function link_to_results ( $host ) {
2010-02-16 01:06:03 +00:00
if ( ! $host ) return tra ( " No host " );
2006-01-16 17:34:54 +00:00
$config = get_config ();
2010-02-16 01:06:03 +00:00
if ( ! parse_bool ( $config , " show_results " )) return tra ( " Unavailable " );
2006-01-16 17:34:54 +00:00
$nresults = host_nresults ( $host );
if ( ! $nresults ) return " 0 " ;
return " <a href=results.php?hostid= $host->id > $nresults </a> " ;
}
2005-12-15 17:16:48 +00:00
function sched_log_name ( $x ) {
if ( $x == 0 ) return " NO_SUCH_LOG " ;
return gmdate ( 'Y-m-d_H/Y-m-d_H:i' , $x ) . " .txt " ;
}
function sched_log_link ( $x ) {
2008-08-18 11:51:15 +00:00
if ( file_exists ( " sched_logs " )) {
2007-11-24 04:51:03 +00:00
return " <a href= \" ../sched_logs/ " . sched_log_name ( $x ) . " \" > " . time_str ( $x ) . " </a> " ;
} else {
return time_str ( $x );
}
2005-12-15 17:16:48 +00:00
}
2004-02-02 23:34:39 +00:00
function location_form ( $host ) {
2004-10-01 07:49:01 +00:00
$none = " selected " ;
2013-07-26 18:23:27 +00:00
$h = $w = $s = $m = " " ;
2004-02-02 23:34:39 +00:00
if ( $host -> venue == " home " ) $h = " selected " ;
if ( $host -> venue == " work " ) $w = " selected " ;
if ( $host -> venue == " school " ) $s = " selected " ;
$x = " <form action=host_venue_action.php>
< input type = hidden name = hostid value = $host -> id >
2016-11-23 10:35:28 +00:00
< select class = \ " form-control \" name=venue>
2004-10-01 07:49:01 +00:00
< option value = \ " \" $none >---
2010-02-16 01:06:03 +00:00
< option value = home $h > " .tra( " Home " ). "
< option value = work $w > " .tra( " Work " ). "
< option value = school $s > " .tra( " School " ). "
2004-02-02 23:34:39 +00:00
</ select >
2016-12-19 09:15:48 +00:00
< p ></ p >
< input class = \ " btn btn-primary btn-sm \" type=submit value= \" " . tra ( " Update location " ) . " \" >
2004-02-02 23:34:39 +00:00
</ form >
" ;
return $x ;
}
2009-03-03 21:58:03 +00:00
function cross_project_links ( $host ) {
2009-02-05 21:19:19 +00:00
global $host_sites ;
$x = " " ;
foreach ( $host_sites as $h ) {
$url = $h [ 0 ];
$name = $h [ 1 ];
2009-03-03 21:58:03 +00:00
$img = $h [ 2 ];
2016-12-05 05:04:23 +00:00
$x .= " <a href= $url " . $host -> host_cpid . " ><img class= \" icon \" border=2 src=img/ $img alt= \" $name\ " ></ a > " ;
2009-02-05 21:19:19 +00:00
}
return $x ;
}
2008-03-11 20:27:19 +00:00
// Show full-page description of $host.
// If $user is non-null, it's both the owner of the host
// and the logged in user (so show some extra fields)
//
function show_host ( $host , $user , $ipprivate ) {
2004-02-02 23:34:39 +00:00
start_table ();
2010-02-16 01:06:03 +00:00
row1 ( tra ( " Computer information " ));
2009-02-07 04:04:54 +00:00
$anonymous = false ;
2008-03-11 20:27:19 +00:00
if ( $user ) {
2004-02-02 23:34:39 +00:00
if ( $ipprivate ) {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " IP address " ), " $host->last_ip_addr <br> " . tra ( " (same the last %1 times) " , $host -> nsame_ip_addr ));
2008-04-26 23:34:38 +00:00
if ( $host -> last_ip_addr != $host -> external_ip_addr ) {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " External IP address " ), $host -> external_ip_addr );
2008-03-11 20:27:19 +00:00
}
2004-02-02 23:34:39 +00:00
} else {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " IP address " ), " <a href=show_host_detail.php?hostid= $host->id &ipprivate=1> " . tra ( " Show IP address " ) . " </a> " );
2004-02-02 23:34:39 +00:00
}
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Domain name " ), $host -> domain_name );
2013-08-02 20:35:17 +00:00
if ( $host -> product_name ) {
row2 ( tra ( " Product name " ), $host -> product_name );
}
2004-05-28 05:53:24 +00:00
$x = $host -> timezone / 3600 ;
2005-05-05 05:15:26 +00:00
if ( $x >= 0 ) $x = " + $x " ;
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Local Standard Time " ), tra ( " UTC %1 hours " , $x ));
2008-03-11 20:27:19 +00:00
} else {
2014-04-24 16:41:59 +00:00
$owner = BoincUser :: lookup_id ( $host -> userid );
2008-03-11 20:27:19 +00:00
if ( $owner && $owner -> show_hosts ) {
2014-09-18 17:08:45 +00:00
row2 ( tra ( " Owner " ), user_links ( $owner , BADGE_HEIGHT_MEDIUM ));
2004-02-02 23:34:39 +00:00
} else {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Owner " ), tra ( " Anonymous " ));
2009-02-07 04:04:54 +00:00
$anonymous = true ;
2004-02-02 23:34:39 +00:00
}
}
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Created " ), time_str ( $host -> create_time ));
2017-08-20 07:21:33 +00:00
if ( ! NO_STATS ) {
row2 ( tra ( " Total credit " ), format_credit_large ( $host -> total_credit ));
row2 ( tra ( " Average credit " ), format_credit ( $host -> expavg_credit ));
if ( ! $anonymous ) {
row2 ( tra ( " Cross project credit " ), cross_project_links ( $host ));
}
2009-02-07 04:04:54 +00:00
}
2010-02-16 01:06:03 +00:00
row2 ( tra ( " CPU type " ), " $host->p_vendor <br> $host->p_model " );
row2 ( tra ( " Number of processors " ), $host -> p_ncpus );
2008-12-16 18:46:28 +00:00
if ( $host -> serialnum ) {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Coprocessors " ), gpu_desc ( $host -> serialnum ));
2008-12-16 18:46:28 +00:00
}
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Operating System " ), " $host->os_name <br> $host->os_version " );
2009-09-10 20:30:46 +00:00
$v = boinc_version ( $host -> serialnum );
if ( $v ) {
2010-08-03 03:56:13 +00:00
row2 ( tra ( " BOINC version " ), $v );
2009-09-10 20:30:46 +00:00
}
2017-05-10 08:35:49 +00:00
$x = $host -> m_nbytes / GIGA ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
2017-05-10 08:35:49 +00:00
row2 ( tra ( " Memory " ), tra ( " %1 GB " , $y ));
2013-06-26 23:16:21 +00:00
if ( $host -> m_cache > 0 ) {
2014-04-03 02:35:59 +00:00
$x = $host -> m_cache / KILO ;
2013-06-26 23:16:21 +00:00
$y = round ( $x , 2 );
row2 ( tra ( " Cache " ), tra ( " %1 KB " , $y ));
}
2004-02-02 23:34:39 +00:00
2008-03-11 20:27:19 +00:00
if ( $user ) {
2017-05-10 08:35:49 +00:00
$x = $host -> m_swap / GIGA ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
2017-05-10 08:35:49 +00:00
row2 ( tra ( " Swap space " ), tra ( " %1 GB " , $y ));
2014-04-03 02:35:59 +00:00
$x = $host -> d_total / GIGA ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Total disk space " ), tra ( " %1 GB " , $y ));
2014-04-03 02:35:59 +00:00
$x = $host -> d_free / GIGA ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Free Disk Space " ), tra ( " %1 GB " , $y ));
2004-02-02 23:34:39 +00:00
}
2017-05-10 08:35:49 +00:00
$x = $host -> p_fpops / 1e9 ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
2017-05-10 08:35:49 +00:00
row2 ( tra ( " Measured floating point speed " ), tra ( " %1 billion ops/sec " , $y ));
$x = $host -> p_iops / 1e9 ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
2017-05-10 08:35:49 +00:00
row2 ( tra ( " Measured integer speed " ), tra ( " %1 billion ops/sec " , $y ));
2014-04-03 02:35:59 +00:00
$x = $host -> n_bwup / KILO ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
if ( $y > 0 ) {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Average upload rate " ), tra ( " %1 KB/sec " , $y ));
2004-02-02 23:34:39 +00:00
} else {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Average upload rate " ), tra ( " Unknown " ));
2004-02-02 23:34:39 +00:00
}
2014-04-03 02:35:59 +00:00
$x = $host -> n_bwdown / KILO ;
2004-02-02 23:34:39 +00:00
$y = round ( $x , 2 );
if ( $y > 0 ) {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Average download rate " ), tra ( " %1 KB/sec " , $y ));
2004-02-02 23:34:39 +00:00
} else {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Average download rate " ), tra ( " Unknown " ));
2004-02-02 23:34:39 +00:00
}
2004-12-06 22:41:19 +00:00
$x = $host -> avg_turnaround / 86400 ;
2017-08-20 07:21:33 +00:00
if ( ! NO_COMPUTING ) {
row2 ( tra ( " Average turnaround time " ), tra ( " %1 days " , round ( $x , 2 )));
row2 ( tra ( " Application details " ),
" <a href=host_app_versions.php?hostid= $host->id > " . tra ( " Show " ) . " </a> "
);
$config = get_config ();
if ( parse_bool ( $config , " show_results " )) {
$nresults = host_nresults ( $host );
if ( $nresults ) {
$results = " <a href=results.php?hostid= $host->id > $nresults </a> " ;
} else {
$results = " 0 " ;
}
row2 ( tra ( " Tasks " ), $results );
2004-08-25 19:04:47 +00:00
}
2004-02-02 23:34:39 +00:00
}
2008-03-11 20:27:19 +00:00
if ( $user ) {
2011-08-28 00:31:40 +00:00
row2 ( tra ( " Number of times client has contacted server " ), $host -> rpc_seqno );
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Last time contacted server " ), sched_log_link ( $host -> rpc_time ));
2015-03-03 18:52:42 +00:00
row2 ( tra ( " Fraction of time BOINC is running " ), number_format ( 100 * $host -> on_frac , 2 ) . " % " );
2007-10-28 15:03:14 +00:00
if ( $host -> connected_frac > 0 ) {
2015-03-03 18:52:42 +00:00
row2 ( tra ( " While BOINC is running, fraction of time computer has an Internet connection " ), number_format ( 100 * $host -> connected_frac , 2 ) . " % " );
2005-10-19 21:04:45 +00:00
}
2015-03-03 18:52:42 +00:00
row2 ( tra ( " While BOINC is running, fraction of time computing is allowed " ), number_format ( 100 * $host -> active_frac , 2 ) . " % " );
row2 ( tra ( " While is BOINC running, fraction of time GPU computing is allowed " ), number_format ( 100 * $host -> gpu_active_frac , 2 ) . " % " );
2005-06-23 07:42:45 +00:00
if ( $host -> cpu_efficiency ) {
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Average CPU efficiency " ), $host -> cpu_efficiency );
2005-06-23 07:42:45 +00:00
}
2017-08-20 07:21:33 +00:00
if ( ! NO_COMPUTING ) {
if ( $host -> duration_correction_factor ) {
row2 ( tra ( " Task duration correction factor " ), $host -> duration_correction_factor );
}
2005-06-23 07:42:45 +00:00
}
2010-02-16 01:06:03 +00:00
row2 ( tra ( " Location " ), location_form ( $host ));
2004-02-02 23:34:39 +00:00
if ( $nresults == 0 ) {
2012-12-19 00:38:40 +00:00
$x = " · <a href=host_delete.php?hostid= $host->id " . url_tokens ( $user -> authenticator ) . " > " . tra ( " Delete this computer " ) . " </a> " ;
2004-02-02 23:34:39 +00:00
} else {
$x = " " ;
}
2016-12-19 09:15:48 +00:00
row2 ( tra ( " Merge duplicate records of this computer " ), " <a class= \" btn btn-primary btn-sm \" href=host_edit_form.php?hostid= $host->id > " . tra ( " Merge " ) . " </a> $x " );
2011-08-28 00:31:40 +00:00
} else {
row2 ( tra ( " Number of times client has contacted server " ), $host -> rpc_seqno );
row2 ( tra ( " Last contact " ), date_str ( $host -> rpc_time ));
2016-10-28 09:59:08 +00:00
}
2004-02-02 23:34:39 +00:00
echo " </table> \n " ;
}
2004-05-31 00:50:06 +00:00
// the following is used for list of top hosts
//
function top_host_table_start ( $sort_by ) {
2009-03-03 21:58:03 +00:00
global $host_sites ;
shuffle ( $host_sites );
2016-11-11 20:36:27 +00:00
start_table ( 'table-striped' );
2016-12-03 07:25:01 +00:00
$x = array (
tra ( " Computer info " ),
tra ( " Rank " ),
tra ( " Owner " ),
);
2017-08-20 07:21:33 +00:00
if ( ! NO_STATS ) {
if ( $sort_by == 'total_credit' ) {
$x [] = " <a href=top_hosts.php?sort_by=expavg_credit> " . tra ( " Avg. credit " ) . " </a> " ;
$x [] = tra ( " Total credit " );
} else {
$x [] = tra ( " Recent average credit " );
$x [] = " <a href=top_hosts.php?sort_by=total_credit> " . tra ( " Total credit " ) . " </a> " ;
}
2016-12-03 07:25:01 +00:00
}
$x [] = tra ( " BOINC version " );
$x [] = tra ( " CPU " );
$x [] = tra ( " GPU " );
$x [] = tra ( " Operating system " );
2016-12-05 05:04:23 +00:00
$s = 'style="text-align:right;"' ;
$a = array ( " " , " " , " " , $s , $s , " " , " " , " " , " " );
2017-05-10 08:35:49 +00:00
row_heading_array ( $x , $a , " bg-default " );
2004-05-31 00:50:06 +00:00
}
2004-02-02 23:34:39 +00:00
function host_nresults ( $host ) {
2007-10-27 20:38:12 +00:00
return BoincResult :: count ( " hostid= $host->id " );
2004-02-02 23:34:39 +00:00
}
2011-12-24 02:01:54 +00:00
// Given string of the form [BOINC|vers][type|model|count|RAM|driver-vers][vbox|vers],
2009-09-10 20:30:46 +00:00
// return a human-readable version of the GPU info
2009-01-29 17:51:02 +00:00
//
2017-07-22 07:13:08 +00:00
function gpu_desc ( $x , $detail = true ) {
2009-09-29 19:46:14 +00:00
$descs = explode ( " ] " , $x );
array_pop ( $descs );
$str = " " ;
foreach ( $descs as $desc ) {
$desc = trim ( $desc , " [ " );
$d = explode ( " | " , $desc );
//print_r($d);
2016-10-28 09:59:08 +00:00
if ( $d [ 0 ] == " BOINC " ) continue ;
if ( $d [ 0 ] == " vbox " ) continue ;
if ( $str ) $str .= " <p> " ;
2009-09-29 19:46:14 +00:00
if ( $d [ 2 ] != " " && $d [ 2 ] != " 1 " ) $str .= " [ " . $d [ 2 ] . " ] " ;
if ( $d [ 0 ] == " CUDA " ) {
$str .= " NVIDIA " ;
2011-11-03 02:35:04 +00:00
} else if ( $d [ 0 ] == " CAL " ) {
$str .= " AMD " ;
2016-10-25 18:08:16 +00:00
} else if ( $d [ 0 ] == " opencl_gpu " ) {
$str .= " OpenCL GPU " ;
2009-09-29 19:46:14 +00:00
} else {
$str .= $d [ 0 ];
2009-02-24 00:06:45 +00:00
}
2009-09-29 19:46:14 +00:00
$str .= " " . $d [ 1 ];
2017-07-22 07:13:08 +00:00
if ( $detail ) {
$str .= " ( " . $d [ 3 ] . " ) " ;
if ( array_key_exists ( 4 , $d )) {
if ( $d [ 4 ] != " " && $d [ 4 ] != 0 ) {
// if version has no '.', assume it's in 100*maj+min form
//
if ( strchr ( $d [ 4 ], '.' )) {
$str .= " driver: " . $d [ 4 ];
} else {
$i = ( int ) $d [ 4 ];
$maj = ( int )( $i / 100 );
$min = $i % 100 ;
$str .= sprintf ( " driver: %d.%02d " , $maj , $min );
}
2011-11-03 02:35:04 +00:00
}
2009-09-29 19:46:14 +00:00
}
2017-07-22 07:13:08 +00:00
if ( array_key_exists ( 5 , $d )) {
if ( $d [ 5 ] != " " && $d [ 5 ] != 0 ) {
if ( strchr ( $d [ 5 ], '.' )) {
$str .= " OpenCL: " . $d [ 5 ];
} else {
$i = ( int ) $d [ 5 ];
$maj = ( int )( $i / 100 );
$min = $i % 100 ;
$str .= sprintf ( " OpenCL: %d.%d " , $maj , $min );
}
2013-02-20 06:24:51 +00:00
}
}
}
2009-02-24 00:06:45 +00:00
}
2009-09-29 19:46:14 +00:00
if ( ! $str ) $str = " --- " ;
return $str ;
2009-01-29 17:51:02 +00:00
}
2009-09-10 20:30:46 +00:00
// Given the same string as above, return the BOINC version
//
function boinc_version ( $x ) {
$y = strstr ( $x , 'BOINC' );
if ( ! $y ) return '' ;
$z = explode ( " ] " , $y , 2 );
2014-07-17 04:08:18 +00:00
$a = explode ( '|' , $z [ 0 ]);
$v = $a [ 1 ];
if ( array_key_exists ( 2 , $a )) {
$brand = $a [ 2 ];
$v .= " ( $brand ) " ;
}
return $v ;
2009-09-10 20:30:46 +00:00
}
2009-01-29 17:51:02 +00:00
function cpu_desc ( $host ) {
2010-02-16 01:06:03 +00:00
return " $host->p_vendor <br> $host->p_model <br> " . tra ( " (%1 processors) " , $host -> p_ncpus ) . " \n " ;
2009-01-29 17:51:02 +00:00
}
2004-02-02 23:34:39 +00:00
// If private is true, we're showing the host to its owner,
// so it's OK to show the domain name etc.
// If private is false, show the owner's name only if they've given permission
//
2013-08-02 20:35:17 +00:00
function show_host_row ( $host , $i , $private , $show_owner , $any_product_name ) {
2009-02-07 04:04:54 +00:00
$anonymous = false ;
if ( ! $private ) {
if ( $show_owner ) {
$user = BoincUser :: lookup_id ( $host -> userid );
if ( $user && $user -> show_hosts ) {
} else {
$anonymous = true ;
}
}
}
2016-12-07 19:32:25 +00:00
echo " <tr><td>ID: $host->id
2017-08-20 07:21:33 +00:00
< br >< a href = show_host_detail . php ? hostid = $host -> id > " .tra( " Details " ). " </ a >
2009-02-07 04:04:54 +00:00
" ;
2017-08-20 07:21:33 +00:00
if ( ! NO_COMPUTING ) {
2009-02-07 04:04:54 +00:00
echo "
2017-08-20 07:21:33 +00:00
| < a href = results . php ? hostid = $host -> id > " .tra( " Tasks " ). " </ a >
" ;
}
if ( ! NO_STATS ) {
if ( ! $anonymous ) {
echo "
< br >< nobr >< small > " .tra( " Cross - project stats : " ). " </ small ></ nobr >< br > " .cross_project_links( $host );
}
2009-02-07 04:04:54 +00:00
}
echo "
2008-04-25 23:56:39 +00:00
</ td >
" ;
2004-02-02 23:34:39 +00:00
if ( $private ) {
2008-03-11 20:27:19 +00:00
echo " <td> $host->domain_name </td> \n " ;
2013-08-02 20:35:17 +00:00
if ( $any_product_name ) {
echo " <td> $host->product_name </td> \n " ;
}
2008-03-11 20:27:19 +00:00
echo " <td> $host->venue </td> \n " ;
2004-02-02 23:34:39 +00:00
} else {
2008-03-11 20:27:19 +00:00
echo " <td> $i </td> \n " ;
2004-02-02 23:34:39 +00:00
if ( $show_owner ) {
2009-02-07 04:04:54 +00:00
if ( $anonymous ) {
2010-02-16 01:06:03 +00:00
echo " <td> " . tra ( " Anonymous " ) . " </td> \n " ;
2009-02-07 04:04:54 +00:00
} else {
2014-09-18 17:08:45 +00:00
echo " <td> " , user_links ( $user , BADGE_HEIGHT_MEDIUM ), " </td> \n " ;
2004-02-02 23:34:39 +00:00
}
}
}
2006-01-16 17:34:54 +00:00
if ( $show_owner ) {
2007-10-07 19:27:59 +00:00
// This is used in the "top computers" display
2006-01-16 17:34:54 +00:00
//
2017-08-20 07:21:33 +00:00
if ( ! NO_STATS ) {
printf ( "
< td align = right >% s </ td >
< td align = right >% s </ td > " ,
format_credit ( $host -> expavg_credit ),
format_credit_large ( $host -> total_credit )
);
}
2006-01-16 17:34:54 +00:00
printf ( "
2009-01-29 17:51:02 +00:00
< td >% s </ td >
< td >% s </ td >
2009-09-10 20:30:46 +00:00
< td >% s </ td >
2006-01-16 17:34:54 +00:00
< td >% s < br > % s </ td > " ,
2009-09-10 20:30:46 +00:00
boinc_version ( $host -> serialnum ),
cpu_desc ( $host ),
gpu_desc ( $host -> serialnum ),
$host -> os_name , $host -> os_version
2006-01-16 17:34:54 +00:00
);
} else {
2009-09-10 20:30:46 +00:00
// This is used to show the computers of a given user
2006-01-16 17:34:54 +00:00
//
2017-08-20 07:21:33 +00:00
if ( ! NO_STATS ) {
printf ( "
< td align = right >% s </ td >
< td align = right >% s </ td > " ,
format_credit ( $host -> expavg_credit ),
format_credit_large ( $host -> total_credit )
);
}
2009-09-10 20:30:46 +00:00
printf ( "
< td >% s </ td >
< td >% s </ td >
< td >% s </ td >
2016-12-05 05:04:23 +00:00
< td >% s < br >< small >% s </ small ></ td >
2009-09-10 20:30:46 +00:00
< td >% s </ td >
" ,
boinc_version ( $host -> serialnum ),
cpu_desc ( $host ),
gpu_desc ( $host -> serialnum ),
$host -> os_name , $host -> os_version ,
sched_log_link ( $host -> rpc_time )
);
2006-01-16 17:34:54 +00:00
}
2005-07-21 06:57:40 +00:00
2004-02-02 23:34:39 +00:00
echo " </tr> \n " ;
}
2011-12-16 19:40:22 +00:00
// Logic for deciding whether two host records might actually
// be the same machine, based on CPU info
2004-02-02 23:34:39 +00:00
//
2011-12-16 19:40:22 +00:00
// p_vendor is typically either AuthenticAMD or GenuineIntel.
// Over time we've changed the contents of p_model.
// Some examples:
// Intel(R) Core(TM)2 Duo CPU E7300 @ 2.66GHz [Family 6 Model 23 Stepping 6]
// AMD Athlon(tm) II X2 250 Processor [Family 16 Model 6 Stepping 3]
// Intel(R) Xeon(R) CPU X5650 @ 2.67GHz [x86 Family 6 Model 44 Stepping 2]
// Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz [Intel64 Family 6 Model 42 Stepping 7]
//
// in the last 2 cases, let's call x86 and Intel64 the "architecture"
//
// so, here's the policy:
//
// if p_ncpus different, return false
// if p_vendor different, return false
// if both have family/model/stepping info
// if info disagrees, return false
// if both have GHz info, and they disagree, return false
// if both have architecture, and they disagree, return false
// return true
// if p_model different, return false
// return true
//
// parse p_model to produce the following structure:
// x->speed "3.00GHz" etc. or null
// x->arch "x86" etc. or null
// x->info "Family 6 Model 23 Stepping 6" etc. or null
//
function parse_model ( $model ) {
$y = explode ( " " , $model );
2013-05-04 05:12:26 +00:00
$x = new StdClass ;
2011-12-16 19:40:22 +00:00
$x -> speed = null ;
$x -> arch = null ;
$x -> info = null ;
2005-04-08 21:40:32 +00:00
foreach ( $y as $z ) {
2011-12-16 19:40:22 +00:00
if ( strstr ( $z , " GHz " )) $x -> speed = $z ;
if ( strstr ( $z , " MHz " )) $x -> speed = $z ;
}
$pos1 = strpos ( $model , '[' );
if ( $pos1 === false ) return $x ;
$pos2 = strpos ( $model , ']' );
if ( $pos2 === false ) return $x ;
$a = substr ( $model , $pos1 + 1 , $pos2 - $pos1 - 1 );
$y = explode ( " " , $a );
if ( count ( $y ) == 0 ) return $x ;
if ( $y [ 0 ] == " Family " ) {
$x -> info = $a ;
} else {
$x -> arch = $y [ 0 ];
$x -> info = substr ( $a , strlen ( $y [ 0 ]) + 1 );
2005-04-08 21:40:32 +00:00
}
2011-12-16 19:40:22 +00:00
return $x ;
2005-04-08 21:40:32 +00:00
}
2007-05-30 20:30:28 +00:00
function cpus_compatible ( $host1 , $host2 ) {
2011-12-16 19:40:22 +00:00
if ( $host1 -> p_ncpus != $host2 -> p_ncpus ) return false ;
if ( $host1 -> p_vendor != $host2 -> p_vendor ) return false ;
$x1 = parse_model ( $host1 -> p_model );
$x2 = parse_model ( $host2 -> p_model );
if ( $x1 -> info && $x2 -> info ) {
if ( $x1 -> info != $x2 -> info ) return false ;
if ( $x1 -> speed && $x2 -> speed ) {
if ( $x1 -> speed != $x2 -> speed ) return false ;
2007-02-19 18:37:00 +00:00
}
2011-12-16 19:40:22 +00:00
if ( $x1 -> arch && $x2 -> arch ) {
if ( $x1 -> arch != $x2 -> arch ) return false ;
2009-05-23 00:06:32 +00:00
}
2011-12-16 19:40:22 +00:00
return true ;
2005-04-08 21:40:32 +00:00
}
2011-12-16 19:40:22 +00:00
if ( $host1 -> p_model != $host2 -> p_model ) return false ;
2007-05-30 20:30:28 +00:00
return true ;
}
2005-10-23 07:11:23 +00:00
2007-05-30 20:30:28 +00:00
// does one host strictly precede the other?
//
function times_disjoint ( $host1 , $host2 ) {
2007-02-19 18:37:00 +00:00
if ( $host1 -> rpc_time < $host2 -> create_time ) return true ;
if ( $host2 -> rpc_time < $host1 -> create_time ) return true ;
2005-10-23 07:11:23 +00:00
return false ;
2004-02-02 23:34:39 +00:00
}
2007-06-27 18:14:25 +00:00
function os_compatible ( $host1 , $host2 ) {
if ( strstr ( $host1 -> os_name , " Windows " ) && strstr ( $host2 -> os_name , " Windows " )) return true ;
if ( strstr ( $host1 -> os_name , " Linux " ) && strstr ( $host2 -> os_name , " Linux " )) return true ;
if ( strstr ( $host1 -> os_name , " Darwin " ) && strstr ( $host2 -> os_name , " Darwin " )) return true ;
if ( strstr ( $host1 -> os_name , " SunOS " ) && strstr ( $host2 -> os_name , " SunOS " )) return true ;
2007-09-17 13:34:46 +00:00
if ( $host1 -> os_name == $host2 -> os_name ) return true ;
2007-06-27 18:14:25 +00:00
return false ;
}
2007-05-30 20:30:28 +00:00
// Return true if it's possible that the two host records
// correspond to the same host
// NOTE: the cheat-proofing comes from checking
// that their time intervals are disjoint.
// So the CPU/OS checks don't have to be very strict.
//
2008-10-06 00:18:36 +00:00
function hosts_compatible ( $host1 , $host2 , $show_detail ) {
2008-10-08 21:49:06 +00:00
// A host is "new" if it has no credit and no results.
// Skip disjoint-time check if one host or other is new
2007-06-27 16:12:25 +00:00
//
2008-10-08 21:49:06 +00:00
$new1 = ! $host1 -> total_credit && ! host_nresults ( $host1 );
$new2 = ! $host2 -> total_credit && ! host_nresults ( $host2 );
if ( ! $new1 && ! $new2 ) {
2007-06-27 18:14:25 +00:00
if ( ! times_disjoint ( $host1 , $host2 )) {
2008-10-06 00:18:36 +00:00
if ( $show_detail ) {
2008-01-12 00:15:24 +00:00
$c1 = date_str ( $host1 -> create_time );
$r1 = date_str ( $host1 -> rpc_time );
$c2 = date_str ( $host2 -> create_time );
$r2 = date_str ( $host2 -> rpc_time );
2010-02-16 01:06:03 +00:00
echo " <br> " . tra ( " Host %1 has overlapping lifetime: " , $host2 -> id ) . " ( $c1 - $r1 ), ( $c2 - $r2 ) " ;
2008-01-12 00:15:24 +00:00
}
2007-06-27 18:14:25 +00:00
return false ;
}
}
if ( ! os_compatible ( $host1 , $host2 )) {
2008-10-06 00:18:36 +00:00
if ( $show_detail ) {
2010-02-16 01:06:03 +00:00
echo " <br> " . tra ( " Host %1 has an incompatible OS: " , $host2 -> id ) . " ( $host1->os_name , $host2->os_name ) \n " ;
2008-01-12 00:15:24 +00:00
}
2007-06-27 18:14:25 +00:00
return false ;
}
if ( ! cpus_compatible ( $host1 , $host2 )) {
2008-10-06 00:18:36 +00:00
if ( $show_detail ) {
2010-02-16 01:06:03 +00:00
echo " <br> " . tra ( " Host %1 has an incompatible CPU: " , $host2 -> id ) . " ( $host1->p_vendor $host1->p_model , $host2->p_vendor $host2->p_model ) \n " ;
2008-01-12 00:15:24 +00:00
}
2007-06-27 18:14:25 +00:00
return false ;
2007-06-27 16:12:25 +00:00
}
2007-05-30 20:30:28 +00:00
return true ;
}
2004-11-01 23:10:02 +00:00
// recompute host's average credit by scanning results.
// Could be expensive if lots of results!
//
2004-06-01 18:55:59 +00:00
function host_update_credit ( $hostid ) {
2004-11-01 23:10:02 +00:00
$total = 0 ;
2004-06-01 18:55:59 +00:00
$avg = 0 ;
$avg_time = 0 ;
2007-10-28 15:03:14 +00:00
$results = BoincResult :: enum ( " hostid= $hostid order by received_time " );
foreach ( $results as $result ) {
2004-06-01 18:55:59 +00:00
if ( $result -> granted_credit <= 0 ) continue ;
2004-11-01 23:10:02 +00:00
$total += $result -> granted_credit ;
update_average (
$result -> received_time ,
$result -> sent_time ,
$result -> granted_credit ,
$avg ,
$avg_time
);
2004-06-01 18:55:59 +00:00
2007-10-07 19:37:31 +00:00
//echo "<br>$avg\n";
2004-06-01 18:55:59 +00:00
}
2004-11-01 23:10:02 +00:00
// do a final decay
//
$now = time ();
update_average ( now , 0 , 0 , $avg , $avg_time );
2007-10-28 15:03:14 +00:00
$host = new BoincHost ();
$host -> id = hostid ;
$host -> update ( " total_credit= $total , expavg_credit= $avg , expavg_time= $now " );
2004-11-01 23:10:02 +00:00
}
// decay a host's average credit
//
function host_decay_credit ( $host ) {
$avg = $host -> expavg_credit ;
$avg_time = $host -> expavg_time ;
$now = time ( 0 );
update_average ( $now , 0 , 0 , $avg , $avg_time );
2007-10-28 15:03:14 +00:00
$host -> update ( " expavg_credit= $avg , expavg_time= $now " );
2004-11-01 23:10:02 +00:00
}
2007-10-28 15:03:14 +00:00
2004-11-01 23:10:02 +00:00
// if the host hasn't received new credit for ndays,
// decay its average and return true
//
function host_inactive_ndays ( $host , $ndays ) {
$diff = time () - $host -> expavg_time ;
if ( $diff > $ndays * 86400 ) {
host_decay_credit ( $host );
return true ;
}
return false ;
2004-06-01 18:55:59 +00:00
}
2007-05-30 20:30:28 +00:00
// invariant: old_host.create_time < new_host.create_time
//
function merge_hosts ( $old_host , $new_host ) {
if ( $old_host -> id == $new_host -> id ) {
2010-02-16 01:06:03 +00:00
return tra ( " same host " );
2007-05-30 20:30:28 +00:00
}
2008-10-06 00:18:36 +00:00
if ( ! hosts_compatible ( $old_host , $new_host , false )) {
2010-02-16 01:06:03 +00:00
return tra ( " Can't merge host %1 into %2 - they're incompatible " , $old_host -> id , $new_host -> id );
2007-05-30 20:30:28 +00:00
}
2010-02-16 01:06:03 +00:00
echo " <br> " . tra ( " Merging host %1 into host %2 " , $old_host -> id , $new_host -> id ) . " \n " ;
2007-05-30 20:30:28 +00:00
2007-10-29 04:02:41 +00:00
// decay the average credit of both hosts
//
$now = time ();
update_average ( $now , 0 , 0 , $old_host -> expavg_credit , $old_host -> expavg_time );
update_average ( $now , 0 , 0 , $new_host -> expavg_credit , $new_host -> expavg_time );
2007-05-30 20:30:28 +00:00
// update the database:
// - add credit from old to new host
// - change results to refer to new host
2009-02-05 21:19:19 +00:00
// - put old host in "zombie" state (userid=0, rpc_seqno=new host ID)
2007-05-30 20:30:28 +00:00
//
$total_credit = $old_host -> total_credit + $new_host -> total_credit ;
$recent_credit = $old_host -> expavg_credit + $new_host -> expavg_credit ;
2007-10-28 15:03:14 +00:00
$result = $new_host -> update ( " total_credit= $total_credit , expavg_credit= $recent_credit , expavg_time= $now " );
2007-05-30 20:30:28 +00:00
if ( ! $result ) {
2010-02-16 01:06:03 +00:00
return tra ( " Couldn't update credit of new computer " );
2007-05-30 20:30:28 +00:00
}
2007-10-29 04:02:41 +00:00
$result = BoincResult :: update_aux ( " hostid= $new_host->id where hostid= $old_host->id " );
2007-05-30 20:30:28 +00:00
if ( ! $result ) {
2010-02-16 01:06:03 +00:00
return tra ( " Couldn't update results " );
2007-05-30 20:30:28 +00:00
}
2007-10-28 15:03:14 +00:00
$result = $old_host -> update ( " total_credit=0, expavg_credit=0, userid=0, rpc_seqno= $new_host->id " );
2007-05-30 20:30:28 +00:00
if ( ! $result ) {
2010-02-16 01:06:03 +00:00
return tra ( " Couldn't retire old computer " );
2007-05-30 20:30:28 +00:00
}
2010-02-16 01:06:03 +00:00
echo " <br> " . tra ( " Retired old computer %1 " , $old_host -> id ) . " \n " ;
2007-05-30 20:30:28 +00:00
return 0 ;
}
2010-02-04 16:15:54 +00:00
//////////////// helper functions for hosts_user.php ////////////////
function link_url ( $sort , $rev , $show_all ) {
global $userid ;
$x = $userid ? " &userid= $userid " : " " ;
return " hosts_user.php?sort= $sort &rev= $rev &show_all= $show_all $x " ;
}
function link_url_rev ( $actual_sort , $sort , $rev , $show_all ) {
if ( $actual_sort == $sort ) {
$rev = 1 - $rev ;
}
return link_url ( $sort , $rev , $show_all );
}
function more_or_less ( $sort , $rev , $show_all ) {
echo " <p> " ;
if ( $show_all ) {
$url = link_url ( $sort , $rev , 0 );
2012-12-19 00:38:40 +00:00
echo tra ( " Show: " ) . " " . tra ( " All computers " ) . " · <a href= $url > " . tra ( " Only computers active in past 30 days " ) . " </a> " ;
2010-02-04 16:15:54 +00:00
} else {
$url = link_url ( $sort , $rev , 1 );
2012-12-19 00:38:40 +00:00
echo tra ( " Show: " ) . " <a href= $url > " . tra ( " All computers " ) . " </a> · " . tra ( " Only computers active in past 30 days " );
2010-02-04 16:15:54 +00:00
}
echo " <p> " ;
}
2013-08-02 20:35:17 +00:00
function user_host_table_start (
$private , $sort , $rev , $show_all , $any_product_name
) {
2016-11-11 20:36:27 +00:00
start_table ( 'table-striped' );
2016-12-03 07:25:01 +00:00
$x = array ();
2016-12-05 05:04:23 +00:00
$a = array ();
2010-02-04 16:15:54 +00:00
$url = link_url_rev ( $sort , " id " , $rev , $show_all );
2016-12-03 07:25:01 +00:00
$x [] = " <a href= $url > " . tra ( " Computer ID " ) . " </a> " ;
2016-12-05 05:04:23 +00:00
$a [] = '' ;
2010-02-04 16:15:54 +00:00
if ( $private ) {
$url = link_url_rev ( $sort , " name " , $rev , $show_all );
2016-12-03 07:25:01 +00:00
$x [] = " <a href= $url > " . tra ( " Name " ) . " </a> " ;
2016-12-05 05:04:23 +00:00
$a [] = null ;
2010-02-04 16:15:54 +00:00
$url = link_url_rev ( $sort , " venue " , $rev , $show_all );
2013-08-02 20:35:17 +00:00
if ( $any_product_name ) {
2016-12-03 07:25:01 +00:00
$x [] = tra ( " Model " );
2016-12-05 05:04:23 +00:00
$a [] = null ;
2013-08-02 20:35:17 +00:00
}
2016-12-03 07:25:01 +00:00
$x [] = " <a href= $url > " . tra ( " Location " ) . " </a> " ;
2016-12-05 05:04:23 +00:00
$a [] = null ;
2010-02-04 16:15:54 +00:00
} else {
2016-12-03 07:25:01 +00:00
$x [] = tra ( " Rank " );
2016-12-05 05:04:23 +00:00
$a [] = null ;
2010-02-04 16:15:54 +00:00
}
2017-08-20 07:21:33 +00:00
if ( ! NO_STATS ) {
$url = link_url_rev ( $sort , " expavg_credit " , $rev , $show_all );
$x [] = " <a href= $url > " . tra ( " Avg. credit " ) . " </a> " ;
$a [] = ALIGN_RIGHT ;
$url = link_url_rev ( $sort , " total_credit " , $rev , $show_all );
$x [] = " <a href= $url > " . tra ( " Total credit " ) . " </a> " ;
$a [] = ALIGN_RIGHT ;
}
2016-12-03 07:25:01 +00:00
$x [] = tra ( " BOINC<br>version " );
2016-12-05 05:04:23 +00:00
$a [] = null ;
2010-02-04 16:15:54 +00:00
$url = link_url_rev ( $sort , " cpu " , $rev , $show_all );
2016-12-03 07:25:01 +00:00
$x [] = " <a href= $url > " . tra ( " CPU " ) . " </a> " ;
2016-12-05 05:04:23 +00:00
$a [] = null ;
2016-12-03 07:25:01 +00:00
$x [] = tra ( " GPU " );
2016-12-05 05:04:23 +00:00
$a [] = null ;
2010-02-04 16:15:54 +00:00
$url = link_url_rev ( $sort , " os " , $rev , $show_all );
2016-12-03 07:25:01 +00:00
$x [] = " <a href= $url > " . tra ( " Operating System " ) . " </a> " ;
2016-12-05 05:04:23 +00:00
$a [] = null ;
2010-02-04 16:15:54 +00:00
$url = link_url_rev ( $sort , " rpc_time " , $rev , $show_all );
2016-12-03 07:25:01 +00:00
$x [] = " <a href= $url > " . tra ( " Last contact " ) . " </a> " ;
2016-12-05 05:04:23 +00:00
$a [] = null ;
2017-05-10 08:35:49 +00:00
row_heading_array ( $x , $a , " bg-default " );
2010-02-04 16:15:54 +00:00
}
function show_user_hosts ( $userid , $private , $show_all , $sort , $rev ) {
$desc = false ; // whether the sort order's default is decreasing
switch ( $sort ) {
case " total_credit " : $sort_clause = " total_credit " ; $desc = true ; break ;
case " expavg_credit " : $sort_clause = " expavg_credit " ; $desc = true ; break ;
case " name " : $sort_clause = " domain_name " ; break ;
case " id " : $sort_clause = " id " ; break ;
case " cpu " : $sort_clause = " p_vendor " ; break ;
case " gpu " : $sort_clause = " serialnum " ; break ;
case " os " : $sort_clause = " os_name " ; break ;
case " venue " : $sort_clause = " venue " ; break ;
default :
// default value -- sort by RPC time
$sort = " rpc_time " ;
$sort_clause = " rpc_time " ;
$desc = true ;
}
if ( $rev != $desc ) {
$sort_clause .= " desc " ;
}
more_or_less ( $sort , $rev , $show_all );
$now = time ();
$old_hosts = 0 ;
$i = 1 ;
$hosts = BoincHost :: enum ( " userid= $userid order by $sort_clause " );
2013-08-02 20:35:17 +00:00
$any_product_name = false ;
foreach ( $hosts as $host ) {
if ( $host -> product_name ) {
$any_product_name = true ;
break ;
}
}
user_host_table_start ( $private , $sort , $rev , $show_all , $any_product_name );
2010-02-04 16:15:54 +00:00
foreach ( $hosts as $host ) {
$is_old = false ;
if (( $now - $host -> rpc_time ) > 30 * 86400 ) {
$is_old = true ;
$old_hosts ++ ;
}
if ( ! $show_all && $is_old ) continue ;
2013-08-02 20:35:17 +00:00
show_host_row ( $host , $i , $private , false , $any_product_name );
2010-02-04 16:15:54 +00:00
$i ++ ;
}
2016-11-11 20:36:27 +00:00
end_table ();
2010-02-04 16:15:54 +00:00
if ( $old_hosts > 0 ) {
more_or_less ( $sort , $rev , $show_all );
}
if ( $private ) {
echo "
2010-02-16 01:06:03 +00:00
< a href = merge_by_name . php > " .tra( " Merge computers by name " ). " </ a >
2010-02-04 16:15:54 +00:00
" ;
}
}
2011-02-08 21:38:16 +00:00
// remove user-specific info from a user's hosts
//
function anonymize_hosts ( $user ) {
$hosts = BoincHost :: enum ( " userid= $user->id " );
foreach ( $hosts as $h ) {
2018-05-03 20:31:42 +00:00
$h -> update ( " domain_name='deleted', last_ip_addr='' " );
2011-02-08 21:38:16 +00:00
}
}
2007-11-14 16:03:47 +00:00
$cvs_version_tracker [] = " \$ Id $ " ; //Generated automatically - do not edit
2004-02-02 23:34:39 +00:00
?>