linux 环境下的脚本chktux.sh 用户 可以查看到 tuxedo服务的运行情况,如果有异常,会输出到屏幕上!?下面是脚本内容,谁能解释一下!
#!/bin/ksh
ChkServer()
{
echo "`date "%Y/%m/%d/%H:%M:%S"`===========================begin check=============================" | tee -a $ERRFILE
SERVLIST=$2
UUID=`id -u $USER`
for proc_name in $SERVLIST
do
if [ "$1" = "TUXEDO" ];then
proc_num=`ps -fu $UUID |grep $USER|grep -v grep|grep -c " $proc_name "`
else
proc_num=`ps -fu $UUID |grep $USER|grep -v grep|grep -c " $proc_name"`
fi
if [ "$proc_num" -eq "0" ] ; then
echo `date "%Y/%m/%d/%H:%M:%S"`" server \t\t[ $proc_name ] \t\tINACT !!!" | tee -a $ERRFILE
fi
done
#ULOG重启失败检查
ULOG=/cpic/$USER/log/ULOG."`date %m%d%y`"
echo "`grep ''tpsvrinit() failed'' $ULOG `" | tee -a $ERRFILE
echo "`date "%Y/%m/%d/%H:%M:%S"`===========================end check===============================" | tee -a $ERRFILE
}
SHOW_TUXEDO ()
{
ChkServer "TUXEDO" "DMADM GWADM GWTDOMAIN BBL WSL"
}
USER=$1
ERRFILE="$HOME/chktux.log"
if [ ! -f $ERRFILE ];then
> $ERRFILE
fi
SHOW_TUXEDO
**************************华丽分割线***************************
终于知道答案:
上面的脚本内容 按下面的 顺序就可以很好理解了:
#!/bin/ksh
USER=$1 #这个是变量,为了接入 ./chktux.sh 后面跟的用户名,$1 就是
ERRFILE="$HOME/chktux.log"
if [ ! -f $ERRFILE ];then
> $ERRFILE
fi
(判断如果不存在$HOME/chktux.log 这个文件,就创建一个.)
SHOW_TUXEDO
SHOW_TUXEDO ()
{
ChkServer "TUXEDO" "DMADM GWADM GWTDOMAIN BBL WSL"
}
ChkServer()
{
echo "`date "%Y/%m/%d/%H:%M:%S"`===========================begin check=============================" | tee -a $ERRFILE
SERVLIST=$2
UUID=`id -u $USER`
for proc_name in $SERVLIST
do
if [ "$1" = "TUXEDO" ];then
proc_num=`ps -fu $UUID |grep $USER|grep -v grep|grep -c " $proc_name "`
else
proc_num=`ps -fu $UUID |grep $USER|grep -v grep|grep -c " $proc_name"`
fi
if [ "$proc_num" -eq "0" ] ; then
echo `date "%Y/%m/%d/%H:%M:%S"`" server \t\t[ $proc_name ] \t\tINACT !!!" | tee -a $ERRFILE
fi
done
#ULOG重启失败检查
ULOG=/cpic/$USER/log/ULOG."`date %m%d%y`"
echo "`grep ''tpsvrinit() failed'' $ULOG `" | tee -a $ERRFILE
echo "`date "%Y/%m/%d/%H:%M:%S"`===========================end check===============================" | tee -a $ERRFILE
}
|