Tag Archives: reporting

Weekly errata Report for YUM based machines

I had a request the other day at the Utah Open Source Conference to share a very small script that I have that checks for, and reports any available updates on a YUM based machine. This means CentOS, RHEL, Fedora, etc. I have been using this script at work for some time now and, by placing it in the /etc/cron.weekly/ directory, it reports to me on what packages are available for update. I find this to be a simpler solution than manually checking and trying to keep on top of all of my machines all the time.

I have outlined two revisions of this script below. The first one has properly formatted reports, the second one only reports if there are available updates. I would like to combine the functionality, but I’ve only briefly looked at doing so.. and I don’t feel like doing it now.

If anyone has any other solutions, or perhaps an official program with the same functionality I’d love to hear about it.

/etc/cron.weekly/check-update.sh – revision #1

#!/bin/bash
#
# Weekly check-update report
#
usr/bin/yum check-update > /tmp/.check-update
cat /tmp/.check-update | mail -s "Errata Report for $(hostname)" admin@example.com

/etc/cron.weekly/check-update.sh – revision #2

#!/bin/bash
#
# Weekly check-update report
#
MESSAGE=$(/usr/bin/yum check-update)
if [ $? -eq 100 ]; then
echo ${MESSAGE} | mail -s "Errata Report for $(hostname)" admin@example.com
fi

Monitor System Logs With Logwatch

I mentioned in a recent post regarding postfix smtp via Gmail that I use the logwatch utility for monitoring my systems.  Ever since I found this utility I have really enjoyed the daily snapshot that it gives me of each of my systems, whether local or remote.  Everything from package installed and removed, to security notifications regarding unsuccessful login attempts.  Here’s how to install and configure Logwatch.

Install The Package

sudo aptitude install logwatch

Configuration

The default configuration can be found in /usr/share/logwatch/default.conf/logwatch.conf.  Take a look around the file, but the main thing you might want to update:

MailTo = root updates to MailTo = user.name@domain.tld

I have my systems email me daily at my gmail address, so each morning I get an overview of the previous days logs.

If you have problems with the mail actually getting out you might want to check out my post regarding Postfix smtp via Gmail.