Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
/bin/ksh
##########################################
# This script is used to collect operating system information from AIX
# Developed for the "MustGather: Crash on AIX" technote
# Property of IBM - author Michael Schneider
##########################################
SCRIPT_VERSION=20111201
##########################################
# FIXES
# 12/01/2011 - Fixed errpt so it now outputs to errpt.out instead of df.out
# - Added ps.out (to capture ps -ef).
##########################################
# Variables
##########################################
S_USERID=
S_OVERRIDE_ROOT=N #Set to Y, or use the argument -R, to override the check for
the root user.
# FUNCTIONS
##########################################
# Determine if root
##########################################
isRoot()
{
print $(date) " AIX_OSINFO:I: Entering isRoot()" | tee -a aix_osinfo.log
S_USERID=`whoami`
if [ $S_USERID = "root" ]
then
print $(date) " AIX_OSINFO:I: Root user confirmed" | tee -a
aix_osinfo.log
else
print $(date) " AIX_OSINFO:W: Non-root user ($S_USERID) has executed
this script!" | tee -a aix_osinfo.log
echo "Non-root user ($S_USERID) has executed this script!" >> emgr.out
print $(date) " AIX_OSINFO:W: The command 'emgr -lv3' will not be
executed. Please rerun this command separately as the root user." | tee -a
aix_osinfo.log
fi
##########################################
# Logging functions
##########################################
startLog()
{
date > aix_osinfo.log 2>&1
print $(date) " AIX_OSINFO:I: Version of this script is :$SCRIPT_VERSION:" |
tee -a aix_osinfo.log
print $(date) " AIX_OSINFO:I: This script is used to collect operating system
information on AIX" | tee -a aix_osinfo.log
}
endLog()
{
print $(date) " AIX_OSINFO:I: Only these files have been automatically
collected into the aix_osinfo_RESULTS.tar.gz file:" | tee -a aix_osinfo.log
if [ $S_USERID = "root" ]
then
print $(date) " AIX_OSINFO:I: emgr.log" | tee -a aix_osinfo.log
fi
print $(date) " AIX_OSINFO:I: Please send in all files generated to IBM
support." | tee -a aix_osinfo.log
if [ $S_USERID = "root" ]
then
print $(date) " AIX_OSINFO:I: Additionally collect the rest of the
files required in the MustGather." | tee -a aix_osinfo.log
else
print $(date) " AIX_OSINFO:W: The command 'emgr -lv3' requires root
authority. Please run this command separately and combine this with the other
files generated and what is required in the MustGather." | tee -a aix_osinfo.log
fi
##########################################
# Create Output Files
##########################################
createOutput()
{
print $(date) " AIX_OSINFO:I: Entering createOutput()" | tee -a
aix_osinfo.log
print $(date) " AIX_OSINFO:I: Creating output files" | tee -a aix_osinfo.log
##########################################
# TAR | GZIP data
##########################################
compressData()
{
print $(date) " AIX_OSINFO:I: Entering compressData()" | tee -a
aix_osinfo.log
if [ S_RET -ne 0 ]
then
#display error message and do not delete files
print $(date) " AIX_OSINFO:E: Tarball creation failed. Please manually
collect the files generated." | tee -a aix_osinfo.log
else
#continue processing gzip, delete files regardless
S_RET=0 #reset RET
if [ S_RET -ne 0 ]
then
print $(date) " AIX_OSINFO:E: Gzip creation failed, instead
tarball has been generated." | tee -a aix_osinfo.log
fi
# Clean up the output files now that they have been tar/gz'd.
print $(date) " AIX_OSINFO:I: Remove the temporary output files as they
have now been added to the archive file." | tee -a aix_osinfo.log
rm $FILES_STRING
fi
print $(date) " AIX_OSINFO:I: Exiting compressData()" | tee -a aix_osinfo.log
}
##########################################
# Execute Commands
##########################################
execute()
{
print $(date) " AIX_OSINFO:I: Entering execute()" | tee -a aix_osinfo.log
if [ $S_USERID = "root" ]
then
print $(date) " AIX_OSINFO:I: Executing '/usr/sbin/emgr -lv3'" | tee -a
aix_osinfo.log
/usr/sbin/emgr -lv3 > emgr.out 2>&1
fi
print $(date) " AIX_OSINFO:I: All commands have been executed." | tee -a
aix_osinfo.log
#########################################
# Main Method
#########################################
startLog
createOutput
# Get Options
while getopts Rr name
do
case $name in
R) S_OVERRIDE_ROOT=Y;;
r) S_OVERRIDE_ROOT=N;;
esac
done
if [ $S_OVERRIDE_ROOT = "Y" ]
then
print $(date) " AIX_OSINFO:W: You have overrided the confirmation check for
the root user!" | tee -a aix_osinfo.log
echo "Script has been forced to run as if the userid was root." >> emgr.out
S_USERID=root
else
isRoot
fi
execute
endLog