Testing Scripts
diskcheck.sh
diskcheck.sh is used to run short SMART health tests against multiple disks on a Linux server.
This script appears to have been written for server disk validation, hardware checking, or pre-deployment testing. It automates the process of starting SMART tests, waiting briefly for them to complete, and saving the collected result output under a filename based on the system product serial number.
#!/bin/bash
for ((i=1; i<=12; i++)) do
device=`lsblk |grep -A 40 sdb |awk '{print $1}' |sed -n "$i"p`
smartctl --test=short /dev/$device
done
sleep 120
serial=`ipmitool fru |grep "Product Serial" |awk '{print $4}' |head -n 1`
sh result.sh > test/"$serial".txt
The script loops through up to 12 disk entries found from lsblk output near sdb.
For each detected device, it runs:
smartctl --test=short /dev/<device>
After starting the SMART tests, the script waits for 120 seconds.
It then retrieves the server product serial number using:
ipmitool fru
Finally, it runs result.sh and saves the output to:
test/<product-serial>.txt
This script assumes a predictable server disk layout. The disk detection logic is based on parsing lsblk output around sdb, so it may need adjustment on systems with different disk naming, different drive counts, or different lsblk formatting.
The script also assumes that result.sh exists in the same working directory and that the test/ directory already exists before execution.
No comments to display
No comments to display