From 82e6d795390c48ef461c915ed2d87bccaa7ee23f Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 18 Jan 2017 13:26:48 +0545 Subject: Add filter to SMART status widget (cherry picked from commit 22e8fa1f6aec0b1536f0c07e1573ac78a291891f) --- .../www/widgets/widgets/smart_status.widget.php | 89 ++++++++++++++++++++-- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/src/usr/local/www/widgets/widgets/smart_status.widget.php b/src/usr/local/www/widgets/widgets/smart_status.widget.php index dd7f0a6..e856987 100644 --- a/src/usr/local/www/widgets/widgets/smart_status.widget.php +++ b/src/usr/local/www/widgets/widgets/smart_status.widget.php @@ -61,9 +61,35 @@ require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once("/usr/local/www/widgets/include/smart_status.inc"); $specplatform = system_identify_specific_platform(); + +$devs = array(); +## Get all adX, daX, and adaX (IDE, SCSI, and AHCI) devices currently installed +if ($specplatform['name'] != "Hyper-V") { + $devs = get_smart_drive_list(); +} + +if ($_POST) { + + $validNames = array(); + + foreach ($devs as $dev) { + array_push($validNames, $dev); + } + + if (is_array($_POST['show'])) { + $user_settings['widgets']['smart_status']['filter'] = implode(',', array_diff($validNames, $_POST['show'])); + } else { + $user_settings['widgets']['smart_status']['filter'] = ""; + } + + save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved SMART Status Filter via Dashboard.")); + header("Location: /index.php"); +} + ?> - +
+
@@ -74,14 +100,14 @@ $specplatform = system_identify_specific_platform(); 0) { foreach ($devs as $dev) { ## for each found drive do + if (in_array($dev, $skipsmart)) { + continue; + } + $dev_ident = exec("diskinfo -v /dev/$dev | grep ident | awk '{print $1}'"); ## get identifier from drive $dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit} /^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive @@ -114,3 +140,54 @@ if (count($devs) > 0) { ?>
+ + +