Showing posts with label Monitoring. Show all posts
Showing posts with label Monitoring. Show all posts

Saturday, October 24, 2009

script for fmadm alerting

source: http://prefetch.net/code/fmadmnotifier

From above site I found the following script
#!/bin/bash
#
# Program: E-mail fault manager errors
#
# Author: Matty < matty91 at gmail dot com >
#
# Current Version: 1.1
#
# Revision History:
#
# Version 1.1
# Avoid the use of temporary files -- Michael Shon
#
# Version 1.0
# Initial Release
#
# Last Updated: 08-18-2006
#
# Purpose:
# Fmadm.sh queries the fault manager to see if errors have been
# generated. If an error is detected, the script will email the
# admininstrator defined in the ADMIN vairable with the error
# details.
#
# License:
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Installation:
# Copy the shell script to a suitable location
#
# Usage:
# To check for events once per hour, add a cron job similar to the following:
#
# $ crontab -l | grep fmadmnotifier.sh
# 0 * * * * /etc/scripts/fmadmnotifier.sh
#

PATH=/usr/bin:/sbin:/usr/sbin:/usr/sfw/bin

# Who to E-mail with new updates
ADMIN="root"

# Location of binaries
AWK=$(which awk)
FMADM=$(which fmadm)
HOSTNAME=$(which hostname)
MAIL=$(which mailx)
MKTEMP=$(which mktemp)

# Check to make sure the mail binary exists
if [ ! -f ${MAIL} ]
then
echo "Cannot find ${MAIL}"
exit 1
fi

# Check to make sure the fmadm utility exists
if [ ! -f ${FMADM} ]
then
echo "Cannot find ${FMADM}"
exit 1
fi

# Verify that mktemp exists
if [ ! -f ${MKTEMP} ]
then
echo "Cannot find ${MKTEMP}"
exit 1
fi

# Run fmadm faulty to check for hardware errors
FMADMOUTPUT=$(${FMADM} faulty | ${AWK} '$0 !~ /STATE/ && $0 !~ /^----/ { print $0 }')

if [ -n "${FMADMOUTPUT}" ]
then
(
echo "The fault manager detected a problem with the system hardware."
echo "The fmadm and fmdump utilities can be run to retrieve additional"
echo "details on the faults and recommended next course of action. "

echo ""
echo "fmadm faulty output:"
echo ""

${FMADM} faulty
echo ""
) | ${MAIL} -s "Hardware fault on $($HOSTNAME)" ${ADMIN}
fi

And some fmadm details:
The fmadm utilities "config" option can be used to view the list of diagnosis engines and agents that are active on a system:
i $ fmadm config
MODULE cpumem-retire disk-transport eft fmd-self-diagnosis io-retire snmp-trapgen sysevent-transport syslog-msgs zfs-diagnosis zfs-retire VERSION 1.1 1.0 1.16 1.0 2.0 1.0 1.0 1.0 1.0 1.0 STATUS active active active active active active active active active active DESCRIPTION CPU/Memory Retire Agent Disk Transport Agent eft diagnosis engine Fault Manager Self-Diagnosis I/O Retire Agent SNMP Trap Generation Agent SysEvent Transport Agent Syslog Messaging Agent ZFS Diagnosis Engine ZFS Retire Agent Fault manager logs
· The fault manager maintains two log files: ­ The error log contains a list of errors events that have been sent to the fault manager daemon ­ The fault log contains a list of problems that have been diagnosed and repaired · The fault log can be viewed by running fmdump:
$ fmdump · The error log can be viewed with fmdump's "-e" option:
$ fmdump -e · Fmdump also has a "-u" option to limit the output to a specific UUID, a "-T" option to display events that occurred during a specific timeframe, and "-v" and "-V" options to display verbose output Viewing faulty components

Monday, October 5, 2009

zpool monitoring

The second script checks the current state of the zpools, looking for degraded arrays (caused by failed drives), unavailable spares and unrecovered errors. Because it keeps a state file in /etc/zfs, it would need to be run as root. I run this hourly. It should be possible to update this script to also check for ZFS checksum errors, but I haven't taken the time to do it. The reminder code hasn't been tested, as I haven't had a failure since the code was put in place.

#! /bin/sh

STATEFILE="/etc/zfs/chk.state"
ALARMUSER="root@localhost"

zpool status 2>&1 | \
egrep -i '(degraded|unavail|unrecover)' > /dev/null

STATE=$?

if [ -f $STATEFILE ]
then
LASTSTATE=`cat $STATEFILE`
else
LASTSTATE=1
echo $STATE > $STATEFILE
fi

#
# Error is currently set.
#
if [ $STATE = 0 ]
then

#
# Error wasn't set previously. Send out the error message.
#
if [ $LASTSTATE = 1 ]
then
HOSTNAME=`uname -n`
zpool status -x | \
mailx -s "ZFS.error.on.$HOSTNAME" $ALARMUSER
echo $STATE > $STATEFILE
exit
fi

#
# Send out a reminder every other day.
#
FOUND=`find $STATEFILE -mtime -2`
if [ -z $FOUND ]
then
exit
fi
HOSTNAME=`uname -n`
zpool status -x | \
mailx -s "ZFS.error.reminder.on.$HOSTNAME" $ALARMUSER
echo $STATE > $STATEFILE
exit
fi

#
# Error was set, but is no longer. Send out the fixed message.
#
if [ $STATE = 1 -a $LASTSTATE = 0 ]
then
HOSTNAME=`uname -n`
zpool status -x | \
mailx -s "ZFS.error.fixed.on.$HOSTNAME" $ALARMUSER
echo $STATE > $STATEFILE
exit
fi


EDIT: Updated above script to look for unrecovered errors, thanks to information in this post by nhamilto40. To reset the error counts, the "zpool clear pool" command can be used.

I scanned this thread, and see no scripts. Perhaps this will be more useful than I thought.

Monday, August 31, 2009

iostat -En

An example of the above command:
# iostat -En
c8d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: ST3160215AS Revision: Serial No: 6RA Size: 160.04GB <160039305216 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0
c7t0d0 Soft Errors: 0 Hard Errors: 9 Transport Errors: 0
Vendor: PLEXTOR Product: DVDR PX-712A Revision: 1.09 Serial No:
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 9 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0
c10t0d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: WDC WD40 Product: 0LB-07DNA2 Revision: 7B79 Serial No:
Size: 40.02GB <40020664320 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 76 Predictive Failure Analysis: 0

Saturday, August 15, 2009

iostat command

iostat -xnzc 1

us sy wt id
1 7 0 92
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.0 348.0 0.0 6340.0 0.0 0.1 0.1 0.2 3 5 c7t0d0
0.0 348.0 0.0 6340.0 0.0 0.1 0.1 0.2 3 5 c7t1d0
0.0 347.0 0.0 6340.0 0.0 0.1 0.1 0.2 3 5 c7t2d0

iostat -xtc 2 2

extended device statistics tty cpu
device r/s w/s kr/s kw/s wait actv svc_t %w %b tin tout us sy wt id
cmdk0 2.6 0.8 134.4 13.7 0.1 0.0 32.7 1 3 0 97 1 1 0 99
fd0 0.0 0.0 0.0 0.0 0.0 0.0 981.3 0 1
sd0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd3 0.1 21.1 1.8 369.1 0.0 0.0 0.5 0 0
sd4 0.1 21.1 1.8 369.1 0.0 0.0 0.4 0 0
sd5 0.1 21.1 1.8 369.1 0.0 0.0 0.4 0 0
sd6 0.1 0.0 1.3 0.3 0.0 0.0 0.9 0 0
extended device statistics tty cpu
device r/s w/s kr/s kw/s wait actv svc_t %w %b tin tout us sy wt id
cmdk0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 309 0 0 0 100
fd0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0


zpool iostat 3

capacity operations bandwidth
pool used avail read write read write
---------- ----- ----- ----- ----- ----- -----
dawpool 2.78G 2.72T 0 16 3 771K
rpool 7.79G 12.2G 2 0 137K 14.0K
---------- ----- ----- ----- ----- ----- -----
dawpool 2.78G 2.72T 0 0 0 0
rpool 7.79G 12.2G 0 0 0 0

Tuesday, May 5, 2009

ZFS Alerting

http://en.wikibooks.org/wiki/System_Monitoring_with_Hobbit/HOWTO#Hobbit_Client_and_ZFS_monitoring

Check which disk are in the system and ID’s given by Solaris:
bash-3.00# metastat |tail -3
Device Reloc Device ID
c0t1d0 Yes id1,sd@SSEAGATE_ST336607LSUN36G_3JA6ECDF00007418PJ5V
c0t0d0 Yes id1,sd@SSEAGATE_ST336607LSUN36G_3JA6EGFK00007418A7PM
bash-3.00#

bash-3.00# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
0. c0t0d0
/pci@1c,600000/scsi@2/sd@0,0
1. c0t1d0
/pci@1c,600000/scsi@2/sd@1,0
2. c0t2d0
/pci@1c,600000/scsi@2/sd@2,0
3. c0t3d0
/pci@1c,600000/scsi@2/sd@3,0


Show Health
# bash-3.00# zpool list -H
# mypool 33.8G 84.5K 33.7G 0% ONLINE -
# bash-3.00#


Script that sends an email out to redalert
This the script (run as root via crontab) I use to have an email sent
to 'root' if a fault is detected. It has already reported a fault:

#!/bin/sh
REPORT=/tmp/faultreport.txt
SYSTEM=$1
rm -f $REPORT
/usr/sbin/fmadm faulty 2>&1 > $REPORT
if test -s $REPORT
then
/usr/bin/Mail -s "$SYSTEM Fault Alert" redalert < $REPORT
fi
rm -f $REPORT