monitor_guiagent
monitor_guiagent
monitor_guiagent.sh
#!/usr/bin/env bash
#filename : monitor_guiagent.sh
#Usage: /usr/bin/nohup /var/hgans/gui/ans_php_env/monitor_guiagent.sh >/dev/null 2>/dev/null & #
# Append the following command to the rc.local for running monitor_guiagent.sh :
# /bin/ps -waux | /usr/bin/grep "monitor_guiagent" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' | /usr/bin/xargs /bin/kill -9
# /bin/ps -waux | /usr/bin/grep "/var/hgans/gui/agent" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' | /usr/bin/xargs /bin/kill -9
# /usr/bin/nohup /var/hgans/gui/ans_php_env/monitor_guiagent.sh >/dev/null 2>/dev/null &
# PS="/bin/ps"
KILL="/bin/kill"
GREP="/usr/bin/grep"
AWK="/usr/bin/awk"
WC="/usr/bin/wc"
TAIL="/usr/bin/tail"
HEAD="/usr/bin/head"
XARGS="/usr/bin/xargs"
ANSCLI="/hgans/anscli"
DATE_EXEC="/bin/date" ANSLOG_FILE="/var/anslog/ans.log"
USER_NAME="%%:ansroot:."
SHOW_SYS_SESSION="show system session -summary"
KILL_ALL_SYS_SESSION="kill system session -all"
KILL_SID_SYS_SESSION="kill system session "
CLEAR_SYS_SESSION_FLAG_FILE="/flash/anscfg/.clear_sys_session"
MAX_SYS_SESSION=12 GUI_HOME="/var/hgans/gui"
HTTPD_DIR="ans_php_env"
RC_CONF_NAME="rc.conf"
RC_LOCAL_NAME="rc.local"
AGENT_DIR="agent"
ANSRAPI_EXEC_NAME="ansrapi_agent"
HGCLOUD_EXEC_NAME="hgcloud_proxy"
MANS_EXEC_NAME="mans_log"
NOTIFYLOG_EXEC_NAME="NotifyLog"
KILL_SIGNAL_NUMBER=9
SLEEP_SECOND_NUMBER=3 while true
do
arr_exec=($ANSRAPI_EXEC_NAME $HGCLOUD_EXEC_NAME $MANS_EXEC_NAME $NOTIFYLOG_EXEC_NAME)
arr_column=${#arr_exec[@]}
for (( i=0; i < ${arr_column}; i++ ))
do
exec_num=`$PS -waux | $GREP ${arr_exec[$i]} | $GREP -v grep | $WC -l`
if [ $exec_num -eq 0 ]; then
echo monitor_guiagent: `$DATE_EXEC +"%Y-%m-%d %H:%M:%S"`": Restart webgui agent process ${arr_exec[$i]} ..." >> $ANSLOG_FILE
$PS -waux | $GREP ${arr_exec[$i]} | $GREP -v grep | $AWK '{print $2}' | $XARGS $KILL $KILL_SIGNAL_NUMBER
${GUI_HOME}/${AGENT_DIR}/${arr_exec[$i]} >/dev/null 2>/dev/null &
fi
done current_system_session_line=`$ANSCLI -U $USER_NAME -s "$SHOW_SYS_SESSION" | $WC -l`
current_system_session_num=$((current_system_session_line-3))
if [ -f $CLEAR_SYS_SESSION_FLAG_FILE -a $current_system_session_num -gt $MAX_SYS_SESSION ]; then
arr_sid=(`$ANSCLI -U $USER_NAME -s "$SHOW_SYS_SESSION" | $TAIL -n $current_system_session_num | $AWK '{print $2}'`)
arr_column=${#arr_sid[@]}
for (( i=0; i < ${arr_column}; i++ ))
do
if [ $i -gt 3 ]; then
echo monitor_guiagent: `$DATE_EXEC +"%Y-%m-%d %H:%M:%S"`": Kill system session ${arr_sid[$i]} ..." >> $ANSLOG_FILE
$ANSCLI -U $USER_NAME -s "$KILL_SID_SYS_SESSION ${arr_sid[$i]}"
else
echo monitor_guiagent: `$DATE_EXEC +"%Y-%m-%d %H:%M:%S"`": Keep system session ${arr_sid[$i]} ..." >> $ANSLOG_FILE
fi
done
fi sleep $SLEEP_SECOND_NUMBER
done
rc.local
# This script auto start ansrapi_agent for NewGUI
/bin/ps -waux | /usr/bin/grep "monitor_guiagent" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' | /usr/bin/xargs /bin/kill -
/bin/ps -waux | /usr/bin/grep "/var/hgans/gui/agent" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' | /usr/bin/xargs /bin/kill -
/usr/bin/nohup /var/hgans/gui/ans_php_env/monitor_guiagent.sh >/dev/null >/dev/null &
root@HGANS# cd /var/hgans/gui/ans_php_env
root@HGANS# chmod +x monitor_guiagent.sh
root@HGANS# ps -waux | grep agent | grep -v grep
root@HGANS# ps -waux | grep agent | grep -v grep | awk '{print $2}'| xargs kill -
root@HGANS# ps -waux | grep agent | grep -v grep
root@HGANS# /usr/bin/nohup /var/hgans/gui/ans_php_env/monitor_guiagent.sh >/dev/null >/dev/null &
root@HGANS# ps -waux | grep agent | grep -v grep

root@HGANS# ps -waux | grep agent | grep -v grep
root@HGANS# ps -waux | grep ansrapi_agent | grep -v grep | awk '{print $2}'| xargs kill -
root@HGANS# ps -waux | grep agent | grep -v grep

========================== End
monitor_guiagent的更多相关文章
随机推荐
- 北京Uber优步司机奖励政策(11月9日~11月15日)
用户组:人民优步“关羽组”(适用于11月9日-11月15日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月 ...
- day 3 list列表生成式
1.定义一个list列表,里面元素是0-33 a = [] i = 0 while i<33: a.append(i) i+=1 print(a) [0, 1, 2, 3, 4, 5, 6, 7 ...
- redis 问题记录
摘抄来自:https://zhuoroger.github.io/ 1.slowlog和排队延时 slowlog是排查性能问题关键监控指标.它是记录Redis queries运行时间超时特定阀值的系统 ...
- spring + mybatis 注解 @Transactional失效
1.问题 在使用@Transactional注解管理事务的时候会出现很多错误,比如: *** was not registered for synchronization because synchr ...
- uvaoj 213 - Message Decoding(二进制,输入技巧)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Git与远程仓库关联以及关联错误解决方法
假设你github的用户名是 helloworld ,你在上面创建了一个 名为 hello 的 repository. 一. 与本地仓库进行关联 1.1用原生ssh进行关联,速度快: git re ...
- 棋盘问题:dfs
Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子 ...
- 利用人脸特征提取DeepID--解读世纪晟人脸识别
概述:DeepID的目标是人脸验证(判断两张图片是否是一个人),同时衍生出人脸识别(多次人脸验证). DeepID采用增大数据集的方法: 增加新的数据,celebFaces(87628张图片,5436 ...
- javascript打开新窗口
一.window.open()支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 二.基本语法: window.open(pageURL,name, ...
- HADOOP docker(三):HDFS高可用实验
前言1.机器环境2.配置HA2.1 修改hdfs-site.xml2.2 设置core-site.xml3.配置手动HA3.1 关闭YARN.HDFS3.2 启动HDFS HA4.配置自动HA4. ...