码迷,mamicode.com
首页 > 系统相关 > 详细

进程监控脚本

时间:2014-10-11 23:25:07      阅读:329      评论:0      收藏:0      [点我收藏+]

标签:shell   监控   

#!/bin/sh

my_ip=`/sbin/ifconfig eth1 | grep 'inet addr' | awk  '{print substr($2, index($2, ":")+1)}'`
recv=""
msg="not_existing, restart ..."
MONITOR_LOG="monitor.log"


#monitor procname scriptname
monitor()
{
        # 查找进程
    pgrep ^$1$ > /dev/null

    # 如果不存在, 就重启他.
    if [ $? -ne 0 ] ; then
                echo "`date` ${my_ip}.$1 $msg";
        $2 restart
    fi

    sleep 2
}

echo "`date` monitor begin ..." >> ../log/monitor.log

monitor "server" "/home/rti/rti/scripts/Server.sh" >> ${MONITOR_LOG}
monitor "connector" "/home/rti/rti/scripts/Connector.sh" >> ${MONITOR_LOG}

echo "`date` monitor end ..." >> ../log/monitor.log

进程监控脚本

标签:shell   监控   

原文地址:http://blog.csdn.net/ahyswang/article/details/40002089

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!