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优步司机奖励政策(2月25日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 北京Uber优步司机奖励政策(1月27日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 北京Uber优步司机奖励政策(12月10日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- ORB-SLAM(七)ORBextractor 特征提取
该类中主要调用OpenCV中的函数,提取图像中特征点(关键点及其描述,描述子,以及图像金字塔) 参考TUM1.yaml文件中的参数,每一帧图像共提取1000个特征点,分布在金字塔8层中,层间尺度比例1 ...
- 封装一个CSVHelper
public class CSVHelper { /// <summary> /// CSV转换成DataTable(OleDb数据库访问方式) /// </summary> ...
- lesson 16 Mary had a little lamb
lesson 16 Mary had a little lamb a little + 可数 小的;+ 不可数 少量的 对于动物在幼时都有不同的称呼: calf 小牛 lamb 羊羔 piglet 小 ...
- 1.1.0 Unity零基础入门2——Roll a Ball
1. 游戏界面 2.代码 //FoodRotate - - 控制cube旋转 using System.Collections; using System.Collections.Generic; u ...
- jQuery筛选器及对DOM修改(学习笔记)
1.jQuery筛选器 注意:请先在管理Nuget程序包中查找jQuery包,并安装.也可以在jQuery官网下载. 实现: <!DOCTYPE html> <html xmlns= ...
- Python的包(Packages)
包,Package,是一种Python模块的集合,从文件组织形式上看,包就是一个文件夹,里面放着各种模块(.py文件),也可以有子文件夹(子包).包名构建了一个Python模块的命名空间.比如,模块名 ...
- linux学习总结----mongoDB总结
dbhelper.py 用户登录和注册(加密算法) 加密导包 import hashlib 或者使用Md5 加密 MongoDB ->JSON service mysql start servi ...