#!/bin/ksh ## ## SCRIPT: showerrs_syslog_anyhost_bygui ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################# ## PURPOSE: Shows the error/warning msgs in /var/adm/SYSLOG or ## /var/adm/oSYSLOG (or other local host files, like config files) ## on an SGI host machine, local or remote. ## ############################################################################# ## CALLED BY: 'hostconfig' script in $FEDIR/scripts ## ## actually, called by 'hostconfig.chestdef' in $FEDIR/scripts. ## ## (May eventually be called in a separate 'HostErrors' or ## 'HostActivityHistory' toolchest.) ############################################################################# ## MAINTENANCE HISTORY: ## Written by: B. Montandon 5dec2000 Based on 'config_memswap_bygui' script ## in $FEDIR/scripts ## Updated by: B. Montandon 10sep2001 Add a check for huge SYSLOG file. Show ## only top & bottom of log in that case. ## Updated by: B. Montandon 31may2002 1) Chg default host from $BIGCLIENT1 ## to $THISHOST. ## 2) Chg GUI script from ## 'enter_hostid_optmenu.tk` to ## 'enter_hostid_optmenu_toghelp-scroll.tk`. ## ## Updated by: B. Montandon 18sep2002 1) Add double-quotes around commands ## submitted by 'rsh'. ## 2) Add some comments to trailer about ## $TOOMANYBYTES and $TOPBOTBYTES used ## to show top & bottom of huge logs. ## ## Updated by: B. Montandon 18sep2002 Add check to see if host is ping-able ## via var $PINGOUT. Avoids long hang ## and mis-leading message about SYLOG ## being bigger than $TOOMANYBYTES. ## ## Updated by: B. Montandon 27sep2004 1) Chgd the Tk-GUI prompt script from ## 'enter_hostid_optmenu_toghelp-scroll.tk' ## to 'enter_hostid_and_file_toghelp-scroll.tk' ## -- to allow for changing SYSLOG to oSYSLOG, ## or other FILENAMEs. ## 2) Added prompting (while) loop. ############################################################################# if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea export FEDIR fi THISHOST=`hostname` BIGCLIENT4FEA="engfea00" ########################################################################## ## SET VARS in Tk-GUI PROMPT FOR HOSTNAME & FILENAME. ########################################################################## WINTITLE="SysLog (errors/msgs) @AnyHost" export WINTITLE WIN_INFO="\ INPUT: Enter the name of an SGI host on the NNS network. This utility shows the System Log File, /var/adm/SYSLOG, of the specified host. Or, you can show the previous week's System Log File, /var/adm/oSYSLOG, by changing the filename. (A cron job ordinarily runs weekly on SGI/Unix hosts, on Sunday's. It starts a new 'SYSLOG' file after renaming the current one to 'oSYSLOG'.) If helpful, you can even change the filename to a config file, like one mentioned in the SYSLOG file. Example: /etc/resolv.conf You can click the Cancel button to exit the prompting loop for host and filename. ----- USAGE: ----- Viewing SYSLOG can be helpful to check for unusual/pathological conditions on a particular SGI host, since its last boot-up. Note that you can do queries on multiple hosts and bring the report windows side-by-side for comparison. ---------------------------------------------------------------------- This utility is run via the script: $0" export WIN_INFO # HOST_ID="$BIGCLIENT4FEA" HOST_ID="$THISHOST" export HOST_ID ########################################################################## ## START PROMPTING LOOP FOR HOSTNAME & FILENAME. ########################################################################## # while true while : do # HOST_ID=`$FEDIR/tkGUIs/enter_hostid.tk` # HOST_ID=`$FEDIR/tkGUIs/enter_hostid_optmenu.tk` # HOST_ID=`$FEDIR/tkGUIs/enter_hostid_optmenu_toghelp-scroll.tk` FILENAME="/var/adm/SYSLOG" export FILENAME FILEWIDTH=20 export FILEWIDTH FILTER_AT_STARTUP="YES" export FILTER_AT_STARTUP TEMP=`$FEDIR/tkGUIs/enter_hostid_and_file_toghelp-scroll.tk` eval "$TEMP" ###################################################################### ## TEMP will contain assignment statements for hostname & filename: ## HOST_ID="xxxxxx" ; FILENAME="yyyyyyyyyy" ###################################################################### ## FOR TESTING: # echo "TEMP: $TEMP" ###################################################################### if test "$HOST_ID" = "" then exit fi if test "$FILENAME" = "" then exit fi ########################################################################## ## SET INDICATOR OF Local or Remote host. ########################################################################## ## THISHOST=`hostname` ## WAS SET ABOVE. LOCALHOST="N" if test "$HOST_ID" = "$THISHOST" then LOCALHOST="Y" fi ##################################################################### ## CHECK THAT *REMOTE* HOST_ID IS PING-ABLE. ##################################################################### if test "$LOCALHOST" = "N" then PINGOUT=`/usr/etc/ping -s 4 -c 1 $HOST_ID` ## FOR TESTING: # echo "$PINGOUT # # " ## FOR TESTING: # set -x PINGCHECK=`echo $PINGOUT | grep '100.0% packet loss'` if test ! "$PINGCHECK" = "" then CONFIRM_TEXT="\ $HOST_ID IS NOT PING-ABLE. Not turned on or not connected to network." export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="350 150" CONFIRM_TITLE="$WINTITLE" export CONFIRM_TITLE CONFIRM_MINSIZE CONFIRM_GEOM CONFIRM_COLOR="#3DADFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` & exit # export HOST_ID STRING # continue # ## break fi ## END OF if test ! "$PINGCHECK" = "" fi ## END OF if test "$LOCALHOST" = "N" ##################################################################### ## CHECK THAT THE HOST_ID EXISTS, if not THISHOST. ##################################################################### ## FOR TESTING: # set -x if test ! "$HOST_ID" = "$THISHOST" then HOSTCHECK=`rsh $HOST_ID cd 2>&1 | grep 'Unknown host'` if test ! "$HOSTCHECK" = "" then CONFIRM_TEXT="\ Specified Host: $HOST_ID is Unknown. " export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="350 150" CONFIRM_TITLE="$WINTITLE" export CONFIRM_TITLE CONFIRM_MINSIZE CONFIRM_GEOM CONFIRM_COLOR="#3DADFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT JUNK=`$FEDIR/tkGUIs/confirm.tk DISMISS` & exit ## continue fi ## END OF if test ! "$HOSTCHECK" = "" fi ## END OF if test ! "$HOST_ID" = "$THISHOST" ########################################################################### ## PREPARE OUTPUT/LIST FILENAME in $OUTLIST. ########################################################################### . $FEDIR/scripts/set_localoutlist ####################################################### ## PREPARE HEADING OF THE OUTPUT FILE. ####################################################### DATETIME=`date '+%Y %b %d %a %T%p %Z'` echo "\ ................... $DATETIME .......................... Contents of File $FILENAME at Host name: $HOST_ID " > $OUTLIST ########################################################################## ## GENERATE REPORT CONTENTS. (from Local or Remote host) ########################################################################## ## If SYSLOG is very big, show only head and tail. ########################################################################## ## THISHOST is set above. # THISHOST=`hostname` TOOMANYBYTES=1000000 TOPBOTBYTES=1000 if test "$HOST_ID" = "$THISHOST" then ####################################################################### ## If $HOST_ID is the local host, $THISHOST: ## ## USE 'local' 'ls -l', 'head', 'tail', 'cat', commands --- ## in other words, DO NOT USE 'rsh' processing. ####################################################################### ## FOR TESTING: # set -x LOGBYTES=`ls -l $FILENAME | awk '{print $5}'` if test $LOGBYTES -gt $TOOMANYBYTES then echo " ************************************************************** $FILENAME is very big --- $LOGBYTES bytes --- more than $TOOMANYBYTES bytes. Showing only the first and last $TOPBOTBYTES bytes. ************************************************************** " >> $OUTLIST head -$TOPBOTBYTES $FILENAME >> $OUTLIST echo " ... ... *** SKIPPING LOG RECORDS HERE. *** ... " >> $OUTLIST tail -$TOPBOTBYTES $FILENAME >> $OUTLIST else cat $FILENAME >> $OUTLIST fi ## END OF if test $LOGBYTES -gt $TOOMANYBYTES ## FOR TESTING: # set - else ####################################################################### ## If $HOST_ID is NOT the local host, $THISHOST: ## ## USE 'rsh' processing --- for 'ls -l', 'head', 'tail', 'cat', commands ####################################################################### ############################################ ## MAKE .rhosts FILE FOR THE USER, if needed. ############################################ . $FEDIR/scripts/mak_rhosts ## FOR TESTING: # set -x LOGBYTES=`rsh $HOST_ID "ls -l $FILENAME" | awk '{print $5}'` if test $LOGBYTES -gt $TOOMANYBYTES then echo " ************************************************************** $FILENAME is very big --- $LOGBYTES bytes --- more than $TOOMANYBYTES bytes. Showing only the first and last $TOPBOTBYTES bytes. ************************************************************** " >> $OUTLIST rsh $HOST_ID "head -$TOPBOTBYTES $FILENAME" >> $OUTLIST echo " ... ... *** SKIPPING LOG RECORDS HERE. *** ... " >> $OUTLIST rsh $HOST_ID "tail -$TOPBOTBYTES $FILENAME" >> $OUTLIST else rsh $HOST_ID "cat $FILENAME" >> $OUTLIST fi ## END OF if test $LOGBYTES -gt $TOOMANYBYTES ## FOR TESTING: # set - ########################################################### ## REMOVE .rhosts FILE FOR THE USER. (Commented; not used.) ########################################################### # . $FEDIR/scripts/mv_rhosts fi ## END OF if test "$HOST_ID" = "$THISHOST" ########################################################################## ## ADD REPORT 'TRAILER'. ########################################################################## echo " ------------------------------------------------------------------------- The list above was generated by the command: cat $FILENAME >> $OUTLIST in the script $0 run on the specified host, $HOST_ID. ------------------------------------------------------------------------- If $FILENAME is very big --- more than $TOOMANYBYTES bytes --- only the first and last $TOPBOTBYTES bytes are shown. *** END OF SYSLOG for Host name: $HOST_ID " >> $OUTLIST ####################################################### ## SHOW THE OUTPUT FILE. ####################################################### #OLD:1995-1999# . $FEDIR/scripts/shofil_land $OUTLIST #OLD:summer99# $FEDIR/scripts/shofil_land_tk $OUTLIST $FEDIR/scripts/shofil_land $OUTLIST ## FOR TESTING: # set - done ########################################################################## ## END OF PROMPTING LOOP FOR HOSTNAME & FILENAME. ##########################################################################