summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2014-05-28 13:41:48 -0400
committerjim-p <jimp@pfsense.org>2014-05-28 14:00:31 -0400
commit504e5fd46f1c4840666d1f20ecac934c07e16a88 (patch)
tree2f2228c4aaf51620af7182f3eb4fc54811a352a6
parent1c847e5e14c75adb86ccd516bbfdc98ac53efca1 (diff)
downloadpfsense-504e5fd46f1c4840666d1f20ecac934c07e16a88.zip
pfsense-504e5fd46f1c4840666d1f20ecac934c07e16a88.tar.gz
Use script-friendly gmirror status output to build this info, old method was breaking output when the mirror was being rebuilt.
-rw-r--r--usr/local/www/widgets/include/gmirror_status.inc13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr/local/www/widgets/include/gmirror_status.inc b/usr/local/www/widgets/include/gmirror_status.inc
index 414c394..8a04d4a 100644
--- a/usr/local/www/widgets/include/gmirror_status.inc
+++ b/usr/local/www/widgets/include/gmirror_status.inc
@@ -27,28 +27,23 @@
function gmirror_get_status() {
$status = "";
- exec("/sbin/gmirror status", $status);
+ exec("/sbin/gmirror status -s", $status);
$mirrors = array();
/* Empty output = no mirrors found */
if (count($status) > 0) {
- /* We don't need the first row, it's just a header */
- $status = array_slice($status, 1);
-
/* Loop through gmirror status output. */
foreach ($status as $line) {
/* Split the line by whitespace */
$all = preg_split("/[\s\t]+/", trim($line), 3);
- if (count($all) == 3) {
+ if (count($all) == 3) {
/* If there are three items on a line, it is mirror name, status, and component */
$currentmirror = $all[0];
$mirrors[$currentmirror]["name"] = $all[0];
$mirrors[$currentmirror]["status"] = $all[1];
- $mirrors[$currentmirror]["components"] = array();
+ if (!is_array($mirrors[$currentmirror]["components"]))
+ $mirrors[$currentmirror]["components"] = array();
$mirrors[$currentmirror]["components"][] = $all[2];
- } elseif ((trim($line) != "") && (count($all) > 0)) {
- /* If there is just one item on a line, it is a component name of the previous mirror */
- $mirrors[$currentmirror]["components"][] = trim($line);
}
}
}
OpenPOWER on IntegriCloud