2021-01-22 21:49:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# license: gpl-3
|
2021-02-01 12:59:52 +00:00
|
|
|
if [[ ! "$0" =~ "bash" ]];then
|
|
|
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/stocheck/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/stocheck/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/stocheck/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "-u" ]];then
|
|
|
|
echo "#############################################"
|
|
|
|
echo -e "\e[4mnote: newer version detected, use -u to update\e[0m"
|
|
|
|
echo "#############################################"
|
|
|
|
echo ""
|
|
|
|
fi
|
2021-01-22 21:49:23 +00:00
|
|
|
fi
|
2021-01-24 20:47:09 +00:00
|
|
|
while [ -z "$1" ]; do
|
2021-01-24 21:49:56 +00:00
|
|
|
raidcheck="$(lspci | grep -E 'LSI|3Ware|Adaptec|Smartraid')"
|
2021-01-23 20:35:30 +00:00
|
|
|
if [[ -z "$raidcheck" ]];then
|
|
|
|
if [[ -n $(ls /sys/block | grep sd) ]];then
|
|
|
|
echo "=== sata drive check: ==="
|
2021-02-10 12:07:46 +00:00
|
|
|
echo "-------------------------"
|
|
|
|
echo "$(ls -l /sys/block | grep sd | wc -l) Drives found"
|
|
|
|
echo "-------------------------"
|
2021-01-23 20:35:30 +00:00
|
|
|
for x in {a..z};do
|
|
|
|
scan=$(smartctl --scan)
|
|
|
|
if [[ -n $(echo $scan | grep /dev/sd$x) ]];then
|
|
|
|
echo "------------------- /dev/sd$x --------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
smartctl -i /dev/sd$x | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate"
|
2021-02-02 12:38:45 +00:00
|
|
|
echo ""
|
2021-02-02 21:34:33 +00:00
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H /dev/sd$x | grep -e "SMART overall-health self-assessment test result:"
|
2021-02-02 14:51:43 +00:00
|
|
|
echo ""
|
2021-02-05 15:42:55 +00:00
|
|
|
smartctl -A /dev/sd$x | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Current_Pending_Sector:" -e "Offline_Uncorrectable:" -e "Raw_Read_Error_Rate:" -e "Seek_Error_Rate:" -e "Spin_Retry_Count:" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect" -e "FAILING_NOW"
|
2021-01-23 20:35:30 +00:00
|
|
|
echo "-------------------------------------------------"
|
2021-01-24 02:28:09 +00:00
|
|
|
else
|
|
|
|
exit
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
|
|
|
done
|
2021-01-24 01:30:07 +00:00
|
|
|
if [[ -z $(ls /dev | grep nvme) ]];then
|
|
|
|
exit
|
|
|
|
fi
|
2021-01-23 23:42:16 +00:00
|
|
|
fi
|
2021-01-23 20:35:30 +00:00
|
|
|
if [[ -n $(ls /dev | grep nvme) ]];then
|
|
|
|
echo "=== nvme drive check: ==="
|
2021-02-10 12:07:46 +00:00
|
|
|
echo "-------------------------"
|
2021-03-05 16:38:07 +00:00
|
|
|
echo "$(ls -l /sys/block | grep nvme | wc -l) Drives found"
|
2021-02-10 12:07:46 +00:00
|
|
|
echo "-------------------------"
|
2021-01-23 20:35:30 +00:00
|
|
|
for x in {0..4};do
|
|
|
|
scan=$(smartctl --scan)
|
|
|
|
if [[ -n $(echo $scan | grep /dev/nvme$x) ]];then
|
|
|
|
echo "------------------- /dev/nvme$x --------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
smartctl -i /dev/nvme$x | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate" -e "Model Number:" -e "Total NVM Capacity:" -e "Namespace 1 Utilization"
|
2021-02-02 12:38:45 +00:00
|
|
|
echo ""
|
2021-02-02 21:34:33 +00:00
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H /dev/nvme$x | grep -e "SMART overall-health self-assessment test result:"
|
2021-02-02 14:51:43 +00:00
|
|
|
echo ""
|
2021-02-05 15:31:31 +00:00
|
|
|
smartctl -A /dev/nvme$x | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect" -e "Temperature:" -e "Percentage Used:" -e "Data Units Read:" -e "Data Units Written:" -e "Power on Hours:" -e "Power Cycles:" -e "Media and Data Integrity Errors:" -e "Error Information Log Entries:" -e "Error Information" -e "No Errors Logged" -e "FAILING_NOW"
|
2021-01-23 20:35:30 +00:00
|
|
|
echo "---------------------------------------------------"
|
|
|
|
fi
|
|
|
|
done
|
2021-01-24 01:30:07 +00:00
|
|
|
if [[ -z $(ls /dev | grep sd) ]];then
|
|
|
|
exit
|
|
|
|
fi
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
2021-03-05 16:38:07 +00:00
|
|
|
if [[ -n $(ls /sys/block | grep nvme) ]] || [[ -n $(ls /sys/block | grep sd) ]] || [[ ! "$raidcheck" =~ "3ware" ]] && [[ "$raidcheck" =~ "adaptec" ]] && [[ "$raidcheck" =~ "lsi" ]] && [[ -n $(ls /sys/block | grep sd) ]] && [[ -n $(ls /dev | grep nvme) ]];then
|
2021-01-24 01:30:07 +00:00
|
|
|
echo "no drives detected"
|
2021-01-23 23:42:16 +00:00
|
|
|
exit
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
2021-01-24 22:36:32 +00:00
|
|
|
elif [[ -n $(echo "$raidcheck" | grep -e "3Ware") ]];then
|
2021-01-23 20:35:30 +00:00
|
|
|
echo "3ware raid-controller detected"
|
|
|
|
dreiware=$(tw_cli show | grep c | cut -c -3)
|
|
|
|
echo "------------------- 3ware controller: $dreiware --------------------"
|
|
|
|
tw_cli /$dreiware show
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
dreiwareversion=$(ls /dev/ | grep t)
|
|
|
|
if [[ -n $(echo $dreiwareversion | grep twe0) ]];then
|
|
|
|
echo "6000/7000/8000 series controller detected"
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
dreiwaredrives=$(tw_cli /$dreiware show | grep p | cut -c -3)
|
|
|
|
echo "=== sata drive check: ==="
|
|
|
|
for x in {0..20};do
|
|
|
|
if [[ -n $(echo $dreiwaredrives | grep p$x) ]];then
|
|
|
|
echo "------------------- p$x --------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
smartctl -i -d 3ware,p$x /dev/twe0 | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate"
|
2021-02-03 15:41:02 +00:00
|
|
|
echo ""
|
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H -d 3ware,p$x /dev/twe0 | grep -e "SMART overall-health self-assessment test result:"
|
|
|
|
echo ""
|
|
|
|
smartctl -A -d 3ware,p$x /dev/twe0 | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect"
|
2021-01-23 20:35:30 +00:00
|
|
|
echo "-------------------------------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
else
|
|
|
|
exit
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
elif [[ -n $(echo $dreiwareversion | grep twa0) ]];then
|
|
|
|
echo "9000 series controller detected"
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
dreiwaredrives=$(tw_cli /$dreiware show | grep p | cut -c -3)
|
|
|
|
echo "=== sata drive check: ==="
|
|
|
|
for x in {0..20};do
|
|
|
|
if [[ -n $(echo $dreiwaredrives | grep p$x) ]];then
|
|
|
|
echo "------------------- p$x --------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
smartctl -i -d 3ware,p$x /dev/twa0 | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate"
|
2021-02-03 15:41:02 +00:00
|
|
|
echo ""
|
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H -d 3ware,p$x /dev/twa0 | grep -e "SMART overall-health self-assessment test result:"
|
|
|
|
echo ""
|
|
|
|
smartctl -A -d 3ware,p$x /dev/twa0 | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect"
|
2021-01-23 20:35:30 +00:00
|
|
|
echo "-------------------------------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
else
|
|
|
|
exit
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
elif [[ -n $(echo $dreiwareversion | grep twl0) ]];then
|
|
|
|
echo "9750 series controller detected"
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
dreiwaredrives=$(tw_cli /$dreiware show | grep p | cut -c -3)
|
|
|
|
echo "=== sata drive check: ==="
|
|
|
|
for x in {0..20};do
|
|
|
|
if [[ -n $(echo $dreiwaredrives | grep p$x) ]];then
|
|
|
|
echo "------------------- p$x --------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
smartctl -i -d 3ware,p$x /dev/twl0 | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate"
|
2021-02-03 15:41:02 +00:00
|
|
|
echo ""
|
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H -d 3ware,p$x /dev/twl0 | grep -e "SMART overall-health self-assessment test result:"
|
|
|
|
echo ""
|
|
|
|
smartctl -A -d 3ware,p$x /dev/twl0 | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect"
|
2021-01-23 20:35:30 +00:00
|
|
|
echo "-------------------------------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
else
|
|
|
|
exit
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "reading smart values for this controller series is not supported"
|
|
|
|
exit
|
|
|
|
fi
|
2021-01-24 22:36:32 +00:00
|
|
|
elif [[ -n $(echo "$raidcheck" | grep -e "Adaptec") ]];then
|
2021-01-24 01:30:07 +00:00
|
|
|
echo "adaptec raid-controller detected"
|
2021-02-10 12:01:51 +00:00
|
|
|
echo "--------------------- adaptec controller ----------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
arcconf GETCONFIG 1 LD
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
echo "=== sata drive check: ==="
|
2021-02-03 15:41:02 +00:00
|
|
|
echo "-------------------------------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
arcconf getconfig 1 pd|egrep "Device #|State\>|Reported Location|Reported Channel|S.M.A.R.T. warnings"
|
|
|
|
echo "-------------------------------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
echo "show all smart values? (y/N)"
|
|
|
|
read yn
|
|
|
|
if [[ $yn == "y" ]] || [[ $yn == "Y" ]] || [[ $yn == "yes" ]];then
|
2021-01-24 01:30:07 +00:00
|
|
|
for x in {1..20};do
|
|
|
|
if [[ -n $(echo $dreiwaredrives | grep p$x) ]];then
|
|
|
|
echo "------------------- sg$x --------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
smartctl -i -d sat /dev/sg$x | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate"
|
2021-02-03 15:41:02 +00:00
|
|
|
echo ""
|
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H -d sat /dev/sg$x | grep -e "SMART overall-health self-assessment test result:"
|
|
|
|
echo ""
|
|
|
|
smartctl -A -d sat /dev/sg$x | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect"
|
2021-01-24 01:30:07 +00:00
|
|
|
echo "-------------------------------------------"
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
2021-02-10 12:01:51 +00:00
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
2021-01-24 22:36:32 +00:00
|
|
|
elif [[ -n $(echo "$raidcheck" | grep -e "LSI") ]];then
|
2021-01-24 01:30:07 +00:00
|
|
|
echo "lsi raid-controller detected"
|
2021-02-10 12:01:51 +00:00
|
|
|
echo "----------------------- LSI controller ------------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
megacli -LDInfo -Lall -Aall
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
echo "=== sata drive check: ==="
|
2021-02-03 15:41:02 +00:00
|
|
|
echo "-------------------------------------------"
|
2021-01-24 01:30:07 +00:00
|
|
|
megacli -PDList -aAll | egrep "Enclosure Device ID:|Slot Number:|Inquiry Data:|Error Count:|state"
|
|
|
|
echo "-------------------------------------------"
|
2021-02-10 12:01:51 +00:00
|
|
|
echo "show all smart values? (y/N)"
|
|
|
|
read yn
|
|
|
|
if [[ $yn == "y" ]] || [[ $yn == "Y" ]] || [[ $yn == "yes" ]];then
|
|
|
|
scan=$(megacli -pdlist -a0 | grep "Device Id")
|
|
|
|
p1=$(head -n 1 $scan | cut -c 12-)
|
|
|
|
pz=$(tail -n 1 $scan | cut -c 12-)
|
|
|
|
for x in {$p1..$pz};do
|
|
|
|
if [[ -n $(echo $scan | grep -E "$x") ]];then
|
|
|
|
echo "------------------- p$x --------------------"
|
|
|
|
smartctl -i -d sat+megaraid,$x /dev/sda | grep -e "=== START OF INFORMATION SECTION ===" -e "Device Model:" -e "Serial Number:" -e "Firmware Version:" -e "User Capacity:" -e "SMART support is:" -e "Sector Size:" -e "Rotation Rate:" -e "Multi_Zone_Error_Rate"
|
|
|
|
echo ""
|
|
|
|
echo "=== START OF SELF-ASSESSMENT TEST RESULT ==="
|
|
|
|
smartctl -H -d sat+megaraid,$x /dev/sda | grep -e "SMART overall-health self-assessment test result:"
|
|
|
|
echo ""
|
|
|
|
smartctl -A -d sat+megaraid,$x /dev/sda | grep -e "=== START OF READ SMART DATA SECTION ===" -e "SMART overall-health self-assessment test result:" -e "Reallocated_Sector_Ct" -e "Power_On_Hours" -e "Temperature_Celsius" -e "Media_Wearout_Indicator" -e "Power_Cycle_Count" -e "Reported_Uncorrect"
|
|
|
|
echo "-------------------------------------------------"
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
2021-01-24 01:30:07 +00:00
|
|
|
else
|
|
|
|
exit
|
2021-01-23 20:35:30 +00:00
|
|
|
fi
|
2021-01-23 23:42:16 +00:00
|
|
|
done
|
2021-01-24 20:47:09 +00:00
|
|
|
while [ -n "$1" ]; do
|
2021-01-22 21:49:23 +00:00
|
|
|
if [[ $1 == "-u" ]] || [[ "$1" == "--update" ]];then
|
2021-01-25 15:25:12 +00:00
|
|
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/stocheck/main/hash) != $(md5sum $0 | cut -c -32) ]];then
|
2021-01-22 21:49:23 +00:00
|
|
|
wget -O $0 --quiet "https://raw.githubusercontent.com/byReqz/stocheck/main/stocheck.sh"
|
|
|
|
echo "#############################################"
|
|
|
|
echo -e "\e[4mscript has been updated to the newest version\e[0m"
|
|
|
|
echo "#############################################"
|
|
|
|
exit
|
2021-01-25 15:25:12 +00:00
|
|
|
elif [[ $(curl -s https://raw.githubusercontent.com/byReqz/stocheck/main/hash) = $(md5sum $0 | cut -c -32) ]];then
|
2021-01-22 21:49:23 +00:00
|
|
|
echo "#############################################"
|
|
|
|
echo "no newer version found"
|
|
|
|
echo "#############################################"
|
|
|
|
exit
|
|
|
|
fi
|
2021-01-22 22:02:23 +00:00
|
|
|
elif [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
|
2021-01-24 20:52:00 +00:00
|
|
|
echo "Usage: $0 (options)"
|
2021-01-22 22:02:23 +00:00
|
|
|
echo "Options:"
|
|
|
|
echo " -u/--update -- update the script"
|
|
|
|
echo " -h/--help -- show help"
|
|
|
|
exit
|
2021-01-24 20:47:09 +00:00
|
|
|
else
|
2021-01-24 20:52:00 +00:00
|
|
|
echo "Usage: $0 (options)"
|
2021-01-24 20:47:09 +00:00
|
|
|
echo "Options:"
|
|
|
|
echo " -u/--update -- update the script"
|
|
|
|
echo " -h/--help -- show help"
|
|
|
|
exit
|
2021-01-22 21:49:23 +00:00
|
|
|
fi
|
2021-01-24 20:52:00 +00:00
|
|
|
done
|