<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=741545211-20062008><FONT face=Arial><FONT color=#0000ff><FONT
size=2>T<SPAN class=741545211-20062008>he last one seems to have lost something
in translation. Please accept my apologies and use this (working)
version!</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=741545211-20062008><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=741545211-20062008></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV><SPAN class=741545211-20062008><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN class=741545211-20062008></SPAN></FONT></FONT></FONT></SPAN><FONT
size=3><FONT face=Arial color=#0000ff size=2>#!/bin/sh<BR>#<BR># meta: Sun
Enterprise Server check - BB external script test<BR>#<BR>##### Purpose is
to report back to a central server, all Solaris<BR>#####
DiskSuite RAID software faults.<BR>#####<BR>#<BR># version 1.0<BR># version 2.0
- properly uses $THIS_HOST instead of $MACHINE due to fqdn
using<BR>#
comma in
name<BR>#
removed all direct program calls in favor of env vars in
bbsys.*<BR>#
changed /tmp to
$BBTMP<BR>#
meta to
$TEST<BR>#
$THIS_HOST to
$MACHINE<BR>#
removed code that checked for the existance of
"meta"<BR>#
after the server name in
bb-hosts<BR>#
moved comment explaining purpose of script to start of
code<BR>#
caused output of metadb, metastat, and metahs to be
displayed<BR>#
on the web page<BR># version 2.1 - Warns if default values are not
used<BR>#
Applied changes by Todd
Jimenez<BR>#
- created get_header and get_footer
functions<BR>#
- set summary
value<BR>#
- added &red to red
alerts<BR>#
- added &yellow to yellow
alerts<BR>#
restored functionality to check for the existence of
"meta"<BR>#
after the server name in bb-hosts, but now optional<BR># version 2.2 - Change
status to &yellow when disk is resyncing.<BR># version 2.3 - Added code to
check for raidctl command and perfrom raid checks<BR># using that if
it's there.<BR># Using this version REQUIRES sudo
!<BR># raidctl(1m) on Solaris can only be run as root. Sudo is
a<BR># nice workaround.<BR>#<BR># BIG BROTHER / XXXXXXXXXXXXXXXX
status<BR>#<BR># Written by Galen Johnson<BR># on October 25,
2000<BR>#<BR># Inspired by a module of the perl clone of BB written<BR># by
Charles Hall in August 1998<BR>#<BR># Based on code found in the DiskSuite
manual<BR>#<BR># 2.0 Updates by Mike Arnold <mike at razorsedge dot
org><BR># on September 27, 2001<BR>#<BR># 2.1 Updates by Mike Arnold
<mike at razorsedge dot org><BR># on November 23, 2001<BR>#<BR># 2.2
Updates by Martin Ward <martin dot ward at colt dot net><BR># on
Monday 19th May 2008<BR>#<BR># 2.3 Updates by Martin Ward <martin dot ward at
colt dot net><BR># on Monday 19th June 2008</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>########################################<BR># NOTE<BR># This has been
tested with BB 1.8c and Hobbit 4.2.0<BR>#<BR># Tested on :<BR># Sun
220R, 420R, E250/450,
E4500<BR>########################################</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>########################################<BR># INSTALLATION<BR>#
step 1 - update bb-bbexttab to include this
meta<BR>#
(older BB versions update EXT section of the bbdef.sh script)<BR>#<BR>#
step 2 - copy lines mentioned to bbsys.local (without the #'s)<BR>#<BR>#
step 3 - if you are using an older version of BB without
bb-bbexttab<BR>#
and you don't want this run on every client
uncomment<BR>#
CHECK_BB_HOSTS="Y" and add the name of this $TEST
to<BR>#
bb-hosts for this client.
eg.<BR>#
myserver1.domain.com # meta<BR>#<BR># step 4 - If you have
sudo installed need to use the raidctl control,<BR># add
the following line into your /etc/sudoers file:<BR>#
hobbit ALL=(root)
NOPASSWD:/usr/sbin/raidctl -l<BR># step 5 - restart Big Brother<BR>#<BR>#
NOTE - the TEST variable in the configuration section, this is the name
used<BR># as the column
header.<BR>########################################</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>##################################<BR># CONFIGURE IT
HERE<BR>##################################<BR>TEST="raid"<BR>SCRIPT_VER="bb-raid.sh
v2.3"</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>BBPROG="$0"; export
BBPROG<BR>DEBUG=0<BR>#<BR># Start of lines to put in bbsys.local<BR># NOTE:
MDBIN can be either /usr/sbin or /usr/opt/SUNWmd/sbin<BR>#</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>MDBIN=/usr/sbin<BR>METADB=${MDBIN}/metadb<BR>METAHS=${MDBIN}/metahs<BR>METASTAT=${MDBIN}/metastat<BR>SUDO=/opt/sfw/bin/sudo<BR>RAIDCTL=/usr/sbin/raidctl<BR>export
MDBIN METADB METAHS METASTAT SUDO RAIDCTL</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#<BR># End of lines to
put in bbsys.local<BR>#</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2># define colours for
graphics<BR># Comment these out if using older BB
versions<BR>RED_PIC="&red"<BR>YELLOW_PIC="&yellow"<BR>GREEN_PIC="&green"</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2># don't scan through
bb-hosts every time<BR># this is here for older BB versions without
bb-bbexttab<BR># uncomment to activate<BR>#CHECK_BB_HOSTS=Y</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>##################################<BR># Start of
script<BR>##################################<BR>#BBHOME="/home/bb/bb"; export
BBHOME</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>if test !
"$BBHOME"<BR>then<BR> echo "template:
BBHOME is not set"<BR> exit
1<BR>fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>if test ! -d
"$BBHOME"<BR>then<BR> echo "template:
BBHOME is invalid"<BR> exit
1<BR>fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>if test !
"$BBTMP"
# GET DEFINITIONS IF
NEEDED<BR>then<BR> # echo "***
LOADING BBDEF ***"<BR> .
$BBHOME/etc/bbdef.sh #
INCLUDE STANDARD DEFINITIONS<BR>fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>get_header()<BR>{<BR> echo ""<BR> echo "<FONT
SIZE=+2><b>$1</b></FONT> ($2)<BR>"<BR> # If you
do not want the header in a bigger font use line below instead<BR> #echo
"<b>$1</b> ($2)"<BR> # If you want the "Paul Luzzi" look
uncomment this section and comment<BR> # out the above sections:<BR>
#echo "<P><DIV ALIGN=\"CENTER\"><HR>" <BR> #echo
"<B>============== $1 ==============</B>"<BR> #echo
"<B>--- ($2) ---</B>"<BR> #echo "<HR></DIV>"
<BR> #echo "<BLOCKQUOTE>" <BR>}</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2>get_footer()<BR>{<BR> echo ""<BR> # If you want the "Paul
Luzzi" look uncomment this section and comment<BR> # out the above
sections:<BR> #echo "</BLOCKQUOTE>"<BR>}</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>##### Get
MD Status proc - used if the server uses a
metadb<BR>#####<BR>get_md_status()<BR>{<BR> #####<BR> #####
Setup some variables for use later<BR> #####<BR>
COLOR="green"</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> # Check defaults
have been set<BR> if [ "$MDBIN" = "" ]; then<BR>
MDBIN=/usr/sbin<BR> echo ""<BR> echo
"$YELLOW_PIC MDBIN command is not defined in etc/bbsys.local - using default:
$MDBIN"<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ "$METADB" =
"" ]; then<BR> METADB=${MDBIN}/metadb<BR>
echo ""<BR> echo "$YELLOW_PIC METADB command is not defined in
etc/bbsys.local - using default: $METADB"<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ "$METAHS" =
"" ]; then<BR> METAHS=${MDBIN}/metahs<BR>
echo ""<BR> echo "$YELLOW_PIC METAHS command is not defined in
etc/bbsys.local - using default: $METAHS"<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ "$METASTAT"
= "" ]; then<BR>
METASTAT=${MDBIN}/metastat<BR> echo ""<BR>
echo "$YELLOW_PIC METASTAT command is not defined in etc/bbsys.local - using
default: $METASTAT"<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> ###<BR> ###
Check replicas for problems, capital letters in the flags indicate an
error.<BR> ###<BR> get_header "MetaDatabases" "$METADB -i"<BR>
dbtrouble=`${METADB} 2>/dev/null | ${TAIL} +2 | ${AWK} '{ fl =
substr($0,1,20); if (fl ~ /[A-Z]/) print $0 }'`<BR> if [ "${dbtrouble}" ];
then<BR> COLOR="red"<BR> echo
""<BR> echo "$RED_PIC <B><I>Database replicas are
not active: </I></B>"<BR> echo
""<BR> ${METADB} -i 2>/dev/null<BR>
else<BR> ${METADB} -i 2>/dev/null<BR> fi<BR>
get_footer</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> ###<BR> ###
Check the metadevice state, if the state is not Okay, something is up.<BR>
###<BR> get_header "Metadevices" "$METASTAT"<BR>
mdtrouble=`${METASTAT} | ${GREP} "Resyncing"`<BR> if [ "${mdtrouble}" ];
then<BR> COLOR="yellow"<BR>
CLR_PIC="$YELLOW_PIC"<BR> fi<BR> mdtrouble=`${METASTAT} | ${GREP} -v
"Resyncing" | ${AWK} '/State:/ { if ( $2 != "Okay" ) print $0 }'`<BR> if [
"${mdtrouble}" ]; then<BR> COLOR="red"<BR>
CLR_PIC="$RED_PIC"<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ "$COLOR" !=
"green" ]; then<BR> echo ""<BR> echo
"$CLR_PIC <B><I>Metadevices are not Okay:
</I></B>"<BR> echo ""<BR>
${METASTAT}<BR> else<BR> ${METASTAT}<BR>
fi<BR> get_footer</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> ###<BR> ###
Check the hotspares to see if any have been used.<BR> ###<BR>### Hotspare
test disabled because writing to BBOUT when no hotspare
pools</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2># get_header "Hot
Spares" "$METAHS -i"<BR># hstrouble=`${METAHS} -i | ${AWK} ' /blocks/ { if
( $2 != "Available" ) print $0 }'`<BR># if [ "${hstrouble}" ];
then<BR># if [ COLOR != "red" ]; then<BR>#
COLOR="yellow"<BR># fi<BR># echo ""<BR>#
echo "$YELLOW_PIC <B><I>Hot spares in use:
</I></B>"<BR># echo ""<BR># ${METAHS} -i
2>&1<BR># else<BR># ${METAHS} -i 2>&1<BR># fi<BR>#
get_footer</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> #####<BR>
##### Make sure to export COLOR so that it gets back to
"central"<BR> #####<BR> export COLOR</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>##### End
of get_md_status proc<BR>#####<BR>}</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>##### Get
LSI Status proc - used if the server has LSI1030 or<BR>##### LSI1064
RAID-enabled controllers.<BR>#####<BR>get_lsi_status()<BR>{<BR>
#####<BR> ##### Setup some variables for use later<BR>
#####<BR> COLOR="green"</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> # Check defaults
have been set<BR> if [ "$RAIDCTL" = "" ]; then<BR>
RAIDCTL=/usr/sbin<BR> echo ""<BR> echo
"$YELLOW_PIC RAIDCTL command is not defined in etc/bbsys.local - using default:
$RAIDCTL"<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> ###<BR> ###
Check replicas for problems. Strip off the header then print any
entries<BR> ### that do not have the work OK in them, or do have the words
"DEGRADED" or<BR> ### "FAILED".<BR> ###<BR> dberrors=`${SUDO}
${RAIDCTL} -l | ${AWK} 'BEGIN { D=0; }<BR>/------/ { D=1; next;
}<BR>/DEGRADED|FAILED/ { if (D==1) {print $0; next; }
}<BR>/ OK/ { if (D==1) { next; } }<BR>{ if (D==1) {print "1 ",$0; } }'
`</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [
"${dberrors}" ]; then<BR> COLOR="red"<BR>
echo ""<BR> echo "$RED_PIC <B><I>RAID errors
exist: </I></B>"<BR> echo
"<pre>"<BR> ${SUDO} ${RAIDCTL} -l<BR>
echo "</pre>"<BR> else<BR> echo
"<pre>"<BR> ${SUDO} ${RAIDCTL} -l<BR>
echo "</pre>"<BR> fi<BR> get_footer</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> #####<BR>
##### Make sure to export COLOR so that it gets back to
"central"<BR> #####<BR> export COLOR</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>##### End
of get_lsi_status proc<BR>#####<BR>}</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>##### Get
Status proc - used to get all responses<BR>#####<BR>get_status()<BR>{<BR>
#####<BR> ##### Decide which RAID we have, then call the right
subroutine.<BR> #####<BR> <BR> COLOR=WHITE<BR> export
COLOR</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ "${RAIDCTL}"
!= "" ]; then<BR> TST=`${SUDO} ${RAIDCTL} -l | grep "No RAID
volumes found" | wc -l`<BR> if [ $TST -lt 1
]<BR> then<BR> get_lsi_status<BR>
fi<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ "${METADB}"
!= "" ]; then<BR> TST=`${METADB} 2>&1 | grep "there are
no existing databases" | wc -l`<BR> if [ $TST -lt 1
]<BR> then<BR>
get_md_status<BR> fi<BR> fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>##### End
of get_status proc<BR>#####<BR>}</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2>#####<BR>#####
Main body<BR>#####<BR>if [ "$CHECK_BB_HOSTS" = "Y" ]; then<BR> # convert
"," to "." in the hostname<BR> MACHINE_WITH_DOTS=`echo $MACHINE | $SED
's/,/\./g'`</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> $GREP
$MACHINE_WITH_DOTS $BBHOSTS | $GREP "$TEST" |<BR> while read
line<BR> do<BR> if [ ! -z "$line" ];
then<BR> get_status >
$BBTMP/$MACHINE.$TEST</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2> ### Tack the script version on to the
end<BR> echo "<table><tr><td
align=right><font
size=-1>${SCRIPT_VER}</font></td></tr></table>"
>> $BBTMP/$MACHINE.$TEST</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2> if [ ${DEBUG} = "1" ];
then<BR> echo "$BB $BBDISP \"status
$BBTMP/$MACHINE.$TEST $COLOR" `$DATE` `$CAT $BBTMP/$MACHINE.$TEST` "\"" >>
$BBTMP/raid.output<BR>
else<BR> # NOW USE THE BB COMMAND TO
SEND THE DATA ACROSS<BR> $BB $BBDISP
"status $BBTMP/$MACHINE.$TEST $COLOR `$DATE` `$CAT $BBTMP/$MACHINE.$TEST`
"<BR> fi<BR> fi<BR>
done<BR>else<BR> get_status > $BBTMP/$MACHINE.$TEST</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> ### Tack the
script version on to the end<BR> echo "<table><tr><td
align=right><font
size=-1>${SCRIPT_VER}</font></td></tr></table>"
>> $BBTMP/$MACHINE.$TEST</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2> if [ ${DEBUG} =
"1" ]; then<BR> echo "$BB $BBDISP \"status $MACHINE.$TEST
$COLOR" `$DATE` `$CAT $BBTMP/$MACHINE.$TEST` "\"<BR>" >>
$BBTMP/raid.output<BR> else<BR> # NOW USE THE BB COMMAND TO SEND THE
DATA ACROSS<BR> $BB $BBDISP "status $MACHINE.$TEST $COLOR `$DATE` `$CAT
$BBTMP/$MACHINE.$TEST`<BR> "<BR> fi<BR>fi</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff size=2># Clean up our mess<BR>#
Checking for existence of each file since the whole test may be
optional<BR># and may not actually run on every client<BR>#<BR>if [
-f $BBTMP/$MACHINE.$TEST ]; then<BR> $RM
$BBTMP/$MACHINE.$TEST<BR>fi<BR>##############################################<BR>#
end of
script<BR>##############################################</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3><FONT face=Arial color=#0000ff
size=2><BR></FONT> </DIV></FONT><FONT SIZE=3><BR>
<BR>
*************************************************************************************<BR>
The message is intended for the named addressee only and may not be disclosed to or used by anyone else, nor may it be copied in any way. <BR>
<BR>
The contents of this message and its attachments are confidential and may also be subject to legal privilege. If you are not the named addressee and/or have received this message in error, please advise us by e-mailing security@colt.net and delete the message and any attachments without retaining any copies. <BR>
<BR>
Internet communications are not secure and COLT does not accept responsibility for this message, its contents nor responsibility for any viruses. <BR>
<BR>
No contracts can be created or varied on behalf of COLT Telecommunications, its subsidiaries or affiliates ("COLT") and any other party by email Communications unless expressly agreed in writing with such other party. <BR>
<BR>
Please note that incoming emails will be automatically scanned to eliminate potential viruses and unsolicited promotional emails. For more information refer to www.colt.net or contact us on +44(0)20 7390 3900.<BR>
</FONT>
</BODY></HTML>