Révision 504e5fd4
Ajouté par jim-p il y a presque 10 ans
usr/local/www/widgets/include/gmirror_status.inc | ||
---|---|---|
27 | 27 |
|
28 | 28 |
function gmirror_get_status() { |
29 | 29 |
$status = ""; |
30 |
exec("/sbin/gmirror status", $status); |
|
30 |
exec("/sbin/gmirror status -s", $status);
|
|
31 | 31 |
$mirrors = array(); |
32 | 32 |
|
33 | 33 |
/* Empty output = no mirrors found */ |
34 | 34 |
if (count($status) > 0) { |
35 |
/* We don't need the first row, it's just a header */ |
|
36 |
$status = array_slice($status, 1); |
|
37 |
|
|
38 | 35 |
/* Loop through gmirror status output. */ |
39 | 36 |
foreach ($status as $line) { |
40 | 37 |
/* Split the line by whitespace */ |
41 | 38 |
$all = preg_split("/[\s\t]+/", trim($line), 3); |
42 |
if (count($all) == 3) {
|
|
39 |
if (count($all) == 3) { |
|
43 | 40 |
/* If there are three items on a line, it is mirror name, status, and component */ |
44 | 41 |
$currentmirror = $all[0]; |
45 | 42 |
$mirrors[$currentmirror]["name"] = $all[0]; |
46 | 43 |
$mirrors[$currentmirror]["status"] = $all[1]; |
47 |
$mirrors[$currentmirror]["components"] = array(); |
|
44 |
if (!is_array($mirrors[$currentmirror]["components"])) |
|
45 |
$mirrors[$currentmirror]["components"] = array(); |
|
48 | 46 |
$mirrors[$currentmirror]["components"][] = $all[2]; |
49 |
} elseif ((trim($line) != "") && (count($all) > 0)) { |
|
50 |
/* If there is just one item on a line, it is a component name of the previous mirror */ |
|
51 |
$mirrors[$currentmirror]["components"][] = trim($line); |
|
52 | 47 |
} |
53 | 48 |
} |
54 | 49 |
} |
Formats disponibles : Unified diff
Use script-friendly gmirror status output to build this info, old method was breaking output when the mirror was being rebuilt.