检查db2sysc进程脚本
执行方式:sh scripts.sh hostname="TEST01" ip="198.145.0.122" check="failed/true"
脚本参数详解:
hostname="" ---执行主机的主机名
ip="" ---执行主机的IP地址
check="" ---failed(执行)true(查看)
脚本内容:
#! /bin/sh
################################################
#return 1 and echo "cmbc-script-success"
#return 0 and echo "cmbc-script-failure"
################################################
hostname=""
ip=""
check=""
script=$0
function DB2syscCheck {
if [[ $check = "true" ]];then
cat $script
return 0
else
db2sysc=`ps -ef |grep db2sysc |grep -v zabbix |grep -v grep |wc -l`
#return=`echo $?`
if [[ $db2sysc -eq 0 ]];then
echo "Number of processes:$db2sysc"
echo "DB2-process-check-script-failure"
return 0
else
echo "Number of process-check-script-success"
return 0
fi
fi
}
############################################# Script logcation parameter value check
while [[ $# -ne 0 ]]
do
opt_name=$(echo $1 |awk -F= '{print $1}')
opt_value=$(echo $1 |awk -F= '{print $2}')
case $opt_name in
hostname)
if [[ -n $opt_value ]];then
hostname=$opt_value
echo "opt_name=$opt_name opt_value=$opt_value"
[[ $opt_name !=$(hostname) ]] && echo "hostname-check-failure" && exit 1|| echo "hostname-check-success"
else
echo "$opt_name cat not be null"
exit 1
fi
;;
ip)
if [[ -n $opt_value ]];then
ip=$opt_name
echo "opt_name=$opt_name opt_value=$opt_value"
else
echo "$opt_name cat not be null"
exit 1
fi
;;
exech)
if [[ -n $opt_value ]];then
mmchecksh=$opt_value
echo "opt_name=$opt_name opt_value=$opt_value"
else
echo "$opt_name cat not be null"
exit 1
fi
;;
appname)
if [[ -n $opt_value ]];then
appname=$opt_value
echo "opt_name=$opt_name opt_value=$opt_value"
else
echo "$opt_name cat not be null"
exit 1
fi
;;
action)
if [[ -n $opt_value ]];then
action=$opt_value
echo "opt_name=$opt_name opt_value=$opt_value"
else
echo "$opt_name cat not be null"
exit 1
fi
echo "opt_name=$opt_name opt_value=$opt_value"
;;
check)
[[ $opt_name != true ]] && [[ $opt_value != false ]] && ech0 "echo value is true or false!!!" && exit 1
echo "opt_name=$opt_name opt_value=$opt_value"
check=$opt_value
;;
*)
echo "ERROR: you provide a non-exist paramter, paramter name is $opt_name,value is $opt_value!!!" && exit 1
;;
esac
shift
done
[[ $check != true ]] && [[ $check != false ]] && echo "check value is true or false!!!" && exit 1
exelog="/tmp/cmbc_app_${action}_${hostname}_${appname}.log"
############################################# Call vg_check_status and vgact action function
DB2syscCheck