LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-04-2007, 08:07 PM   #1
blu_alchemist
Member
 
Registered: Jun 2007
Location: Canada
Distribution: Fedora Core 7
Posts: 31

Rep: Reputation: 15
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!!

Thanks
--Blu
 
Old 06-05-2007, 01:02 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
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:
Code:
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).
 
Old 06-05-2007, 05:00 PM   #3
blu_alchemist
Member
 
Registered: Jun 2007
Location: Canada
Distribution: Fedora Core 7
Posts: 31

Original Poster
Rep: Reputation: 15
Sweet

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!
--blu
 
Old 06-05-2007, 05:22 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
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:

Code:
   #------------------------
   # Motherboard temperature
   #------------------------
   if [ -f /sys/bus/i2c/devices/9191-0290/temp1_input ]
   then
      temp=`/bin/cat /sys/bus/i2c/devices/9191-0290/temp1_input`
      left=${temp:0:2}
      right=${temp:2:3}
      MBtemp=${left}.${right}
   else
      MBtemp="0"
   fi

   #----------------
   # CPU temperature
   #----------------
   if [ -f /sys/bus/i2c/devices/9191-0290/temp2_input ]
   then
      temp=`/bin/cat /sys/bus/i2c/devices/9191-0290/temp2_input`
      left=${temp:0:2}
      right=${temp:2:3}
      CPUtemp=${left}.${right}
   else
      CPUtemp="0"
   fi

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

   #--------------------
   # 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/temperature.log.new
   /bin/mv -f /dev/shm/temperature.log.new /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
 
Old 06-06-2007, 02:03 AM   #5
blu_alchemist
Member
 
Registered: Jun 2007
Location: Canada
Distribution: Fedora Core 7
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks

Works great,

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

random question, any idea how to rectify this error:

Code:
# /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.
 
Old 06-06-2007, 07:33 AM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
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...
 
Old 06-07-2007, 09:25 AM   #7
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
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?
 
Old 06-07-2007, 10:33 AM   #8
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

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

Code:
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:

Code:
echo "`/bin/date` $MBtemp $CPUtemp $HDA $HDG" >> /var/log/temperature.log
This appends the collected timestamped data to the temperature.log file.
 
Old 06-07-2007, 03:38 PM   #9
blu_alchemist
Member
 
Registered: Jun 2007
Location: Canada
Distribution: Fedora Core 7
Posts: 31

Original Poster
Rep: Reputation: 15
Yup

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:

Code:
#HDD Temps - */1 means run every whole min
*/1 * * * * root (nice -15 /root/smart_temps.sh)
/root/smart_temps.sh 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.
 
Old 06-07-2007, 03:52 PM   #10
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
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:

Code:
#------------------------
# 6hr updates 60s samples
# = 360 samples
#------------------------
/usr/bin/tail -n 360 /var/log/temperature-6hr.log > /dev/shm/temperature.log.new
/bin/mv -f /dev/shm/temperature.log.new /var/log/temperature-6hr.log
You would then plot the '/var/log/temperature-6hr.log' for your 6hr graph. Similarly:

Code:
#---------------------------
# 30day updates 3hrs samples
# = 240 samples
#---------------------------
/usr/bin/tail -n 240 /var/log/temperature-30day.log > /dev/shm/temperature.log.new
/bin/mv -f /dev/shm/temperature.log.new /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.
 
Old 06-07-2007, 04:26 PM   #11
blu_alchemist
Member
 
Registered: Jun 2007
Location: Canada
Distribution: Fedora Core 7
Posts: 31

Original Poster
Rep: Reputation: 15
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:
Code:
root:x:0:root
~~~~~~~~
3710:x:100:
blu:x:500:
mike:x:501:
www-data:x:502:
/etc/passwd:
Code:
root:x:0:100:root:/root:/bin/bash
~~~~~~~~~~~~~~
blu:x:500:100::/home/blu:/bin/bash
mike:x:501:100::/home/mike:/bin/bash
www-data:x:33:100::/home/www-data:/sbin/nologin
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?
 
Old 06-08-2007, 01:05 AM   #12
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
Ahhh, so that is the trick. I was digging in the smartd.conf man page with no luck (have been doing that for months ). 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 .
 
Old 06-08-2007, 01:26 AM   #13
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 326Reputation: 326Reputation: 326Reputation: 326
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.
 
  


Reply

Tags
smart


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free web based control panel for web hosting? mooman_fl Linux - Software 0 06-18-2004 05:16 PM
from a gui-based s/w to a web-based app h/w Programming 0 04-13-2004 02:07 PM
web based email thesnaggle Linux - Newbie 4 09-26-2003 12:06 PM
Web Based Mail !!!! chuck77 Linux - General 3 02-25-2002 03:33 PM
Web Based Firewall karunesh Linux - General 1 02-14-2002 06:02 AM


All times are GMT -5. The time now is 10:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration