2 # Show all drives and their SMART status
4 require './smart-status-lib.pl';
7 # Make sure SMART commands are installed
8 if (!&has_command($config{'smartctl'})) {
9 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
11 &ui_config_link('index_ecmd',
12 [ "<tt>$config{'smartctl'}</tt>", undef ]));
16 $ver = &get_smart_version();
18 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
20 &ui_config_link('index_ecmd2',
21 [ "<tt>$config{'smartctl'}</tt>", undef ]));
23 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
24 &help_search_link("smartctl", "man", "doc", "google"),
26 &text('index_version', $ver));
29 @drives = &list_smart_disks_partitions();
31 &ui_print_endpage($text{'index_eidescsi'});
34 if ($config{'mode'} == 1 || $in{'drive'}) {
35 # Just show one drive, selected from menu
36 print &ui_form_start("index.cgi");
37 print "<b>$text{'index_show'}</b>\n";
38 print &ui_select("drive", $in{'drive'},
39 [ map { [ $_->{'device'}.":".$_->{'subdisk'},
40 $_->{'desc'}.($_->{'model'} ? " ($_->{'model'})" : "") ] } @drives ],
41 1, 0, 0, 0, "onChange='form.submit()'");
42 print &ui_submit($text{'index_ok'}),"\n";
46 ($device, $subdisk) = split(/:/, $in{'drive'});
47 ($d) = grep { $_->{'device'} eq $device &&
48 $_->{'subdisk'} == $subdisk } @drives;
54 foreach $d (@drives) {
59 &ui_print_footer("/", $text{'index'});
64 print &ui_form_start("action.cgi");
65 print &ui_hidden("drive", $_[0]->{'device'});
66 print &ui_hidden("subdisk", $_[0]->{'subdisk'});
67 local $h = defined($_[0]->{'subdisk'}) ?
68 &text('index_drivesub', "<tt>$_[0]->{'device'}</tt>",
70 &text('index_drive', "<tt>$_[0]->{'device'}</tt>");
71 print &ui_table_start($h, "width=100%", 4,
72 [ "width=30%", undef, "width=30%", undef ]);
73 local $st = &get_drive_status($_[0]->{'device'}, $_[0]);
74 print &ui_table_row($text{'index_desc'},
76 if ($_[0]->{'cylsize'}) {
77 print &ui_table_row($text{'index_size'},
78 &nice_size($_[0]->{'cylinders'}*$_[0]->{'cylsize'}));
80 if ($_[0]->{'model'}) {
81 print &ui_table_row($text{'index_model'},
84 print &ui_table_row($text{'index_support'},
85 $st->{'support'} ? $text{'yes'} : $text{'no'});
86 print &ui_table_row($text{'index_enabled'},
87 $st->{'enabled'} ? $text{'yes'} : $text{'no'});
88 if ($st->{'support'} && $st->{'enabled'}) {
89 if ($st->{'errors'}) {
90 print &ui_table_row($text{'index_errors'},
91 "<font color=#ff0000>".
92 &text('index_ecount', $st->{'errors'}).
95 print &ui_table_row($text{'index_check'},
96 $st->{'check'} ? $text{'yes'} :
97 "<font color=#ff0000>$text{'no'}</font>");
99 print &ui_table_end();
101 # Show extra attributes
102 if ($config{'attribs'} && @{$st->{'attribs'}}) {
104 print &ui_hidden_table_start($text{'index_attrs'}, "width=100%", 2,
105 "attrs".$attrs_count, 1, [ "width=30%" ]);
106 foreach my $a (@{$st->{'attribs'}}) {
107 next if ($a->[0] =~ /UDMA CRC Error Count/i); # too long
108 print &ui_table_row($a->[0],
109 $a->[2] =~ /^\s*(seconds|minutes|hours|days|months|years|weeks)\s*/i || !$a->[2] ? $a->[1]." ".$a->[2] : $a->[2]);
111 print &ui_hidden_table_end();
114 # Show raw data from smartctl
115 if ($config{'attribs'} && $st->{'raw'}) {
117 print &ui_hidden_table_start($text{'index_raw'}, "width=100%", 2,
118 "raw".$raw_count, @{$st->{'attribs'}} ? 0 : 1);
119 print &ui_table_row(undef,
120 "<pre>".&html_escape($st->{'raw'})."</pre>", 2);
121 print &ui_hidden_table_end();
124 if ($st->{'support'} && $st->{'enabled'}) {
125 print &ui_form_end([ [ "short", $text{'index_short'} ],
126 [ "ext", $text{'index_ext'} ],
127 [ "data", $text{'index_data'} ] ]);
130 print &ui_form_end();