互联网服务Sybaseaix 7

AIXcheckall-解析(1)

# # VARIABLES # # Unalias everything - just in case. unalias -a # Start time. # date +"%s" does not work on AIX 5.2. # STARTTIME=`date +"%s" 2>/dev/null` STARTTIME=`perl -le 'print time' 2>/dev/null` STARTTIMEERRPT=`perl -MPOSIX -le 'print strftime "%m%d%H%M%...显示全部
#
# VARIABLES
#

# Unalias everything - just in case.
unalias -a

# Start time.
# date +"%s" does not work on AIX 5.2.
# STARTTIME=`date +"%s" 2>/dev/null`
STARTTIME=`perl -le 'print time' 2>/dev/null`
STARTTIMEERRPT=`perl -MPOSIX -le 'print strftime "%m%d%H%M%y",localtime(time)'`
if [ -z "${STARTTIME}" ] ; then
        echo "Perl is not working properly. Aborting."
        exit 1
fi

export STARTTIME
mydate=`date +"%m/%d/%Y"`
mytime=`date +"%H:%M:%S"`
export mydate mytime

# Clear the list of scripts.
unset ScriptsList
export ScriptsList

# Helper variable for scripts.
let mins=0
export mins

# Clear the list of email addresses.
unset eMailList
export eMailList

# The variable counters to store results for each return code.
let TOTALNR=0 #TOTAL
let OKNR=0    #OK
let WARNNR=0  #WARNING
let ERRORNR=0 #ERROR
export TOTALNR OKNR WARNNR ERRORNR

# The hostname. 
MY_HOST_NAME=`uname -a | awk '{ print $2 }'`
export MY_HOST_NAME

# The default file location.
myoutput=checkall_${MY_HOST_NAME}
OUTPUT=${myoutput}.log
export myoutput
unset LogFile
export LogFile
export csvon=false
export htmlon=false
export logfileon=true
export email100=false
export basic=false

# Width of output - default set to 130 characters.
let mywidth=130
export mywidth

# Write descriptions to output? Default set to false.
writedesc=false
export writedesc

# Suppress all checks that have returncode 0? Default set to false.
suppressok=false
export suppressok

# Default set verbose to false.
verboseon=false
export verboseon

#
# End of VARIABLES
#


#
# FUNCTIONS
#

# Function filler is used to display a line of comments up to ${mywidth}.

filler(){
        # Export character so perl can use it.
        export mychar=${1}
        if [ "${verboseon}" = "true" ] ; then
                perl -e 'print $ENV{"mychar"} x $ENV{"mywidth"};printf("n")' 
        fi
        if [ "${logfileon}" = "true" ] ; then
                perl -e 'print $ENV{"mychar"} x $ENV{"mywidth"};printf("n")'  >> ${OUTPUT}
        fi
        # Function filler is not used for CSV and HTML output.
}

# Function verbose is used to get this script to log in a consistent way.

verbose(){
        string=${1}
        unset mytimestamp
        mytimestamp=${2}
        if [ -z "${mytimestamp}" ] ; then
                mytimestamp=`date "+%Y-%m-%d %H:%M:%S"`
        fi
        [ "${verboseon}" = "true" ] && echo "${mytimestamp}: ${string}" | fold -w ${mywidth}
        [ "${logfileon}" = "true" ] && echo "${mytimestamp}: ${string}" | fold -w ${mywidth} >> ${OUTPUT}
        # verbose is not used with CSV and HTML file output
}

# Function verbosehtml is used to get this script to log in a consistent way for HTML output.

verbosehtml(){
        [ "${htmlon}" = "true" ] && echo "
${1}
${2}
" >> ${OUTPUT}
}

# Function verbosehtmlwarning is used to get this script to log in a consistent way for HTML outputi for warning messages.

verbosehtmlwarning(){
        [ "${htmlon}" = "true" ] && echo "
${1}
${2}
" >> ${OUTPUT}
}

# Function description displays the description of the check script being run.

description(){
        if [ "${writedesc}" = "true" ] ; then
                echo
                [ "${verboseon}" = "true" ] && echo "Description:" && echo "------------" && echo && grep -p'**' ${file} DESCRIPTIONS | grep -v "^       script_name" | sed "s/script_description: //g" | sed "s/
//g" | fold -w ${mywidth}
        fi
}

# Function descriptionlog is used to log a script description to the log file.

descriptionlog(){
        if [ "${writedesc}" = "true" ] ; then
                [ "${logfileon}" = "true" ] && ( echo && echo "Description:" && echo "------------" && echo && grep -p'**' ${file} DESCRIPTIONS | grep -v "^       script_name" | sed "s/script_description: //g" | sed "s/
//g" | fold -w ${mywidth} ) >> ${OUTPUT}
        fi
}
收起
参与5

查看其它 3 个回答xw721xw的回答

xw721xwxw721xw系统架构师北明软件
回复 2# 午夜幽魂


    这个是一个aixcheck healthy 脚本,用perl写的,嗯,研究研究一下!:lol
互联网服务 · 2013-07-01
浏览1274

回答者

xw721xw
系统架构师北明软件

xw721xw 最近回答过的问题

回答状态

  • 发布时间:2013-07-01
  • 关注会员:1 人
  • 回答浏览:1274
  • X社区推广