The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > SUN Solaris
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-07-2008
Tornado's Avatar
Tornado Tornado is offline
Registered User
 

Join Date: Nov 2006
Location: Melbourne
Posts: 240
Quote:
Originally Posted by itik View Post
how do you configure this for email alert that will send to your email or pager?

how do you query for the current error on the log so that I could capture and send it to the email system?

Thanks in advance,
itik
Write a script to look through /var/adm/messages which is where most errors go to.
You could use the comm command in your script

Here's a copy of one of my scripts to look at errors from a 3510 array.

Code:
#Minute (0-59),
#|      Hour (0-23),
#|      |       Day of the month (1-31),
#|      |       |       Month of the year (1-12),
#|      |       |       |       Day of the week (0-6 with 0=Sunday).
#|      |       |       |       |       Commands
#|      |       |       |       |       |
#------------------------------------------------------------------------------------------------------
#
# Script to monitor 3510 events
00      7,12,17 *       *       *       /ops/p_admin/utils/chk3510 > /dev/null 2>&1
Code:
#! /bin/sh
#
# Goran Cvetanoski
#
# chk3510
#
# This script will send an email if any 3510 events have occured since the
# last time it was run
#
# CHANGE LOG
# =========================================================================
# 20/2/2007 - Goran Base script created
#

LOG=/var/adm/3510-events-email
LOG1=/var/adm/3510-events
LOG2=/var/adm/3510-events-new

DEV=`sccli -l | awk '{print $1}'`

NOTIFY=unix.admin@xxxx.xxxx.com

DASHES="--------------------------------"

show()
{
        echo "$DASHES $1 $DASHES" >> $LOG
        echo "" >> $LOG
        shift
        eval "$@" >> $LOG
        echo "" >> $LOG
}

scriptargs()
{
        echo "Date:   `date`"
        echo System: `uname -a`
        echo Device: `sccli -l`
}

Footnote()
{
        echo "Other usefull information can be obtained via the sccli command run from `uname -n`."
        echo "To invoke the sccli interface, type sccli and hit return"
        echo ""
        echo "Once at the sccli> prompt valid commands are:"
        echo ""
        echo "  show battery-status [-u | --update]"
        echo "        display status of backup battery"
        echo "  show configuration [--xml | -x] [<filename>]"
        echo "        display the device's configuration or save to file"
        echo "  show disks"
        echo "        display info for array disks."
        echo "  show drive-parameters"
        echo "        display drive parameters"
        echo "  show enclosure-status"
        echo "        display the status of internal chassis components"
        echo "  show frus"
        echo "        display FRU-ID information"
        echo "  show logical-drives [<logical-drive-list>]"
        echo "        display logical drives"
        echo "  show lun-maps"
        echo "        display lun maps for host channels"
        echo "  show redundancy-mode"
        echo "        display redundancy status"
        echo "  show redundant-controller-configuration"
        echo "        display redundant controller configuration"
        echo ""
        echo "You can see the full list of available commands by typing help at the sccli> prompt"
        echo "To exit sccli and return to your shell prompt type quit"
}

SendMail()
{
        cat $LOG | mailx -s "$1" $NOTIFY
}

GetEvents()
{
        sccli $DEV show events > $1
}

cat /dev/null > $LOG
test ! -f $LOG1 && GetEvents $LOG1
GetEvents $LOG2

show "`uname -n` 3510 Status" scriptargs
show "Event Log" comm -13 $LOG1 $LOG2
show "Write policy" sccli $DEV show cache-parameters
show "Additional Information" Footnote

if [ "`comm -13 $LOG1 $LOG2`" != "" ]
        then
            SendMail "`uname -n` 3510 Events"
fi

mv $LOG2 $LOG1
exit 0
Reply With Quote