Hi Guys,
I have small dilemma which I could do with a little help solving . I currently have text HDD S.M.A.R.T report which I have pasted below:
smartctl 5.39 2008-10-24 22:33 [i686-suse-linux-gnu] (openSUSE RPM)
Copyright (C) 2002-8 by Bruce Allen, http://smartmontools.sourceforge.net
Device: COMPAQ BD036635C5 Version: B020
Serial number: 38322209 0123
Device type: disk
Local Time is: Mon Jul 26 10:46:24 2010 BST
Device supports SMART and is Enabled
Temperature Warning Enabled
SMART Health Status: OK
Current Drive Temperature: 18 C
Drive Trip Temperature: 65 C
Manufactured in week 23 of year 2001
Recommended maximum start stop count: 10000 times
Current start stop count: 209 times
Elements in grown defect list: 91
Error counter log:
Errors Corrected by Total Correction Gigabytes Total
ECC rereads/ errors algorithm processed uncorrected
fast | delayed rewrites corrected invocations [10^9 bytes] errors
read: 0 906 155 60 0 38098.027 95
write: 0 109 0 0 0 1017.565 0
verify: 0 0 0 0 0 36.420 0
Non-medium error count: 258
SMART Self-test log
Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
Description number (hours)
# 1 Background short Interrupted (bus reset ?) 2 22862 - [- - -]
# 2 Background short Failed in segment --> 3 22841 3525970 [0x4 0x15 0x1]
# 3 Background short Failed in segment --> 3 22838 1818820 [0x4 0x15 0x1]
# 4 Background short Failed in segment --> 3 22809 519934 [0x4 0x15 0x1]
Long (extended) Self Test duration: 2070 seconds [34.5 minutes]
Short Background Self Test has
I have written a small script to extract the few fields at the top of the report as show below which eventually gets saved as to a CSV file so I can import it into my database:
BEGIN {
FS="[:]"
}
$1 ~ /^Device$/ {device = $2 $3}
$1 ~ /^Serial number$/ {ser = $NF}
$1 ~ /Device type$/ {devt = $NF}
$1 ~ /^Transport protocol$/ {tranp = $NF}
$1 ~ /^Local Time is$/ {time = $2 $3 $4}
$1 ~ /^SMART Health Status$/ {smrtstat = $NF}
$1 ~ /^Elements in grown defect list$/ {glist = $2}
END {print device "," ser "," devt "," tranp "," time "," smrtstat "," glist "," readeccf "," readeccd "," readrereadrewt "," readtoterrcorrec "," readcoralginvocat "," readgigpro "," readtotuncorerr "," writeeccf "," writeeccd "," writerewriterewt "," writetoterrcorrec "," writecoralginvocat "," writegigpro "," writetotuncorerr; exit}
This extracts the desired fields perfectly but.... I don't just want these feilds. My trouble starts when I begin to try and extract the data in the fields "read:" & "write:". I'm trying to extract the 7 columns individually so they appear in me csv file as
device, serial, etc.....0, 906, 155, 60, 0, 38098.027, 95.....
My problem seems to be that my field separator is set to a ":" and these fields are separated by blank space. Can I get awk to change the Fields Separator half way through my script? I'm a bit of a newbie to this but I'm picking it up pretty quick.
Any help would be gratefully appreciated.
Thanks
bb