Exemplo n.º 1
0
function do_app($app)
{
    // enumerate the host_app_versions for this app,
    // joined to the host
    $db = BoincDb::get();
    $query = "select et_avg, host.on_frac, host.active_frac, host.gpu_active_frac, app_version.plan_class " . " from DBNAME.host_app_version, DBNAME.host, DBNAME.app_version " . " where host_app_version.app_version_id = app_version.id " . " and app_version.appid = {$app->id} " . " and et_n > 0  and et_avg > 0 " . " and host.id = host_app_version.host_id";
    $result = $db->do_query($query);
    $a = array();
    while ($x = _mysql_fetch_object($result)) {
        if (is_gpu($x->plan_class)) {
            $av = $x->on_frac;
            if ($x->gpu_active_frac) {
                $av *= $x->gpu_active_frac;
            } else {
                $av *= $x->active_frac;
            }
        } else {
            $av = $x->on_frac * $x->active_frac;
        }
        $a[] = 1 / $x->et_avg * $av;
    }
    _mysql_free_result($result);
    sort($a);
    $n = count($a);
    $f = fopen("../../size_census_" . $app->name, "w");
    for ($i = 1; $i < $app->n_size_classes; $i++) {
        $k = (int) ($i * $n / $app->n_size_classes);
        fprintf($f, "%e\n", $a[$k]);
    }
    fclose($f);
}
Exemplo n.º 2
0
function delete_user($user)
{
    if (!empty($user->teamid)) {
        user_quit_team($user);
    }
    if ($user->has_profile) {
        _mysql_query("DELETE FROM profile WHERE userid = {$user->id}");
        delete_user_pictures($user->id);
        _mysql_query("UPDATE user SET has_profile=0 WHERE id={$user->id}");
    }
    if ($user->total_credit > 0.0) {
        error_page("Cannot delete user: User has credit.");
        return false;
    }
    // Don't delete user if they have any outstanding Results
    //
    $q = "SELECT COUNT(*) AS count FROM result WHERE userid=" . $user->id;
    $result = _mysql_query($q);
    $c = _mysql_fetch_object($result);
    _mysql_free_result($result);
    if ($c->count) {
        error_page("Cannot delete user: User has {$c->count} results in the database.");
    }
    // Don't delete user if they have posted to the forums
    //
    $q = "SELECT COUNT(*) AS count FROM post WHERE user="******"Cannot delete user: User has {$c->count} forum posts.");
    }
    $q = "DELETE FROM user WHERE id=" . $user->id;
    $result = _mysql_query($q);
}
Exemplo n.º 3
0
function get_mysql_count($hr_class)
{
    $result = _mysql_query("select count(id) as count from workunit where hr_class=" . $hr_class);
    $count = _mysql_fetch_object($result);
    _mysql_free_result($result);
    return $count->count;
}
Exemplo n.º 4
0
function get_count_from_db()
{
    $result = _mysql_query("select count(*) from result");
    if (!$result) {
        return false;
    }
    $count = _mysql_fetch_array($result);
    _mysql_free_result($result);
    return $count[0];
}
Exemplo n.º 5
0
function getSingleQuery($query)
{
    $result = _mysql_query($query);
    if (!$result) {
        return;
    }
    $cnt = _mysql_fetch_row($result);
    if (!$cnt) {
        return;
    }
    _mysql_free_result($result);
    return $cnt[0];
}
Exemplo n.º 6
0
function update_thread_timestamps()
{
    $threads = BoincThread::enum();
    foreach ($threads as $thread) {
        $q = "select max(timestamp) as foo from post where thread={$thread->id}";
        $r2 = _mysql_query($q);
        $m = _mysql_fetch_object($r2);
        echo "id: {$thread->id}; min: {$m->foo}\n";
        _mysql_free_result($r2);
        $n = $m->foo;
        if ($n) {
            $q = "update thread set timestamp={$n} where id={$thread->id}";
            _mysql_query($q);
        }
    }
}
// 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/>.
require_once "../inc/util_ops.inc";
db_init();
admin_page_head("Failures grouped by app version and host");
$query_appid = $_GET['appid'];
$query_received_time = time() - $_GET['nsecs'];
$main_query = "\nSELECT\n       app_version_id,\n       app_version_num,\n       hostid AS Host_ID,\n       case\n           when INSTR(host.os_name, 'Darwin') then 'Darwin'\n           when INSTR(host.os_name, 'Linux') then 'Linux'\n           when INSTR(host.os_name, 'Windows') then 'Windows'\n           when INSTR(host.os_name, 'SunOS') then 'SunOS'\n           when INSTR(host.os_name, 'Solaris') then 'Solaris'\n           when INSTR(host.os_name, 'Mac') then 'Mac'\n           else 'Unknown'\n       end AS OS_Name,\n       case\n           when INSTR(host.os_name, 'Linux') then \n               case\n                   when INSTR(LEFT(host.os_version, 6), '-') then LEFT(host.os_version, (INSTR(LEFT(host.os_version, 6), '-') - 1))\n                   else LEFT(host.os_version, 6)\n               end\n           else host.os_version\n       end AS OS_Version,\n       host.nresults_today AS Results_Today, \n       COUNT(*) AS error_count\nFROM   result\n           left join host on result.hostid = host.id \nWHERE\n       appid = '{$query_appid}' and\n       server_state = '5' and\n       outcome = '3' and \n       received_time > '{$query_received_time}'\nGROUP BY\n       app_version_id,\n       hostid\norder by error_count desc\n";
$result = _mysql_query($main_query);
start_table();
table_header("App version", "Host ID", "OS Version", "Results today", "Error count");
while ($res = _mysql_fetch_object($result)) {
    table_row(app_version_desc($res->app_version_id), "<a href=" . URL_BASE . "show_host_detail.php?hostid={$res->Host_ID}>{$res->Host_ID}</a>", $res->OS_Version, $res->Results_Today, "<a href=db_action.php?table=result&detail=low&hostid={$res->Host_ID}&app_version_id={$res->app_version_id}&server_state=5&outcome=3>{$res->error_count}</a>");
}
_mysql_free_result($result);
end_table();
admin_page_tail();
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit
Exemplo n.º 8
0
while ($res = _mysql_fetch_object($dbresult)) {
    $id = $res->workunitid;
    if ($id != $previd) {
        if ($errors > $prevquorum + $notification_level) {
            print_wu($previd, $prevname, $prevquorum, $errors);
            $rescount++;
        }
        $previd = $id;
        $prevname = $res->name;
        $prevquorum = $res->min_quorum;
        $errors = 0;
    }
    if ($res->outcome == 3) {
        $errors++;
    }
    if ($res->outcome == 1) {
        $errors = 0;
    }
}
_mysql_free_result($dbresult);
if ($errors > $prevquorum) {
    print_wu($id, $prevname, $prevquorum, $errors);
    $rescount++;
}
echo "</table>\n<br>";
echo $rescount;
echo " entries\n";
admin_page_tail();
end_cache($cache_sec);
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit
Exemplo n.º 9
0
function cherokee_mysql_free_result(&$result)
{
    if (!_is_result($result)) {
        return _mysql_free_result($result);
    }
    return TRUE;
}
Exemplo n.º 10
0
function grant_credits_for_cancelled()
{
    $ngranted = 0;
    $query_w = _mysql_query("select * from workunit where error_mask!=0");
    while ($workunit = _mysql_fetch_object($query_w)) {
        // echo "Starting WU $workunit->id\n";
        $ngranted += grant_credits_for_wu($workunit->id);
        // NEED TO SET assimilate_state=READY for WU!!
    }
    _mysql_free_result($query_w);
    echo "\nGranted credits to {$ngranted} results\n";
}
Exemplo n.º 11
0
function do_lapsed()
{
    global $globals;
    $max_last_rpc_time = time() - $globals->lapsed_interval;
    // the following is an efficient way of getting the list of
    // users for which no host has done an RPC recently
    //
    $result = _mysql_query("select userid from host group by userid having max(rpc_time)<{$max_last_rpc_time};");
    while ($host = _mysql_fetch_object($result)) {
        $uresult = _mysql_query("select * from user where id = {$host->userid};");
        $user = _mysql_fetch_object($uresult);
        _mysql_free_result($uresult);
        if (!$user) {
            echo "Can't find user {$host->userid}\n";
            continue;
        }
        handle_user($user, 'lapsed');
    }
    _mysql_free_result($result);
}
Exemplo n.º 12
0
function do_one($thisid, $log)
{
    $result = _mysql_query("select * from user where id={$thisid}");
    $user = _mysql_fetch_object($result);
    if ($user) {
        handle_user($user);
        fputs($log, $user->id . "\n");
        fflush($log);
    }
    _mysql_free_result($result);
    return $startid;
}
Exemplo n.º 13
0
// 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/>.
// repairs a problem that was fixed in 2004.
// You should never have to run this script
set_time_limit(0);
$cli_only = true;
require_once "../inc/util_ops.inc";
// activate/deactivate script
if (1) {
    echo "\nThis script needs to be activated before it can be run.\nOnce you understand what the script does you can change the \nif (1) to if (0) at the top of the file to activate it.\nBe sure to deactivate the script after using it to make sure\nit is not accidentally run. \n";
    exit;
}
db_init();
$result = _mysql_query("select * from workunit where canonical_resultid=0");
while ($wu = _mysql_fetch_object($result)) {
    $r2 = _mysql_query("select count(*) from result where workunitid={$wu->id} and outcome=1 limit 1000");
    $x = _mysql_fetch_array($r2);
    _mysql_free_result($r2);
    $nsuccess = $x[0];
    $r2 = _mysql_query("select count(*) from result where workunitid={$wu->id} and server_state=2");
    $x = _mysql_fetch_array($r2);
    _mysql_free_result($r2);
    $nunsent = $x[0];
    if ($nsuccess >= 3 and $nunsent == 0) {
        echo "WU {$wu->id} has {$nsuccess} success, {$nunsent} unsent \n";
        _mysql_query("update workunit set need_validate=1 where id={$wu->id}");
    }
}