-   Linux - Software (
-   -   S.M.A.R.T - Web Based Reports (

blu_alchemist 06-04-2007 09:07 PM

S.M.A.R.T - Web Based Reports
Hello All,

I have a fileserver running: All in a LVM2 array, works beautifully even tho its in the closet.
2 x 500gig sata
2 x 320gig sata

My question is their an easy way to through known programs to provide me with a basic webpage that displays say an hourly, day/month harddrive temperature graph??

I know i can use a basic LAMP setup and webmin to achieve this but thats way to much bloat for such a simple task. Currently i have a cron job dumping the temps into an xml file (very, very dirty method due to bad scripting) but still have no method of graphing it nicely even through xls sheets.

Any smart utilities, miniwebservers, mods, you guys think will help lemme know!!


macemoneta 06-05-2007 02:02 PM

I use gnuplot executed after each data collection for this:

Command: /usr/bin/gnuplot /usr/local/bin/HDtemperatureplot.parms &>/dev/null

The HDtemperatureplot.parms file:

set terminal png medium
set grid xtics ytics
set output '/var/www/html/HDtemperature-temp.png'
set title "Hard Drive Temperature (bezier smoothed) - last 72 hours";
set xlabel "" 0.000000,0.000000 font "";
set xtics 43200
set mytics 10
set ylabel "Degrees Centigrade" 0.000000,0.000000 font ""
set yrange [25:55]
set xdata time;
set timefmt x "%b %d %H:%M:%S"
set key on outside below
set size 1.5,1.5
set rmargin 5
plot  "</bin/cat /var/log/temperature.log | /bin/awk '{print $2,$3,$4,$9}'" using 1:4 smooth bezier with linespoints t 'HDA', \
      "</bin/cat /var/log/temperature.log | /bin/awk '{print $2,$3,$4,$10}'" using 1:4 smooth bezier with linespoints t 'HDG';

The resulting graph is on the web page, here (HD temps are near the bottom).

blu_alchemist 06-05-2007 06:00 PM

Thanks man!

Gnuplot in itself is pretty awsome.

I have not installed it yet as im changing cases and doing general os cleanup but how are you generating your /var/log/temperature.log?

Currently im using awk via cron to poll the 'smartctl -A /dev/sda' to grab the temps and >> to a logfile but polling 6 drives as of today is not very efficiant.

Thanks again!

macemoneta 06-05-2007 06:22 PM

Pretty much the same. I run the following code section in a minimal priority continuous process that sleeps between iterations, yielding about one sample every 15 seconds:


  # Motherboard temperature
  if [ -f /sys/bus/i2c/devices/9191-0290/temp1_input ]
      temp=`/bin/cat /sys/bus/i2c/devices/9191-0290/temp1_input`

  # CPU temperature
  if [ -f /sys/bus/i2c/devices/9191-0290/temp2_input ]
      temp=`/bin/cat /sys/bus/i2c/devices/9191-0290/temp2_input`

  # Drives
  HDA=`/usr/sbin/smartctl -A /dev/hda 2>&1 | /bin/grep "^194" | /bin/awk '{print $10}'`
  if [ "$HDA" == "" ]
  HDG=`/usr/sbin/smartctl -A /dev/hdg 2>&1 | /bin/grep "^194" | /bin/awk '{print $10}'`
  if [ "$HDG" == "" ]

  # Update the log file
  echo "`/bin/date` $MBtemp $CPUtemp $HDA $HDG" >> /var/log/temperature.log

  # Trim log to most recent 72 hours
  /usr/bin/tail -n 17280 /var/log/temperature.log > /dev/shm/
  /bin/mv -f /dev/shm/ /var/log/temperature.log

  # Plot the motherboard and CPU temperature data
  /usr/bin/gnuplot /usr/local/bin/temperatureplot.parms &>/dev/null
  /bin/mv -f /var/www/html/temperature-temp.png /var/www/html/temperature.png

  # Plot the temperature data for the hard drives
  /usr/bin/gnuplot /usr/local/bin/HDtemperatureplot.parms &>/dev/null
  /bin/mv -f /var/www/html/HDtemperature-temp.png /var/www/html/HDtemperature.png

blu_alchemist 06-06-2007 03:03 AM

Works great,

I totally forgot i could run scripts as 'nice' lol

random question, any idea how to rectify this error:


# /etc/init.d/smb start
audit(1181134028.841:1624): avc: denied { append } for pid=8237 comm="smbd" name="log.smbd" dev=sda2 ino=643509 scontext=root:system_r:smbd_t:s0 tcontext=root:object_r:var_log_t:s0 tclass=file

I just installed FC7 from FC6 and have never seen an error like this b4... and SELinux is disabled.

macemoneta 06-06-2007 08:33 AM

If you are logging audits, then SELinux is not disabled. It could be in permissive mode, which means that it is logging audits (but not preventing anything). If you ever did disable SELinux, the entire filesystem needs to be relabled. The setroubleshoot package should be installed (if not install it); it will provide you with an explanation for any SELinux errors along with suggested corrective action.

Since this is a completely unrelated issue, I suggestion you open a new thread for it; I doubt people with SELinux expertise will be checking a SMART thread...

JZL240I-U 06-07-2007 10:25 AM

I realize this is a stupid question, but I simply could not find out how to redirect the smart output to something like "/var/log/temperature.log" in stead of /var/log/messages. How do you do that? :scratch:

macemoneta 06-07-2007 11:33 AM

If you look in the code above, you'll see:


HDA=`/usr/sbin/smartctl -A /dev/hda 2>&1 | /bin/grep "^194" | /bin/awk '{print $10}'`
This places the temperature from the smartctl command into variable HDA. Other variables are similarly populated. Later in the code:


echo "`/bin/date` $MBtemp $CPUtemp $HDA $HDG" >> /var/log/temperature.log
This appends the collected timestamped data to the temperature.log file.

blu_alchemist 06-07-2007 04:38 PM

My script looks exactly like his above except I required the "-T permissive" option on all my sataII seagate drives because they fail one of the smart commands. no idea why but it works and im happy.

To get the script to run every 60 seconds I placed this line into my /etc/crontab:


#HDD Temps - */1 means run every whole min
*/1 * * * * root (nice -15 /root/

/root/ is the file thats has the $HDA variables and dumps the /var/log/temperatures file.

I have a question for you macemoneta, i was playing around with the .parm file and wow could i mess stuff up, I have the colors, lables, and graph looking as i want it but the scale for time on the x axis is terriblely irratic. My temperatures file is being updated every 60 seconds and I want a graph for 6hrs, 24hrs, 30days. (6hr updates 60s, 24hr updates 30min, 30day updates 3hrs) I have all the cron jobs to call the scripts but I just cant get that x scale to stick to 6/24/720hr scale.

Or a tutorial you reccomend as gnuplots ones are pretty weak.

macemoneta 06-07-2007 04:52 PM

The time scale of the graph was a problem for me as well (I'm no gnuplot expert). I work around it by creating multiple files with different amounts of data.

In your case, with one minute collections, you would create three files, trimming the data to the last n entries for each interval. For example:


# 6hr updates 60s samples
# = 360 samples
/usr/bin/tail -n 360 /var/log/temperature-6hr.log > /dev/shm/
/bin/mv -f /dev/shm/ /var/log/temperature-6hr.log

You would then plot the '/var/log/temperature-6hr.log' for your 6hr graph. Similarly:


# 30day updates 3hrs samples
# = 240 samples
/usr/bin/tail -n 240 /var/log/temperature-30day.log > /dev/shm/
/bin/mv -f /dev/shm/ /var/log/temperature-30day.log

The above would maintain the 30 day data for the respective graph. Since you are plotting all the data in the file(s), gnuplot calculates the range correctly.

blu_alchemist 06-07-2007 05:26 PM

Ahh I didnt think of that.... Explains why after i thought the graph looked good the next hour it was all out of wack as my main temp.log file is trimmed to 43200 entries for the 30day log and its only been like 2 days of monitoring.

Your quite knowledgeable and these forums seem to take 4 days for a reply 90% of the time hopefully you can give me some advice.

Group management is a pain and Im not familiar with console user management, is their a text manager for users and groups that you know about?

If not my issue is I have blu:3710, mike:3710, www-data:3710, when i do 'groups blu' it says 3710 is the primary group, I even did a 'useradd -g 3710 blu' to make sure but my /etc/groups file says:




user www-data is still creating files as www-data:33 should I manual edit the files and have 3710(aka 100) as the only group for all 3 users?

JZL240I-U 06-08-2007 02:05 AM

Ahhh, so that is the trick. I was digging in the smartd.conf man page with no luck (have been doing that for months :rolleyes:). I simply overlooked the trick in your code blinded by my assumption that there was a way to redirect the logging output. Thank you, macemoneta and blu_alchemist :).

macemoneta 06-08-2007 02:26 AM

blu_alchemist: I suggest you start a new thread on the issue of managing users and groups, since it's not related to the topic of this thread. There are different tools available under different distributions; update your profile so that the folks know which distribution you're using.

All times are GMT -5. The time now is 07:46 PM.