#!/usr/local/bin/perl # Show SMART status for a given device use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; require './bsdfdisk-lib.pl'; our (%in, %text, $module_name); &ReadParse(); # Validate device param $in{'device'} =~ /^[a-zA-Z0-9_\/.-]+$/ or &error($text{'disk_edevice'} || 'Invalid device'); $in{'device'} !~ /\.\./ or &error($text{'disk_edevice'} || 'Invalid device'); # Check smartctl availability &has_command('smartctl') or &error($text{'index_ecmd'} ? &text('index_ecmd','smartctl') : 'smartctl not available'); my $device = $in{'device'}; my $dev_html = &html_escape($device); &ui_print_header($dev_html, $text{'disk_smart'} || 'SMART Status', ""); print "
\n"; print "

SMART status for $dev_html

\n"; print "
\n"; my $cmd = "smartctl -a " . "e_path($device) . " 2>&1"; my $out = &backquote_command($cmd); print "
" . &html_escape("Command: $cmd\n\n$out") . "
\n"; print "
\n"; &ui_print_footer("edit_disk.cgi?device=".&urlize($device), $text{'disk_return'});