#!/bin/sh ################################################################# # bb-lwsn.sh J. David Schronce david@schronce.net # Tue Dec 19 12:58:41 EST 2000 # # A Big Brother External Script # Monitors Lawson Financials processes, queues and security # Displays data in BB 'lwsn' column # ################################################################# # # This software is provided as-is. J. David Schronce # makes no claims towards its suitability for any purpose # and accepts absolutely no liability for any damages # the software may cause. Use at your own risk. # # But for God's sake - read the freakin' instructions! # ################################################################# # # NOTE: If you are running Lawson Environment 7.3.2 or later # note the Special Lawson Instructions below. # # Instructions: Assign the appropriate values to the variables # described below. # # Add an entry for bb-lwsn.sh in your BBEXT variable # RESTART BB # # If you remove bb-lwsn.sh you must also # delete the *.lwsn data from $BBHOME/www/logs # or it will go PURPLE on you. # ################################################################# # S P E C I A L L A W S O N I N S T R U C T I O N S # # If you are running Lawson Environment 7.3.2 or later you will need # to follow the directions below in order to make the GEN database # accessible by the BBUSER. # # --- O R --- # # Run BB as lawadm, and have "lawadm" as the default user/owner of all of BB. # If lawadm is added as a user with a UID OVER 200 , AND is set up as a # Security Officer, he can rngdbdump the GEN tables without having to add # GEN # # bbdef.sh:- # # BB USER # BBUSER="lawadm" # export BBUSER # laua:- # Home Directory /home/lawadm # Shell Name /bin/ksh # Security Role Officer # # # -------------------------------- # # Adding GEN to dbdef # # NOTE: These instructions are not necessarily supported by Lawson # and the author of this software STRONGLY recomends that you test # these instructions on a non-production system before applying any # of the recommended changed to your Production Lawson System. # # In any case the author shall remain blameless for any consequences # incurred by the application of the following instructions. # # # 1. In dbdef add the GEN database, DO NOT specify a Database Space # # Tab down to the System Code section and key in the following: # UN Universe Tools # CS Universe Case # IS Internal Support # # Hit a few times to save, then Esc. # # 2. In laua create a new Security Class for the BBUSER # and assign it access to GEN # # # Now BBUSER (whatever you call yours) can run rngdbdump against # the GEN database. Additionally you can assign GEN access to any # other security classes you deem appropriate. # # Additional Note: Lawson disallowed this access in the 7.3.2 # Environment because they considered it a security risk. The # author cautions you to assign GEN access with forethought of # its possible consequences. # ################################################################# # # Uncomment the line below for manual testing # ################################################################# #DEBUG="Y" ################################################################# # # INITIALIZE VARIABLES WE'LL BE NEEDING # ################################################################# PROG=bb-lwsn.sh VERSION=1.07 TEST="lwsn" # THE NAME OF OUR TEST ################################################################# # # Lawson Process Configuration # # GENDIR should be set the same as the Lawson $GENDIR # # ------------------ # # LAWIPC should be set the same as the Lawson Environment you wish to monitor # As it stands now bb-lwsn.sh can only monitor 1 environment and should be # run with multiple names and $TEST values in a multi environment installation. # # ------------------ # # The following mimics the "PROCS" function already in # Big Brother, but is included to make it possible to # monitor the Lawson processes in one place and notify a # separate admin if necessary. # # ------------------ # # DOWN_RED should be substrings of the ps output # that identifies processes to verify are running, # and turn RED if it goes away. # # DOWN_YELLOW should be substrings of the ps output # that identifies processes to verify are running, # and turn YELLOW if it goes away. # # UP_RED should be substrings of the ps output # that identifies processes to notify if they are up, # and turn RED if it starts - you probably wil not use # this variable. # # UP_YELLOW should be substrings of the ps output # that identifies processes to notify if they are up, # and turn YELLOW if it starts - you probably wil not use # this variable. # # The selections below are merely examples and should be # changed to meet the needs of your particular envioment # ################################################################# GENDIR=/lawson/gen # Lawson $GENDIR LAWIPC=0x80 # Change for multiple environments DOWN_RED="latm ladb lajs" # red if DOWN # # Note from Alistair Hull #------------------ # I added "InfoDistAgent" to BB DOWN_RED for lwsn. This is the # process used at Unix clients who have E-Broadcasting Report # Distribution running, and must be present for E-Broadcasting # to work. # DOWN_YELLOW="queue" # yellow if DOWN UP_RED=" " # red if UP UP_YELLOW=" " # yellow if UP ################################################################# # # QUEUEDJOB Status Configuration # # A listing of the codes and their definitions are # included in the configuration section below. # # FOUND_RED should be the Lawson QUEUEDJOB Status codes # that will return RED if they show up in jobschd. # # FOUND_YELLOW should be the Lawson QUEUEDJOB Status codes # that will return YELLOW if they show up in jobschd. # ################################################################# QUEUESTATUSDEF=" 0 : Running 30 : Waiting 31 : Waiting Step 32 : Waiting On Time 33 : Waiting Recovery 34 : Needs Recovery 35 : Invalid Parameters 36 : Queue Inactive 37 : Hold 60 : Recurring Skipped 61 : Recovery Deleted 62 : Cancelled 63 : Normal Completion" FOUND_RED="36" FOUND_YELLOW="30 32 33 34" ################################################################# # # Lawson Security Configuration # # SECOFFCOLOR should be set to the color that will be # displayed if Lawson Security is turned off. # ################################################################# SECOFFCOLOR="yellow" # color to display if security is OFF ################################################################# # # DEBUG Configuration # # Set BBHOME as needed by your system # ################################################################# if test "$DEBUG" = "Y" then echo "*** BEGIN: LWSN TEST ***" set -xv BBHOME=/bb; export BBHOME fi ################################################################# # # NO CONFIGURATION BEYOND THIS POINT # ################################################################# # # Check that we have a basic environment setup # if test "$BBHOME" = "" then echo ERROR: BBHOME variable not set exit 1 fi if test ! "$BBTMP" # GET DEFINITIONS IF NEEDED then # echo "*** LOADING BBDEF ***" . $BBHOME/etc/bbdef.sh # INCLUDE STANDARD DEFINITIONS fi # THE hostname COMMAND MUST RETURN THE FULL MACHINE NAME (ASSUMING FQDN) # AND REPLACE "." WITH "," MACHINE=`hostname | $SED 's/\./,/g'` # # Check for processes in `ps` # LINE="" COLOR="green" # Build table for display by BB echo "" > $BBTMP/$TEST echo "
" >> $BBTMP/$TEST for UPPROC in $DOWN_YELLOW do PROC=`$PS | $GREP -v "grep" | $GREP "$UPPROC"` if [ "$PROC" ] then echo "" >> $BBTMP/$TEST else LINE="$LINE ATTENTION! $UPPROC is not running"; export LINE COLOR="yellow" ; export COLOR echo "" >> $BBTMP/$TEST fi done for DNPROC in $UP_YELLOW do PROC=`$PS | $GREP -v "grep" | $GREP "$DNPROC"` if [ "$PROC" ] then LINE="$LINE ATTENTION! $DNPROC is running"; export LINE COLOR="yellow" ; export COLOR echo "" >> $BBTMP/$TEST else echo "" >> $BBTMP/$TEST fi done for UPPROC in $DOWN_RED do PROC=`$PS | $GREP -v "grep" | $GREP "$UPPROC"` if [ "$PROC" ] then echo "" >> $BBTMP/$TEST else LINE="$LINE WARNING! $UPPROC is not running"; export LINE COLOR="red" ; export COLOR echo "" >> $BBTMP/$TEST fi done for DNPROC in $UP_RED do PROC=`$PS | $GREP -v "grep" | $GREP "$DNPROC"` if [ "$PROC" ] then LINE="$LINE WARNING! $DNPROC is running"; export LINE COLOR="red" ; export COLOR echo "" >> $BBTMP/$TEST else echo "" >> $BBTMP/$TEST fi done for QUEUEPROB in $FOUND_YELLOW do QUEUEPROBDEF=`echo "$QUEUESTATUSDEF" | $GREP " $QUEUEPROB " | cut -d":" -f2` PROB=`$GENDIR/bin/rngdbdump -c gen queuedjob -f username jobname status | $GREP "$QUEUEPROB$"` #LINE="$LINE #$QUEUEPROBDEF $PROB" if [ "$PROB" ] then LINE="$LINE ATTENTION! Job Scheduler has Status $QUEUEPROBDEF"; export LINE COLOR="yellow" ; export COLOR echo "" >> $BBTMP/$TEST else echo "" >> $BBTMP/$TEST fi done for QUEUEPROB in $FOUND_RED do QUEUEPROBDEF=`echo "$QUEUESTATUSDEF" | $GREP " $QUEUEPROB " | cut -d":" -f2` # PROB=`$GENDIR/bin/rngdbdump -c gen queuedjob -f username jobname status 2> /dev/null | $GREP -v "grep" | $GREP "$QUEUEPROB$" | $SED 's/\"//g'` PROB=`$GENDIR/bin/rngdbdump -c gen queuedjob -f username jobname status 2> /dev/null | $GREP "$QUEUEPROB$" | $SED 's/\"//g'` if [ "$PROB" ] then LINE="$LINE WARNING! Job Scheduler has Status $QUEUEPROBDEF"; export LINE #WARNING! Job Scheduler has Status `echo $PROB | cut -d',' -f 1-2`"; export LINE COLOR="red" ; export COLOR echo "" >> $BBTMP/$TEST else echo "" >> $BBTMP/$TEST fi done ##################################################### if test `$GENDIR/bin/lawsec status | $GREP "Is On." | wc -l` -eq 0 then LINE="$LINE `$GENDIR/bin/lawsec status`"; export LINE COLOR=$SECOFFCOLOR; export COLOR echo "" >> $BBTMP/$TEST else echo "" >> $BBTMP/$TEST fi echo "
$UPPROC" >> $BBTMP/$TEST echo "\"${UPPROC}
$UPPROC" >> $BBTMP/$TEST echo "\"${UPPROC}
$DNPROC" >> $BBTMP/$TEST echo "\"${DNPROC}
$DNPROC" >> $BBTMP/$TEST echo "\"${DNPROC}
$UPPROC" >> $BBTMP/$TEST echo "\"${UPPROC}
$UPPROC" >> $BBTMP/$TEST echo "\"${UPPROC}
$DNPROC" >> $BBTMP/$TEST echo "\"${DNPROC}
$DNPROC" >> $BBTMP/$TEST echo "\"${DNPROC}
$QUEUEPROBDEF" >> $BBTMP/$TEST echo "\"${QUEUEPROBDEF}
$QUEUEPROBDEF" >> $BBTMP/$TEST echo "\"${QUEUEPROBDEF}
$QUEUEPROBDEF" >> $BBTMP/$TEST echo "\"${QUEUEPROBDEF}
$QUEUEPROBDEF" >> $BBTMP/$TEST echo "\"${QUEUEPROBDEF}
Lawson Security" >> $BBTMP/$TEST echo "\"Lawson
Lawson Security" >> $BBTMP/$TEST echo "\"Lawson
" >> $BBTMP/$TEST echo "
" >> $BBTMP/$TEST
# Add footer
echo "

$PROG Version:$VERSION
J. David Schronce
" >> $BBTMP/$TEST # SEND THE DATA TO BIG BROTHER # Decide worst color for background for tmpcolor in yellow red do if test `$GREP $tmpcolor.gif $BBTMP/$TEST | $WC` -gt 0 then COLOR="$tmpcolor" fi done LINE="status $MACHINE.$TEST $COLOR `date` $LINE `cat $BBTMP/$TEST`" # # Send a status update to the Big Brother display unit # # # Debugging # if test "$DEBUG" = "Y" then echo "COLOR = ${COLOR}" echo "LINE = ${LINE} `cat $BBTMP/$TEST`" echo "*** END: LWSN TEST ***" else $BB $BBDISP "$LINE" # SEND IT TO BBDISPLAY fi # # END OF bb-lwsn.sh #