互联网服务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%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

4同行回答

xw721xwxw721xw系统架构师北明软件
回复 4# 午夜幽魂     这种说法只有在AIX版本5,3盛行的时候才勉强说得过去哦,而现在,有几家的AIX版本不会在5,3以上或者6,甚至7!这个脚本,从开始就声明,只是不支持5。2(代码第9行有说明)而已哦!另外,亲测,我在安装AIX6的机器上直接运行此代码所携带的脚本包,没有报错,并且能...显示全部
回复 4# 午夜幽魂


    这种说法只有在AIX版本5,3盛行的时候才勉强说得过去哦,而现在,有几家的AIX版本不会在5,3以上或者6,甚至7!这个脚本,从开始就声明,只是不支持5。2(代码第9行有说明)而已哦!
另外,亲测,我在安装AIX6的机器上直接运行此代码所携带的脚本包,没有报错,并且能得到所有预期的效果。:)收起
互联网服务 · 2013-07-01
浏览1200
午夜幽魂午夜幽魂系统运维工程师计算机有限公司
回复 3# xw721xw perl的一般的生产环境好像都没安装这个包吧,可能执行不了吧,没注意过,如果没安装,这个脚本就不太好普及呀。显示全部
回复 3# xw721xw

perl的一般的生产环境好像都没安装这个包吧,可能执行不了吧,没注意过,
如果没安装,这个脚本就不太好普及呀。收起
系统集成 · 2013-07-01
浏览1181
xw721xwxw721xw系统架构师北明软件
回复 2# 午夜幽魂     这个是一个aixcheck healthy 脚本,用perl写的,嗯,研究研究一下!:lol显示全部
回复 2# 午夜幽魂


    这个是一个aixcheck healthy 脚本,用perl写的,嗯,研究研究一下!:lol收起
互联网服务 · 2013-07-01
浏览1261
午夜幽魂午夜幽魂系统运维工程师计算机有限公司
兄弟,发的东西越来越深奥了,看不懂,啥意思呢??显示全部
兄弟,发的东西越来越深奥了,看不懂,
啥意思呢??收起
系统集成 · 2013-07-01
浏览1243

提问者

xw721xw
系统架构师北明软件

相关问题

相关资料

问题状态

  • 发布时间:2013-06-29
  • 关注会员:1 人
  • 问题浏览:10117
  • 最近回答:2013-07-01
  • X社区推广