liunx server monitoring script (monitoring nginx, php-fpm, mysql)

#!/bin/bash
ip=$(ifconfig eth0 | awk -F'addr:|Bcast' '/Bcast/{print $2}')
num = `ps aux | grep php-fpm | grep -v grep | wc -l`
if [ $num -eq 0 ];then
        php alarm.php  "php-fpm is not running on $ip"
        /etc/init.d/php-fpm start
be

num = `ps aux | grep nginx | grep -v grep | wc -l`
if [ $num -eq 0 ];then
        php alarm.php  "nginx is not running on $ip"
        /etc/init.d/nginx start
be

cmd=`/usr/local/mysql/bin/mysqladmin -h127.0.0.1 -uroot -proot ping`
echo "$cmd" | grep -q "alive"
if [ $? -ne 0 ];then
        php alarm.php  "mysql is not running on $ip"
        /etc/init.d/mysql start
be

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326685372&siteId=291194637