PATH="/usr/local/bin:/usr/bin:/sbin:/usr/X11R6/bin:/usr/sbin:/bin:/usr/games"
SCRIPT_PATH=/usr/local/sa/agent/kill.sh
BASE_DIR=/usr/local/sa/agent
PS_INFO=$BASE_DIR/secubase/secu-tcs-ps.info
MON_LOG=$BASE_DIR/secubase/secu-tcs-ps.log
LIMIT_FILE=$BASE_DIR/secubase/secu-tcs-ps.lmt
RESTART_FILE=$BASE_DIR/secubase/secu-tcs-restart.cnt
if [ -e ${MON_LOG} ]; then
LOG_FILE_SIZE=`stat --format=%s ${MON_LOG}`
if [ $LOG_FILE_SIZE -gt 10240 ]; then
# 获取pid为1的进程的mnt namespace inode
if [ -L /proc/1/ns/mnt ]; then
PID1_MNT_NS_INODE=$(readlink /proc/1/ns/mnt)
CUR_TIME=`date +"%Y-%m-%d %H:%M:%S"`
echo "[$CUR_TIME] $1" >> $MON_LOG
if [ -z "$PID1_MNT_NS_INODE" ]; then
LIST_WATCH_DOG_PID=`ps -efw | grep "watchdog\.sh" | grep $BASE_DIR | grep -v grep | awk -F ' ' '{print $2}'`
for watchdog_pid in $LIST_WATCH_DOG_PID
LIST_AGENT_PID=`ps -efw | grep -E "${PROC_NAME}($|[[:space:]]+)" | grep $BASE_DIR | grep -v grep | awk -F ' ' '{print $2}'`
for agent_pid in $LIST_AGENT_PID
LIST_WATCH_DOG_PID=`ps -efw | grep "watchdog\.sh" | grep $BASE_DIR | grep -v grep | awk -F ' ' '{print $2}'`
for watchdog_pid in $LIST_WATCH_DOG_PID
WATCHDOG_MNT_NS_INODE=$(readlink /proc/${watchdog_pid}/ns/mnt)
if [ "$WATCHDOG_MNT_NS_INODE" = "$PID1_MNT_NS_INODE" ]; then
LIST_AGENT_PID=`ps -efw | grep -E "${PROC_NAME}($|[[:space:]]+)" | grep $BASE_DIR | grep -v grep | awk -F ' ' '{print $2}'`
for agent_pid in $LIST_AGENT_PID
AGENT_MNT_NS_INODE=$(readlink /proc/${agent_pid}/ns/mnt)
if [ "$AGENT_MNT_NS_INODE" = "$PID1_MNT_NS_INODE" ]; then