Virtual Devices

Sep 16, 2014 at 8:43 PM
Hey everyone, just found this product today. Seems pretty interesting but I have some questions about virtual devices.

For other Windows machines it seems fairly straight forward, you run the program, share the device and everyone is happy. What about cross platform support? For example do you recommend any scripts/thresholds for smartd/smartctl on a Linux machine?

I think the most basic thing I could do is just set up a cron job for each drive, pipe the data into a file that can be read by the program, but I'm wondering if there's anything more specific that you could recommend?
Coordinator
Sep 18, 2014 at 9:09 PM
Hi,

Unfortunately I don't know how works scripts on a Linux machine; the only thing that I can suggest is to create a program (or script) that regularly launch smartctl on all devices and then save the output into a text file on a folder shared with another other computer with Windows and HDD Guardian installed.
This thing, under Windows, can be done with a simple batch file (I can make a sample, if it can be useful) and a task in Windows Task Scheduler.

Alternatively you can use GSmartControl, that works also under Linux. From what I remember it supports also virtual devices, but (at least under Windows) is not possible to use it as a background program.

Tell me if you found a solution, because can be applied also to other environments with mixed OS! ;)

Thanks,
Sam
Sep 21, 2014 at 5:59 PM
This is what I came up with.

For this example is deals with deva to devg and saves the logs with the model name and SN into /home/Shared Documents/SMART/ (which I have set up as a Samba share). It'll log the output and e-mail it as well, I'm a bit anal about that. Couldn't get the runcmd part to work but stopped caring. :P

My scriptheader is just a small script to print a nice boxed header for the log files, might as well post it here as well.

There's probably 1000 different ways you can do this better than what I've done but it works. I then put the script into my cron to be run on a regular basis.


/opt/scripts/hddguardian.sh
#! /bin/bash

fullfilename=${0##*/}
filename="${fullfilename%.*}"
logfile="/var/log/scripts/$filename.log"
email=logemail
savepath="/home/Shared Docs/SMART/"
runcmd="/usr/sbin/smartctl -a"

echo "Script output will be logged to $logfile"
logger -p syslog.info "Updating SMART attributes.  Output stored in ${savepath}"

exec > "$logfile" 2>&1

/opt/scripts/scriptheader.sh "HDD Guardian Update"

for i in {a,b,c,d,e,f,g}
        do
                read MN <<< $(sudo hdparm -I /dev/sd${i} | awk '/Model Number:/{ print $3 }')
                read SN <<< $(sudo hdparm -I /dev/sd${i} | awk '/Serial Number:/{ print $3 }')

                fullpath="${savepath}${MN}_${SN}.txt"

                sudo /usr/sbin/smartctl -a /dev/sd${i} > "${fullpath}"
done

if [[ -f ${logfile} ]]; then
        echo "Mailing log to ${email}"
        mail -s "${filename^} Log - $(date +%m-%d-%Y)" ${email} < ${logfile}
fi
/opt/scripts/scriptheader.sh
#!/bin/bash

WIDTH=49

if [[ -z $1 ]]; then
        echo "No argument supplied."
        exit 1
fi

printf "$1\n$(date +%r)\n$(date +%m-%d-%Y)" | boxes -d simple -p v1 -a c -s $WIDTH
echo ""
Marked as answer by Eruestan on 9/22/2014 at 12:05 AM