当前位置:   article > 正文

linux进程中monitor,linux进程监控,monitor脚本

linux中的monitor is stopped如何开启

由于服务器上一些进程莫名的挂掉,需要些一个monitor的bash脚本来监控这些进程:

#! /bin/bash

#chkconfig info

### BEGIN INIT INFO

# Provides:

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Description:

### END INIT INFO

MYSQL_NAME='mysql'

APACHE_NAME='http'

function check_process {

search_string=$1

search_result=`nmap localhost|grep -P $1'$'|awk '{print $3}'|grep $search_string`

echo $search_result

if [ "$search_result" = "$search_string" ]

then

echo $"Still exist!"

else

echo $"Not exist!"

/opt/lampp/lampp start >> /dev/null

echo $"Lampp restart!"

echo $"Lampp stop unexpectedly, now it restart by cron!" | mail -s "Breamweb error!" 13482746059@139.com

fi

}

case "$1" in

start)

/opt/lampp/lampp start

;;

stop)

/opt/lampp/lampp stop

;;

monitor)

check_process $MYSQL_NAME

check_process $APACHE_NAME

;;

esac

exit 0 crontab: */1 *  * * * /etc/init.d/ monitor >> /var/log/cron..monitor.log 2>&1 完

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/76492
推荐阅读
相关标签
  

闽ICP备14008679号