summaryrefslogtreecommitdiffstats
path: root/usr/local/www/widgets
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2014-05-30 14:10:18 -0400
committerjim-p <jimp@pfsense.org>2014-05-30 14:15:06 -0400
commit52398a6b569c8de55b4e4ee931c82e47e2ee4b31 (patch)
treec1ea80449a0b97e7d4339b7943a5939630b1bd67 /usr/local/www/widgets
parent8490ba0fc6119415a0925ab5b80018ad6709969a (diff)
downloadpfsense-52398a6b569c8de55b4e4ee931c82e47e2ee4b31.zip
pfsense-52398a6b569c8de55b4e4ee931c82e47e2ee4b31.tar.gz
Bring in proper gmirror support for the GUI and notifications.
Made a general gmirror library to perform various gmirror tasks and get information, using some of the former widget logic to start. Updated widget to use this new code. Added a Diag > GEOM Mirrors page that displays information about existing mirrors and perform various management tasks. Current actions include rebuilding a drive, forgetting disconnected mirror drives, insert/remove, deactivate/activate, clearing medatada. It's now possible to use the GUI to rebuild a failed mirror by performing a forget, then insert action to replace a missing/dead drive. Also included is a notification setup. Mirror status is polled every 60 seconds, and if any aspect of the mirror changes, notifications are issues that alert in the GUI and by SMTP, etc.
Diffstat (limited to 'usr/local/www/widgets')
-rw-r--r--usr/local/www/widgets/include/gmirror_status.inc85
-rw-r--r--usr/local/www/widgets/widgets/gmirror_status.widget.php2
2 files changed, 1 insertions, 86 deletions
diff --git a/usr/local/www/widgets/include/gmirror_status.inc b/usr/local/www/widgets/include/gmirror_status.inc
deleted file mode 100644
index 8a04d4a..0000000
--- a/usr/local/www/widgets/include/gmirror_status.inc
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-/*
- gmirror_status.widget.php
- Copyright (C) 2009-2010 Jim Pingle
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-function gmirror_get_status() {
- $status = "";
- exec("/sbin/gmirror status -s", $status);
- $mirrors = array();
-
- /* Empty output = no mirrors found */
- if (count($status) > 0) {
- /* 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 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];
- if (!is_array($mirrors[$currentmirror]["components"]))
- $mirrors[$currentmirror]["components"] = array();
- $mirrors[$currentmirror]["components"][] = $all[2];
- }
- }
- }
- /* Return an hash of mirrors and components */
- return $mirrors;
-}
-
-function gmirror_html_status() {
- $mirrors = gmirror_get_status();
- $output = "";
- if (count($mirrors) > 0) {
- $output .= "<tr>\n";
- $output .= "<td width=\"40%\" class=\"vncellt\">Name</td>\n";
- $output .= "<td width=\"40%\" class=\"vncellt\">Status</td>\n";
- $output .= "<td width=\"20%\" class=\"vncellt\">Component</td>\n";
- $output .= "</tr>\n";
- foreach ($mirrors as $mirror => $name) {
- $components = count($name["components"]);
- $output .= "<tr>\n";
- $output .= "<td width=\"40%\" rowspan=\"{$components}\" class=\"listr\">{$name['name']}</td>\n";
- $output .= "<td width=\"40%\" rowspan=\"{$components}\" class=\"listr\">{$name['status']}</td>\n";
- $output .= "<td width=\"20%\" class=\"listr\">{$name['components'][0]}</td>\n";
- $output .= "</tr>\n";
- if (count($name["components"]) > 1) {
- $morecomponents = array_slice($name["components"], 1);
- foreach ($morecomponents as $component) {
- $output .= "<tr>\n";
- $output .= "<td width=\"20%\" class=\"listr\">{$component}</td>\n";
- $output .= "</tr>\n";
- }
- }
- }
- } else {
- $output .= "<tr><td colspan=\"3\" class=\"listr\">No Mirrors Found</td></tr>\n";
- }
- // $output .= "<tr><td colspan=\"3\" class=\"listr\">Updated at " . date("F j, Y, g:i:s a") . "</td></tr>\n";
- return $output;
-}
-?> \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/gmirror_status.widget.php b/usr/local/www/widgets/widgets/gmirror_status.widget.php
index 543daf4..2d040c0 100644
--- a/usr/local/www/widgets/widgets/gmirror_status.widget.php
+++ b/usr/local/www/widgets/widgets/gmirror_status.widget.php
@@ -28,7 +28,7 @@
$nocsrf = true;
require_once("guiconfig.inc");
-require_once("/usr/local/www/widgets/include/gmirror_status.inc");
+require_once("gmirror.inc");
if ($_GET['textonly'] == "true") {
header("Cache-Control: no-cache");
OpenPOWER on IntegriCloud