Victor Feng, December 2007 (Updated February 2008)
Introduction
As system administrators, most of us check the system logs daily. If you have 10 systems, that is a lot of work. This article provides three scripts
for automating system checks on systems that run the Solaris 8, 9, or 10 Operating System:
The checkmessages script check the logs. If anything wrong is found, the script sends email to the system administrator. This
script should be scheduled to run daily using cron.
The checkpatch script (updated February 2008) checks for newly available patches for the system. I recommend that it, too, should be run daily. The checkpatch script uses a free tool from the community, the Patch Check Advanced (PCA) tool.
In each message generated by syslog, the 5th through the 10th characters specify the date on which the message was received
using the format <mmm dd>, for example, Nov 13. So the following script line checks
only for messages with today's date, which is what we want because the script will be scheduled to run daily and we do not want to be notified
about messages from previous days.
grep \"^`date|cut -c5-10`\" /var/adm/messages
The script checks messages with a severity level above "warning." Some messages are for well-known problems and can be ignored.
For example, on systems that run Solaris Volume Manager, the message forceload of misc/md_trans failed is generated.
The following script lines cause this message and No proxy found messages to be ignored. You can add additional lines to ignore
other messages.
The script's eval command in the if eval "$GREP" > /tmp/seriousmessages.txt line is necessary.
When the day is a single digit, for example, Nov 9, the output of $GREP is as follows:
grep "^Nov 9" /var/adm/messages
This output has only one space between "Nov" and "9," but there are two spaces between the month and the day for messages in
/var/adm/messages, which means that no messages will be found. Adding eval solves this problem.
Finally, you need to use cron to run the script late at night. For example, the following schedules the script to be run
at one minute before midnight:
59 23 * * * /home/<username>/bin/checkmessages
Maybe your system logs messages to other files, too. If so, you can check your /etc/syslog.conf file and modify the
script to fit your own needs.
Some new patches might be not related to your system. If you do not want to be notified about them again, you can add them to the script using lines
similar to the following:
After you patch your systems, you should remove such lines from the script so that you are notified if new, related patches become available.
The checkpatch script checks security patches. But you can modify the script to check for all available patches by
changing missings to missing.
Again, you can use cron to run the script daily.
The checkdisk Script
Although all disk errors are recorded in /var/adm/messages, you might want to use the checkdisk
script to keep an eye out for disk failure prediction messages. As before, you can use cron to run the script daily.
Comments (latest comments first)
Discuss and comment on this resource in the BigAdmin Wiki
Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.