#!/bin/sh # name: checkmessages_net # # The checkmessages_net script checks the logs on the hosts. If anything # wrong is found, the script sends email to the system administrator. # This script should be scheduled to run daily using cron. # # Described in the BigAdmin submitted tech tip: # http://www.sun.com/bigadmin/content/submitted/net_sys_autocheck.jsp # MAIL_RECEIVER= PATH=/usr/bin; export PATH # Check host01. # Check today's message above the level of warning. GREP="grep \"^`date|cut -c5-10`\" /var/adm/messages | egrep \"emerg|alert|crit|err|warning\"" # The messages to be ignored FILTER="| grep -v \"forceload of misc/md\"" FILTER="$FILTER | grep -v \"No proxy found\"" GREP="$GREP$FILTER" if eval "$GREP" > /tmp/seriousmessages.txt then mailx -s "host01 Serious Message" $MAIL_RECEIVER < /tmp/seriousmessages.txt fi # Check host02. # Use a cron job to copy the /var/adm/messages file to a shared place # before running this script. if [ -f /net/host02/report/host02_messages ] then GREP="grep \"^`date|cut -c5-10`\" /net/host02/report/host02_messages \ | egrep \"emerg|alert|crit|err|warning\"" FILTER="| grep -v \"forceload of misc/md\"" GREP="$GREP$FILTER" if eval "$GREP" > /tmp/host02_seriousmessages.txt then mailx -s "host02 Serious Message" $MAIL_RECEIVER < /tmp/host02_seriousmessages.txt fi fi # Check host03. # Use a cron job to copy the /var/adm/messages file to a shared place # before running this script. if [ -f /net/host02/report/host03_messages ] then GREP="grep \"^`date|cut -c5-10`\" /net/host02/report/host03_messages \ | egrep \"emerg|alert|crit|err|warning\"" FILTER="| grep -v \"forceload of misc/md\"" GREP="$GREP$FILTER" if eval "$GREP" > /tmp/host03_seriousmessages.txt then mailx -s "host03 Serious Message" $MAIL_RECEIVER < /tmp/host03_seriousmessages.txt fi fi ############################################################################## ### This script is submitted to BigAdmin by a user of the BigAdmin community. ### Sun Microsystems, Inc. is not responsible for the ### contents or the code enclosed. ### ### ### Copyright Sun Microsystems, Inc. ALL RIGHTS RESERVED ### Use of this software is authorized pursuant to the ### terms of the license found at ### http://www.sun.com/bigadmin/common/berkeley_license.jsp ##############################################################################