My question is a quite simple , I want to run the command smartctl -i -A on all disks that the server have.Think that I've too much server with different number of disks and RAID Controllers, then I need to scan all drivers for a diagnosis.I'm thinking of running smartctl --scan | awk '{print $1}' >> test.log, so if I open the test.log I'll have all the drives information in it.After this I need to run some if or do constructions to scan with smartctl all drivers.I don't know if this is the best way to do this, since I need to identify the RAID Controller too.Am heading in the right direction?Edit:I'm used to use these commands to troubleshoot:Without RAID Controllerfor i in {c..d}; do    echo Disk sd$i $SN $MD    smartctl -i -A /dev/sd$i |grep -E ^  5|^197|^198|FAILING_NOW|SERIALdonePERC Controllerfor i in {0..12}; do    echo $i $SN $MD    smartctl -i -A -T permissive /dev/sda -d megaraid,$i |grep -E ^  5|^197|^198|FAILING_NOW|SERIALdone/usr/sbin/megastatus physical/usr/sbin/megastatus --logical3ware Controllerfor i in {0..10}; do    echo Disk $i $SN $MD    smartctl -i -A /dev/twa0 -d 3ware,$i |grep -E ^  5|^197|^198|FAILING_NOW|SERIALdoneSmartArray & Megaraid Controler:smartctl a d cciss,0 /dev/cciss/c0d0/opt/3ware/9500/tw_cli showcd /tmpDD (Rewrite disk block (DESTROY DATA)):dd if=/dev/zero of=/dev/HD* bs=4MHD*: sda, sdbBurning (Stress test (DESTROY DATA)):/opt/systems/bin/vs-burnin --destructive --time=<hours> /tmp/burninlog.txtDmesg&kernerrors:tail /var/log/kernerrorsdmesg |grep i E ata|fault|errorSo what I'm trying to do is automate these commands.I want that the script verify all disks that the host have and run the appropriate smartctl command for the case.Something like a menu with some options that let me choose if I want to run a smartctl or some destructive command, if I choose to run smartctlthe script will scan all disks and runs the command according to the host configuration ( with / without RAID controller),and if I choose to run a destructive command, the script will ask me to put the disk number that I want to do this.Edit 2:I resolved my problem with the following script:#!/bin/bash# Troubleshoot.sh# A more elaborate version of Troubleshoot.sh.SUCCESS=0E_DB=99    # Error code for missing entry.declare -A address#       -A option declares associative array.if [ -f Troubleshoot.log ]then    rm Troubleshoot.logfiif [ -f HDs.log ]then    rm HDs.logfismartctl --scan | awk '{print $1}' >> HDs.loglspci | grep -i raid >> HDs.loggetArray (){    i=0    while read line # Read a line    do        array[i]=$line # Put it into the array        i=$(($i + 1))    done < $1}getArray HDs.logfor e in ${array[@]}do    if [[ $e =~ /dev/sd* || $e =~ /dev/hd* ]]        then            echo smartctl -i -A $e >> Troubleshoot.log            smartctl -i -A $e >> Troubleshoot.log # Run smartctl into all disks that the host have    fidoneexit $?   # In this case, exit code = 99, since that is function return.I don't know if this solution is the right or the best one, but works for me!Appreciate all help!!
Run smartctl on all disks of a server
shell script;logs;hard disk;raid;smartctl