1
|
|
|
<?php |
2
|
|
|
// This file is part of BOINC. |
3
|
|
|
// https://boinc.berkeley.edu |
4
|
|
|
// Copyright (C) 2024 University of California |
5
|
|
|
// |
6
|
|
|
// BOINC is free software; you can redistribute it and/or modify it |
7
|
|
|
// under the terms of the GNU Lesser General Public License |
8
|
|
|
// as published by the Free Software Foundation, |
9
|
|
|
// either version 3 of the License, or (at your option) any later version. |
10
|
|
|
// |
11
|
|
|
// BOINC is distributed in the hope that it will be useful, |
12
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
14
|
|
|
// See the GNU Lesser General Public License for more details. |
15
|
|
|
// |
16
|
|
|
// You should have received a copy of the GNU Lesser General Public License |
17
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
|
19
|
|
|
// show counts of Linux hosts broken down by libc and vbox version |
20
|
|
|
|
21
|
|
|
require_once("../inc/boinc_db.inc"); |
22
|
|
|
|
23
|
|
|
$max_days = 30; |
24
|
|
|
// include only hosts who have done an RPC within this many days |
25
|
|
|
|
26
|
|
|
function is_linux($host) { |
27
|
|
|
return strstr($host->os_name, 'Linux'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function libc_version($host) { |
31
|
|
|
$p = $host->os_version; |
32
|
|
|
$n = strpos($p, 'libc '); |
33
|
|
|
if ($n === false) return ''; |
34
|
|
|
$m = strpos($p, ']', $n); |
35
|
|
|
if ($m === false) return ''; |
36
|
|
|
$x = substr($p, $n+5, $m-$n-5); |
37
|
|
|
|
38
|
|
|
$n = strpos($x, ' '); |
39
|
|
|
if ($n !== false) return substr($x, 0, $n); |
40
|
|
|
return $x; |
41
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function vbox_version($host) { |
45
|
|
|
$p = $host->serialnum; |
46
|
|
|
$n = strpos($p, 'vbox|'); |
47
|
|
|
if ($n === false) return ''; |
48
|
|
|
$m = strpos($p, ']', $n); |
49
|
|
|
if ($m === false) return ''; |
50
|
|
|
$x = substr($p, $n+5, $m-$n-5); |
51
|
|
|
$n = strpos($x, '_'); |
52
|
|
|
if ($n !== false) return substr($x, 0, $n); |
53
|
|
|
$n = strpos($x, 'r'); |
54
|
|
|
if ($n !== false) return substr($x, 0, $n); |
55
|
|
|
return $x; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function main() { |
59
|
|
|
global $max_days; |
60
|
|
|
$t = time()-$max_days*86400; |
61
|
|
|
$hosts = BoincHost::enum("rpc_time>$t"); |
62
|
|
|
$descs = []; |
63
|
|
|
foreach ($hosts as $host) { |
64
|
|
|
if (!is_linux($host)) continue; |
65
|
|
|
$d = new StdClass; |
66
|
|
|
$d->libc = libc_version($host); |
67
|
|
|
$d->vbox = vbox_version($host); |
68
|
|
|
$descs[] = $d; |
69
|
|
|
} |
70
|
|
|
show($descs); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
// show: |
74
|
|
|
// counts by libc version |
75
|
|
|
// counts by libc version for hosts w/ vbox |
76
|
|
|
// counts by vbox version |
77
|
|
|
|
78
|
|
|
function show($descs) { |
79
|
|
|
global $max_days; |
80
|
|
|
$libc = []; |
81
|
|
|
$libc2 = []; |
82
|
|
|
$vbox = []; |
83
|
|
|
$nv = 0; |
84
|
|
|
foreach ($descs as $d) { |
85
|
|
|
if (array_key_exists($d->libc, $libc)) { |
86
|
|
|
$libc[$d->libc] += 1; |
87
|
|
|
} else { |
88
|
|
|
$libc[$d->libc] = 1; |
89
|
|
|
} |
90
|
|
|
if (!$d->vbox) continue; |
91
|
|
|
$nv++; |
92
|
|
|
if (array_key_exists($d->vbox, $vbox)) { |
93
|
|
|
$vbox[$d->vbox] += 1; |
94
|
|
|
} else { |
95
|
|
|
$vbox[$d->vbox] = 1; |
96
|
|
|
} |
97
|
|
|
if (array_key_exists($d->libc, $libc2)) { |
98
|
|
|
$libc2[$d->libc] += 1; |
99
|
|
|
} else { |
100
|
|
|
$libc2[$d->libc] = 1; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
$n = count($descs); |
105
|
|
|
echo "$n Linux hosts active in last $max_days days\n"; |
106
|
|
|
ksort($libc); |
107
|
|
|
echo "libc versions:\n"; |
108
|
|
|
foreach ($libc as $x=>$count) { |
|
|
|
|
109
|
|
|
if (!$x) continue; |
110
|
|
|
echo "$x: $count\n"; |
111
|
|
|
} |
112
|
|
|
ksort($vbox); |
113
|
|
|
echo "vbox versions ($nv hosts):\n"; |
114
|
|
|
foreach ($vbox as $x=>$count) { |
|
|
|
|
115
|
|
|
if (!$x) continue; |
116
|
|
|
echo "$x: $count\n"; |
117
|
|
|
} |
118
|
|
|
ksort($libc2); |
119
|
|
|
echo "libc versions of hosts with vbox:\n"; |
120
|
|
|
foreach ($libc2 as $x=>$count) { |
|
|
|
|
121
|
|
|
if (!$x) continue; |
122
|
|
|
echo "$x: $count\n"; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
main(); |
127
|
|
|
?> |
128
|
|
|
|