Commit 28939991 authored by Vitaly Lipatov's avatar Vitaly Lipatov

improve hdd script

parent dc699720
......@@ -101,7 +101,7 @@ done
# [23743.306922] blk_update_request: critical medium error, dev sdc, sector 510634067
# [ 6.934350] blk_update_request: I/O error, dev sda, sector 16780432
dmesg | grep -E "(blk_update_request|end_request|print_req_error): (critical medium error|I/O error)" | sed -e "s|.*, dev \(sd[a-z]\), sector \([0-9]*\).*|\1 \2|g" | sort -u | \
dmesg | grep -E "(blk_update_request|end_request|print_req_error): (critical medium error|I/O error)" | sed -e "s|.*, dev \([a-z].*\), sector \([0-9]*\).*|\1 \2|g" | sort -u | \
while read devname sector ; do
#for i in $BLOCKLIST ; do
echo
......
......@@ -6,6 +6,9 @@ fatal()
exit 1
}
SUDO=''
[ "$UID" = "0" ] || SUDO='sudo'
# arg: /dev/sd?
is_hdd()
{
......@@ -39,7 +42,7 @@ print_drive_vendor()
{
local OUT=''
local TF=$(mktemp)
smartctl -i $1 >$TF
$SUDO smartctl -i $1 >$TF
OUT="$(get_smart_field $TF "Model Family" | sed -e 's/ .*//')"
[ -n "$OUT" ] || OUT="$(get_smart_field $TF "Model Number" | sed -e 's/ .*//')"
[ -n "$OUT" ] || OUT="$(get_smart_field $TF "Vendor")"
......@@ -51,7 +54,7 @@ print_drive_product()
{
local OUT=''
local TF=$(mktemp)
smartctl -i $1 >$TF
$SUDO smartctl -i $1 >$TF
OUT="$(get_smart_field $TF "Device Model" | sed -e 's/ / /')"
[ -n "$OUT" ] || OUT="$(get_smart_field $TF "Model Number" | sed -e 's/ / /')"
[ -n "$OUT" ] || OUT="$(get_smart_field $TF "Product") $(get_smart_field $TF "Revision")"
......@@ -63,7 +66,7 @@ print_drive_rotation()
{
local OUT=''
local TF=$(mktemp)
smartctl -i $1 >$TF
$SUDO smartctl -i $1 >$TF
OUT="$(get_smart_field $TF "Rotation Rate" | sed -e 's/ .*//')"
echo "$OUT"
rm -f $TF
......@@ -150,7 +153,7 @@ print_serno()
{
# 'Serial number' for SAS
# 'Serial Number' for SATA
smartctl -i "$1" | grep -i "Serial Number: " | sed -e "s/.*Serial Number: *//gi" | tail -c 5
$SUDO smartctl -i "$1" | grep -i "Serial Number: " | sed -e "s/.*Serial Number: *//gi" | tail -c 5
#hdparm -i "$1" | grep "SerialNo=" | sed -e "s/.*SerialNo=//g" | tail -c 5
}
......@@ -158,7 +161,7 @@ print_wwn()
{
# 'Serial number' for SAS
# 'Serial Number' for SATA
smartctl -i "$1" | grep -i "LU WWN Device Id: " | sed -e "s/.*LU WWN Device Id: *//gi" | tail -c 5
$SUDO smartctl -i "$1" | grep -i "LU WWN Device Id: " | sed -e "s/.*LU WWN Device Id: *//gi" | tail -c 5
#hdparm -i "$1" | grep "SerialNo=" | sed -e "s/.*SerialNo=//g" | tail -c 5
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment