no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:hba.ksh [2010/08/24 01:43] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== hba.ksh ====== | ||
+ | |||
+ | ^ Author | [[ everett.vernon@gmail.com | Vernon Everett ]] | | ||
+ | ^ Compatibility | Should work on all versions | | ||
+ | ^ Requirements | Solaris | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2010-08-11 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | A monitoring script to keep tabs on your HBAs. | ||
+ | It can check they are | ||
+ | * Online | ||
+ | * Running at optimal speed | ||
+ | * Not getting errors | ||
+ | * Correctly multi-pathed | ||
+ | It will also | ||
+ | * List SCSI devices | ||
+ | * List remote ports | ||
+ | * List multi-path info, even if you don't want it to generate alerts. | ||
+ | Alerts are configurable, | ||
+ | Override variables are (With default value) | ||
+ | * CHECKSPEED=true | ||
+ | * CHECKONLINE=true | ||
+ | * CHECKERRS=true | ||
+ | * CHECKMPATH=true | ||
+ | * LIST_MPATH=true | ||
+ | * LIST_SCSI=true | ||
+ | * LIST_REMOTE=true | ||
+ | * ERR_YELLOW=3 | ||
+ | * ERR_RED=100 | ||
+ | * MPATHFAILCOL=yellow -- Colour of a multipath fail | ||
+ | |||
+ | Some may notice that this script could probably have been much shorter, and simpler to create using Perl, but that would require me to learn enough Perl to do so. | ||
+ | Anybody feeling energetic enough to redo it in Perl - knock yourself out. | ||
+ | |||
+ | ===== Installation ===== | ||
+ | === Client side === | ||
+ | 1. Copy hba.ksh to ~$HOME/ | ||
+ | |||
+ | 2. Edit the '' | ||
+ | |||
+ | [hba] | ||
+ | ENVFILE $HOBBITCLIENTHOME/ | ||
+ | CMD $HOBBITCLIENTHOME/ | ||
+ | LOGFILE $HOBBITCLIENTHOME/ | ||
+ | INTERVAL 5m | ||
+ | === Server side === | ||
+ | If you want to override some of the default variables in the script, add them to client-local.cfg under the appropriate label. | ||
+ | HBA:export CHECKERRS=false | ||
+ | HBA:export ERR_RED=20 | ||
+ | HBA:export LIST_SCSI=false | ||
+ | |||
+ | See Description above for more. | ||
+ | |||
+ | ===== Source ===== | ||
+ | ==== hba.ksh ==== | ||
+ | |||
+ | <hidden onHidden=" | ||
+ | <code bash> | ||
+ | #!/bin/ksh | ||
+ | # HBA monitoring script | ||
+ | # Author : Vernon Everett | ||
+ | # Development History | ||
+ | # Date | Author | ||
+ | # | ||
+ | # 10/08/2010 | Vernon Everett | Initial release. | ||
+ | # 11/08/2010 | Vernon Everett | Added override variables | ||
+ | # | Added mult-path, SCSI details, remote port info | ||
+ | # | ||
+ | # | ||
+ | if [ -x / | ||
+ | then | ||
+ | [ $(/ | ||
+ | fi | ||
+ | TEMPFILE=$BBTMP/ | ||
+ | FCINFO="/ | ||
+ | MPATHADM="/ | ||
+ | COLOUR=green | ||
+ | # Define what to check and default threshholds for the error counts | ||
+ | CHECKSPEED=true | ||
+ | CHECKONLINE=true | ||
+ | CHECKERRS=true | ||
+ | CHECKMPATH=true | ||
+ | LIST_MPATH=true | ||
+ | LIST_SCSI=true | ||
+ | LIST_REMOTE=true | ||
+ | ERR_YELLOW=3 | ||
+ | ERR_RED=100 | ||
+ | MPATHFAILCOL=yellow | ||
+ | # Now we define them, let's over-ride them if defined in clientlocal.cfg | ||
+ | # Add lines like this in clientlocal.cfg to override the defaults. | ||
+ | # HBA:export CHECKERRS=false | ||
+ | # HBA:export ERR_RED=20 | ||
+ | LOGFETCH=${BBTMP}/ | ||
+ | if [ -f $LOGFETCH ] | ||
+ | then | ||
+ | grep " | ||
+ | | while read NEW_DEF | ||
+ | do | ||
+ | $NEW_DEF | ||
+ | done | ||
+ | fi | ||
+ | |||
+ | date > $TEMPFILE.out | ||
+ | $FCINFO hba-port | grep "No Adapters Found" > /dev/null | ||
+ | if [ $? -eq 0 ] | ||
+ | then | ||
+ | # There are no adapters to work with. | ||
+ | echo "No Adapters Found" >> $TEMPFILE.out | ||
+ | # Let's skip the rest of the crap | ||
+ | else | ||
+ | | ||
+ | | cut -d":" | ||
+ | | while read WWN | ||
+ | do | ||
+ | | ||
+ | done >> $TEMPFILE | ||
+ | if [ " | ||
+ | then | ||
+ | cat $TEMPFILE | while read LINE | ||
+ | do | ||
+ | | ||
+ | if [ -n " | ||
+ | then | ||
+ | if [ " | ||
+ | then | ||
+ | echo "& | ||
+ | else | ||
+ | echo "& | ||
+ | | ||
+ | fi | ||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | done | ||
+ | [ " | ||
+ | mv $TEMPFILE.online $TEMPFILE | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | cat $TEMPFILE | while read LINE | ||
+ | do | ||
+ | echo " | ||
+ | | ||
+ | [ -n " | ||
+ | | ||
+ | if [ -n " | ||
+ | then | ||
+ | [ " | ||
+ | echo "& | ||
+ | echo " | ||
+ | MAXSPEED="" | ||
+ | SPEEDS="" | ||
+ | CURRSPEED="" | ||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | done | ||
+ | mv $TEMPFILE.speed $TEMPFILE | ||
+ | fi | ||
+ | |||
+ | | ||
+ | | ||
+ | if [ " | ||
+ | then | ||
+ | cat $TEMPFILE | while read LINE | ||
+ | do | ||
+ | | ||
+ | | ||
+ | if [ -n " | ||
+ | then | ||
+ | ERRCOUNT=$(echo " | ||
+ | [ $ERRCOUNT -lt $ERR_YELLOW ] && LCOL=green | ||
+ | [ $ERRCOUNT -ge $ERR_YELLOW ] && LCOL=yellow | ||
+ | [ $ERRCOUNT -ge $ERR_RED ] && LCOL=red | ||
+ | echo "& | ||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | [ " | ||
+ | [ " | ||
+ | done | ||
+ | [ " | ||
+ | [ " | ||
+ | mv $TEMPFILE.err $TEMPFILE | ||
+ | fi | ||
+ | [ " | ||
+ | [ " | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | rm $TEMPFILE.badpath 2> / | ||
+ | echo "< | ||
+ | echo "" | ||
+ | echo "< | ||
+ | echo "" | ||
+ | $MPATHADM list lu > $TEMPFILE.path | ||
+ | if [ " | ||
+ | then | ||
+ | cp $TEMPFILE.path $TEMPFILE.path.colours | ||
+ | cat $TEMPFILE.path | awk '{ FS=":" | ||
+ | | nawk ' | ||
+ | | while read DEV TOTPATH OPERPATH | ||
+ | do | ||
+ | | ||
+ | if [ $TOTPATH -ne $OPERPATH ] | ||
+ | then | ||
+ | LCOL=$MPATHFAILCOL | ||
+ | MPATH=bad | ||
+ | [ $COLOUR != " | ||
+ | fi | ||
+ | | ||
+ | sed " | ||
+ | mv $TEMPFILE.path.tmp $TEMPFILE.path.colours | ||
+ | done | ||
+ | mv $TEMPFILE.path.colours $TEMPFILE.path | ||
+ | [ " | ||
+ | fi | ||
+ | cat $TEMPFILE.path >> $TEMPFILE.path.out | ||
+ | mv $TEMPFILE.path.out $TEMPFILE.path | ||
+ | echo >> $TEMPFILE.path | ||
+ | fi | ||
+ | |||
+ | cat $TEMPFILE | while read LINE | ||
+ | do | ||
+ | echo " | ||
+ | if [ $? -eq 0 ] | ||
+ | then | ||
+ | echo "< | ||
+ | echo " | ||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | done | ||
+ | [ " | ||
+ | rm $TEMPFILE.path 2>/ | ||
+ | |||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | echo "< | ||
+ | echo "" | ||
+ | echo "< | ||
+ | echo "" | ||
+ | $FCINFO hba-port | grep "HBA Port WWN:" \ | ||
+ | | cut -d":" | ||
+ | | while read WWN | ||
+ | do | ||
+ | $FCINFO remote-port -p $WWN | ||
+ | done >> $TEMPFILE.out | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | FIRST=true | ||
+ | echo "< | ||
+ | echo "< | ||
+ | echo "" | ||
+ | $FCINFO hba-port | grep "HBA Port WWN:" \ | ||
+ | | cut -d":" | ||
+ | | while read WWN; | ||
+ | do | ||
+ | $FCINFO remote-port -s -p $WWN | ||
+ | done > $TEMPFILE | ||
+ | cat $TEMPFILE | while read LINE | ||
+ | do | ||
+ | echo $LINE | grep " | ||
+ | | ||
+ | [ $RES -eq 0 -a " | ||
+ | [ $RES -eq 0 -a " | ||
+ | echo " | ||
+ | done | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | $BB $BBDISP " | ||
+ | rm $TEMPFILE $TEMPFILE.out 2> /dev/null | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | **PUBLIC SERVICE WARNING** | ||
+ | I have not had the opportunity to test this script under all fail conditions! | ||
+ | |||
+ | This means that there could be bugs that I am not aware of. | ||
+ | |||
+ | If you spot any, please let me know, and I will see what I can do about it. | ||
+ | |||
+ | |||
+ | No bugs known - at the moment. | ||
+ | |||
+ | ===== To Do ===== | ||
+ | Fix any bugs that come along. | ||
+ | |||
+ | Features? | ||
+ | |||
+ | No. I am done with this one for now. I leave it to the rest of the community to add any more features. | ||
+ | |||
+ | |||
+ | ===== Credits ===== | ||
+ | I am going to take the blame for this one. | ||
+ | |||
+ | However, I am indebted to Kevin Kelly for giving me the idea. | ||
+ | http:// | ||
+ | |||
+ | It was a great way to keep myself from going crazy on what was panning out to be a very slow and boring day. :-) | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2010-08-11** | ||
+ | * Initial release | ||