*New 11.4 series Release:
2020-07-03: XigmaNAS 11.4.0.4.7633 - released!

*New 12.1 series Release:
2020-04-17: XigmaNAS 12.1.0.4.7542 - released


We really need "Your" help on XigmaNAS https://translations.launchpad.net/xigmanas translations. Please help today!

Producing and hosting XigmaNAS costs money. Please consider donating for our project so that we can continue to offer you the best.
We need your support! eg: PAYPAL

More useful disk status script

XigmaNAS Scripts and shell tips
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
User avatar
dnar
Starter
Starter
Posts: 71
Joined: 27 Apr 2013 10:38
Location: Perth Australia
Status: Offline

More useful disk status script

#1

Post by dnar »

I wrote this script to provide more useful information than is provided in the Status-Disks page.

Information provided:

1. Disk node determined via camcontrol devlist, with usb disks ignored.
2. Running state (RUNNING or STANDBY) via camcontrol (code copied from net).
3. Drive temperature via smartctl.
4. Interface speed in MB/s via camcontrol.
5. Drive run hours via smartctl.
6. Head load count via smartcrl. WD Green drives idle after 8 secs, maxing this out. See wdwidle3.exe
7. Current pending sectors via smartctl.
8. Offline uncorrectable sectors via smartctl.
9. Health assessment via smartctl.
10. Last test result via smartcl.

Sample output:

Code: Select all

$ diskstat
Sun Apr 28 16:47:52 WST 2013

-------------------------------------------------------------------------------------------------------
Disk    Disk State   Temp  MB/s  Hours  Load Count  Pending  Offline   Health   Last Test Result
-------------------------------------------------------------------------------------------------------
ada0  ++ SPINNING ++  35c  300   29029      149076        0        0   PASSED   Completed without error    
ada1  ++ SPINNING ++  37c  300   28700      135455        0        0   PASSED   Completed without error    
ada2  ++ SPINNING ++  36c  300   28765      134965        0        0   PASSED   Completed without error    
ada3  ++ SPINNING ++  39c  300    8624       31721        0        0   PASSED   Completed without error    
ada4  ++ SPINNING ++  36c  300   28740      138146        0        0   PASSED   Completed without error    
ada5  ++ SPINNING ++  37c  300   20304      100642        0        0   PASSED   Completed without error    
-------------------------------------------------------------------------------------------------------
Script:

Code: Select all

#!/bin/sh

date
echo
echo "-------------------------------------------------------------------------------------------------------"
echo "Disk    Disk State   Temp  MB/s  Hours  Load Count  Pending  Offline   Health   Last Test Result"
echo "-------------------------------------------------------------------------------------------------------"
camcontrol devlist | awk -F\( '{print $2'} | awk -F\, '{print $1}' | grep ada|while read LINE
do
	CM=$(camcontrol cmd $LINE -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10}')
	if [ "$CM" = "FF" ] ; then
		STATE="++ SPINNING ++"
	elif [ "$CM" = "00" ] ; then
		STATE="   STANDBY    "
	else
		STATE="** UNKNOWN ** "
	fi
	smartctl -a /dev/$LINE > /tmp/$LINE.txt
	BUS=`camcontrol inquiry ada0 -R | cut -f2 -d " " | cut -b1-3`
	TEMP=`grep Temperature /tmp/$LINE.txt | cut -b88-90`
        HOURS=`grep Power_On_Hours /tmp/$LINE.txt | cut -b88-99`
	PEND=`grep Pending /tmp/$LINE.txt | cut -b88-99`
	LOAD=`grep Load_Cycle_Count /tmp/$LINE.txt | cut -b88-99`
	OFFLINE=`grep Offline_Uncorrectable /tmp/$LINE.txt | cut -b88-99`
        HEALTH=`grep overall-health /tmp/$LINE.txt | cut -b51-99`
	LAST=`grep "# 1" /tmp/$LINE.txt | grep -v newer | cut -b26-51`
	printf "%-5s %-13s %3sc %4s %7s %11s %8s %8s %8s %s %s\n" $LINE "$STATE" $TEMP $BUS $HOURS $LOAD $PEND $OFFLINE $HEALTH "  $LAST"
done
echo "-------------------------------------------------------------------------------------------------------"
echo
Results returned using camcontrol will only work with AHCI drives.

Yes, my drives have a lot of reloads. I only discovered the WD Green drive issue recently and have now changed the drives to idle after 300s ( not 5s) using the WD idle tool... As a result I had loads of bad sectors, requiring me to perform a low level format with dd so the drive would resassign the Bad blocks...
NAS 1: NAS4Free 9.3.0.2 x64 embedded, Intel Core 2 E8400, 8GB, 6 x WD Green 1TB in RAIDZ2, Highpoint 2720 SAS x 8 card 6Gbps
NAS 2: NAS4Free 10.2.0.2 x64 embedded, Intel Core i3-3220, 8GB, 7 x WD Green 750GB in RAIDZ1, onboard SATA 3Gbps

Onichan
Advanced User
Advanced User
Posts: 240
Joined: 04 Jul 2012 21:41
Status: Offline

Re: More useful disk status script

#2

Post by Onichan »

So I must be missing something here, but how do I get this to execute? I pasted the script into diskstat.sh on my NAS and when I tried entering ./diskstat.sh into the prompt it says command not found. I also tried without the ./ and it gives the same error.

User avatar
dnar
Starter
Starter
Posts: 71
Joined: 27 Apr 2013 10:38
Location: Perth Australia
Status: Offline

Re: More useful disk status script

#3

Post by dnar »

What path did you install the script?
NAS 1: NAS4Free 9.3.0.2 x64 embedded, Intel Core 2 E8400, 8GB, 6 x WD Green 1TB in RAIDZ2, Highpoint 2720 SAS x 8 card 6Gbps
NAS 2: NAS4Free 10.2.0.2 x64 embedded, Intel Core i3-3220, 8GB, 7 x WD Green 750GB in RAIDZ1, onboard SATA 3Gbps

Onichan
Advanced User
Advanced User
Posts: 240
Joined: 04 Jul 2012 21:41
Status: Offline

Re: More useful disk status script

#4

Post by Onichan »

/apps/diskstat.sh
/apps is chmod -R 770

User avatar
dnar
Starter
Starter
Posts: 71
Joined: 27 Apr 2013 10:38
Location: Perth Australia
Status: Offline

Re: More useful disk status script

#5

Post by dnar »

Did you chmod +x the script? Does /apps/diskstat.sh work? I doubt /apps is in the $PATH.
NAS 1: NAS4Free 9.3.0.2 x64 embedded, Intel Core 2 E8400, 8GB, 6 x WD Green 1TB in RAIDZ2, Highpoint 2720 SAS x 8 card 6Gbps
NAS 2: NAS4Free 10.2.0.2 x64 embedded, Intel Core i3-3220, 8GB, 7 x WD Green 750GB in RAIDZ1, onboard SATA 3Gbps

User avatar
raulfg3
Site Admin
Site Admin
Posts: 5119
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: More useful disk status script

#6

Post by raulfg3 »

copy script to /usr/local/sbin , must work
12.0.0.4 (revision 6766)+OBI on SUPERMICRO X8SIL-F 8GB of ECC RAM, 12x3TB disk in 3 vdev in RaidZ1 = 32TB Raw size only 22TB usable

Wiki
Last changes

HP T510

Onichan
Advanced User
Advanced User
Posts: 240
Joined: 04 Jul 2012 21:41
Status: Offline

Re: More useful disk status script

#7

Post by Onichan »

I tried both of those things and I just deleted it and recreated it. Now it executes with ./diskstat.sh so it seems like I missed up the first time I pasted it. Though when I run it I don't get any disk information. When I run camcontrol devlist I get
<ATA WDC WD30EZRX-00M 0A80> at scbus0 target 0 lun 0 (pass0,da0)
<ATA WDC WD30EZRX-00M 0A80> at scbus0 target 1 lun 0 (pass1,da1)
<ATA WDC WD30EZRX-00M 0A80> at scbus0 target 2 lun 0 (pass2,da2)
<ATA WDC WD30EZRX-00M 0A80> at scbus0 target 3 lun 0 (pass3,da3)
<ATA WDC WD30EZRX-00M 0A80> at scbus0 target 4 lun 0 (pass4,da4)
<ATA WDC WD30EZRX-00M 0A80> at scbus0 target 5 lun 0 (pass5,da5)
<ATA WDC WD30EFRX-68A 0A80> at scbus0 target 8 lun 0 (pass6,da6)
<ATA WDC WD30EFRX-68A 0A80> at scbus0 target 9 lun 0 (pass7,da7)
<ATA WDC WD15EADS-00S 0A01> at scbus1 target 0 lun 0 (pass8,da8)
<ATA WDC WD15EADS-00W 0A01> at scbus1 target 1 lun 0 (pass9,da9)
<ATA WDC WD15EADS-00P 0A01> at scbus1 target 2 lun 0 (pass10,da10)
<ATA WDC WD15EADS-00P 0A01> at scbus1 target 3 lun 0 (pass11,da11)
<ATA WDC WD30EFRX-68A 0A80> at scbus1 target 4 lun 0 (pass12,da12)
<ATA WDC WD30EFRX-68A 0A80> at scbus1 target 5 lun 0 (pass13,da13)
<ATA WDC WD30EFRX-68A 0A80> at scbus1 target 6 lun 0 (pass14,da14)
<ATA WDC WD30EFRX-68A 0A80> at scbus1 target 7 lun 0 (pass15,da15)
So it should work, but doesn't look like the script accounts for da instead of ada. I tried changing the variables myself and after I run it then I just got two lines
camcontrol: error sending command
da16 ** UNKNOWN ** 600c
So it seems like some of the commands aren't supported.

User avatar
dnar
Starter
Starter
Posts: 71
Joined: 27 Apr 2013 10:38
Location: Perth Australia
Status: Offline

Re: More useful disk status script

#8

Post by dnar »

Try replacing ada to da in the camcontrol line.
NAS 1: NAS4Free 9.3.0.2 x64 embedded, Intel Core 2 E8400, 8GB, 6 x WD Green 1TB in RAIDZ2, Highpoint 2720 SAS x 8 card 6Gbps
NAS 2: NAS4Free 10.2.0.2 x64 embedded, Intel Core i3-3220, 8GB, 7 x WD Green 750GB in RAIDZ1, onboard SATA 3Gbps

Onichan
Advanced User
Advanced User
Posts: 240
Joined: 04 Jul 2012 21:41
Status: Offline

Re: More useful disk status script

#9

Post by Onichan »

I did, that's how I got the error I previously posted. I replaced both instances of ada with da.

rampie
NewUser
NewUser
Posts: 13
Joined: 12 Jun 2013 12:03
Status: Offline

Re: More useful disk status script

#10

Post by rampie »

I just tried this script and all i get is

---------------------------------------------------------------------------------------------------------------
Disk Disk State Temp MB/s Hours Load Count Pending Offline Health Last Test Result
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------

when i execute camcontrol devlist the result is

<ST31000520AS CC32> at scbus0 target 1 lun 0 (ada0,pass0)
<WDC WD1002FAEX-00Z3A0 05.01D05> at scbus1 target 0 lun 0 (ada1,pass1)
<SAMSUNG HD103SI 1AG01118> at scbus1 target 1 lun 0 (ada2,pass2)
<Hitachi HDS723020BLA642 MN6OA5Q0> at scbus2 target 0 lun 0 (ada3,pass3)
<Ut165 USB2FlashStorage 0.00> at scbus5 target 0 lun 0 (pass4,da0)

What can i do about this?

Post Reply

Return to “Scripts and shell tips”