Projet

Général

Profil

Télécharger (2,87 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / widgets / widgets / smart_status.widget.php @ fab1cd2f

1
<?php
2
/*
3
	Copyright 2012 mkirbst @ pfSense Forum
4
	Part of pfSense widgets (https://www.pfsense.org)
5
	All rights reserved.
6

    
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9

    
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12

    
13
	2. Redistributions in binary form must reproduce the above copyright
14
	   notice, this list of conditions and the following disclaimer in the
15
	   documentation and/or other materials provided with the distribution.
16

    
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28

    
29
require_once("guiconfig.inc");
30
require_once("pfsense-utils.inc");
31
require_once("functions.inc");
32
require_once("/usr/local/www/widgets/include/smart_status.inc");
33
?>
34

    
35
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="smart status">
36
	<tr>
37
		<td class="widgetsubheader" align="center"><b><?php echo gettext("Drive") ?></b></td>
38
		<td class="widgetsubheader" align="center"><b><?php echo gettext("Ident") ?></b></td>
39
		<td class="widgetsubheader" align="center"><b><?php echo gettext("SMART Status") ?></b></td>
40
	</tr>
41

    
42
<?php
43
$devs = array();
44
## Get all adX, daX, and adaX (IDE, SCSI, and AHCI) devices currently installed
45
exec("ls /dev | grep '^\(ad\|da\|ada\)[0-9]\{1,2\}$'", $devs); ## From SMART status page
46

    
47
if(count($devs) > 0)  {
48
	foreach($devs as $dev)  {	## for each found drive do
49
		$dev_ident = exec("diskinfo -v /dev/$dev | grep ident   | awk '{print $1}'"); ## get identifier from drive
50
		$dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit}
51
/^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive
52
		switch ($dev_state) {
53
		case "PASSED":
54
		case "OK":
55
			$color = "#90EE90";
56
			break;
57
		case "":
58
			$dev_state = "Unknown";
59
			$color = "#C0B788";
60
			break;
61
		default:
62
			$color = "#F08080";
63
			break;
64
		}
65
?>
66
		<tr>
67
			<td class="listlr"><?php echo $dev; ?></td>
68
			<td class="listr" align="center"><?php echo $dev_ident; ?></td>
69
			<td class="listr" align="center"><span style="background-color:<?php echo $color; ?>">&nbsp;<?php echo $dev_state; ?>&nbsp;</span></td>
70
		</tr>
71
<?php	}
72
}
73
?>
74
</table>
(17-17/21)