I realise this is a very old thread, but I am in the early stages of writing a pure Go library for reading SMART attributes from HDDs / SSDs. So far it works for simple SCSI block devices (i.e., those that have a sd* device name) via SCSI pass-through, and I am in the process of adding support for devices attached to MegaRAID controllers.
You can find the code at https://github.com/dswarbrick/smart On Friday, March 23, 2012 at 12:15:16 PM UTC+1, Jeff R. Allen wrote: > > > > On Thursday, March 22, 2012 4:59:09 PM UTC+1, minux wrote: >> >> you can strace(1) the command line app and find out how to read these >> data. >> > > Out of curiosity, I did just that, and I found that smartctl is using > ioctl SG_IO to do SCSI Generic commands on the device: > > 4602 ioctl(3, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[*12, 00, 00, 00, > 24, 00*], mx_sb_len=32, iovec_count=0, dxfer_len=36, timeout=20000, > flags=0, data[36]=["*\0\0\5\2[\0\0\0ATA TOSHIBA THNSNC12*"...], > status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, > resid=0, duration=0, info=0}) = 0 > > (The request and reply are emboldened.) > > You can see an example of how to access ioctl from Go in the exp/terminal > package: > http://code.google.com/p/go/source/browse/src/pkg/exp/terminal/util.go > > If you want to make this portable, you'll need to think about making a > package in Go that can do SCSI Generic commands, hiding the > platform-dependent parts inside of it. Take a look at the source to the net > package to see how to make one Go package that's got OS-dependent > implementations of the same external API. > > Then you can use your new package to talk S.M.A.R.T. with your device. > > I think that project would be a very good fit for Go; at the low levels, > you need control of the bits to do the ioctl, and once you get the data, > you have all the niceities of Go to transform it, store it in a database, > graph it, etc. Go for it! > > -jeff > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
