Fedora Linux Support Community & Resources Center
  #1  
Old 2nd January 2009, 11:04 PM
CrazyCaver Offline
Registered User
 
Join Date: Dec 2008
Posts: 73
Logwatch and hddtemp

Has anyone created a logwatch filter script for hddtemp?

I would like to have the daily log reports tell me the disk drive temperatures. I have hddtemp running and reporting to the syslog. I see its entries in /var/log/messages. Now the trick is to get logwatch to pull those lines out and report them along with all the other stuff.

I figured out how to create the .conf file, but writing the filter script is beyond my programming skills.

Thanks - Bill Gee
Reply With Quote
  #2  
Old 7th January 2009, 01:48 AM
CrazyCaver Offline
Registered User
 
Join Date: Dec 2008
Posts: 73
HOWTO - hddtemp reports from logwatch

Since no one piped up with an answer, I decided to spend a bit more time on this. It turned out to be easier than I thought, though a truly elegant solution still requires programming expertise I do not have.

-------------

The goal of this exercise is to have the hddtemp service report hard drive temperature numbers regularly to the system log, then see that information in the daily logwatch emails.

Part 1 - Setting up hddtemp

1) sudo yum install hddtemp

2) sudo gedit /etc/sysconfig/hddtemp

3) The hddtemp config file contains only one line. Make it look something like this. Be sure to use the name(s) of your actual hard drives. Also, the number after --syslog is the number of seconds between reports.

Code:
HDDTEMP_OPTIONS="--syslog=36000 -l 127.0.0.1 /dev/sda /dev/sdb /dev/sdc /dev/sdd"
4) sudo /sbin/chkconfig hddtemp on

5) sudo /etc/init.d/hddtemp start

At this point you can open the system log file /var/log/messages and scroll to the end. It should contain lines reflecting the output of hddtemp.

Part two - Logwatch configuration

1) As far as I know all Redhat distros include logwatch as part of the base system. The rest of these instructions presume that logwatch is configured and running, and that it is sending emails to somewhere you can see them.

2) Add a file /usr/share/logwatch/default.conf/services/hddtemp.conf. Here are the contents:

Code:
###########################################################################
# $Id: hddtemp.conf,v 1.0 2009/01/01
###########################################################################

# You can put comments anywhere you want to.  They are effective for the
# rest of the line.

# this is in the format of <name> = <value>.  Whitespace at the beginning
# and end of the lines is removed.  Whitespace before and after the = sign
# is removed.  Everything is case *insensitive*.

# Yes = True  = On  = 1
# No  = False = Off = 0

Title = "hddtemp"

# Which logfile group...
LogFile = messages

# Whether or not to lookup the IPs into hostnames...
# Setting this to Yes will significantly increase runtime
$named_ip_lookup = No

# Only give lines pertaining to the named service...
# *OnlyService = hddtemp
# *RemoveHeaders
*ApplyStdDate

# vi: shiftwidth=3 tabstop=3 et
3) Add a file called /usr/share/logwatch/scripts/services/hddtemp. The contents are:

Code:
#!/bin/bash

# These are the standard environment variables.  You can define
# more in your service config file (see above).
echo "Date Range: $LOGWATCH_DATE_RANGE"
echo "Detail Level: $LOGWATCH_DETAIL_LEVEL"
echo "Temp Dir: $LOGWATCH_TEMP_DIR"
echo "Debug Level: $LOGWATCH_DEBUG"

# Now take STDIN and dump it to STDOUT after finding only desired lines.
grep -i hddtemp -
4) That's it! You do not have to restart logwatch. It might be a day before you see anything come back since logwatch (in default configuration) does not report today's data until tomorrow.

The file in step 3 is a simple bash script. It can be Perl, PHP, C++ ... Whatever you want to write in. The key point is that it takes standard input, finds the lines you want and sends them to standard output.

The lines you want come from the messages log file group which is named in the file from step 2. In this case the messages group is already created by the default installation of logwatch, so you don't have to do anything more except use it.
Reply With Quote
  #3  
Old 7th January 2009, 02:03 AM
Hlingler Offline
Administrator
 
Join Date: Sep 2006
Location: Connellsville, PA, USA
Posts: 11,294
Very nice. I had looked at your question, more than once in fact, but (and I suspect that this was true for others too) it was beyond my immediate knowledge and experience - I would have had to dig into the documentation too to find an answer. Sometimes questions like these, without being technically difficult, impossible or even necessarily hard to resolve, are obscure enough that one has to end up being the pioneer and solving it oneself.

Good job, and thanks for posting the solution so others can find it (if they search...).

V
Reply With Quote
Reply

Tags
hddtemp, logwatch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logwatch reports empty!! how to debug logwatch? paul sanz Using Fedora 1 26th June 2008 10:29 AM
hddtemp ferd Using Fedora 21 1st November 2005 08:12 PM


Current GMT-time: 12:44 (Saturday, 01-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Zhengzhou Travel Photos on Instagram - Maltby Instagram Photos - Faizpur