redis服务端的ip地址是192.168.0.171 
打开的端口是:7000 7001 7002 
安装的目录为:/data/redis-server
日志目录为:/data/redis-server/log

[root@test3 redis-server]# pwd
/data/redis-server
[root@test3 redis-server]# ls
7000  7001  7002  7003  log  monitor.sh  redis-3.0.3  redis-3.0.3.tar.gz  redis_mon.sh  redis-server  redis-trib.rb
[root@test3 redis-server]#











#!/bin/bash
#version 1.0
#name han
#email hz7726@163.com
脚本A:
yum install -y mutt postfix
/etc/init.d/postfix start
sed -i -n "s/inet_protocols = all/inet_protocols = ipv4/g" /etc/postfix/main.cf
/etc/init.d/postfix restart

function redres {
for i in $1 $2 $3
do

reds=`redis-cli -h 192.168.0.171  -c -p $i  monitor`
 if [ "$reds" == "OK" ]; then
     echo "is successs"
 else
      /data/redis-server/redis-server /data/redis-server/$i/redis.conf
    echo "is down" |mutt -s -a “日志文件” -- hz7726@163.com
  fi
done
  }
redres 7000 7001 7002



脚本B:
date=`date +%Y%m%d%H`
datadr="/data/redis-server"
logdir="/data/redis-server/log"
if [ ! -d $logdir ]; then mkdir -pv $logdir;fi
function redis_mon {
for redisport in $1 $2 $3
do
    ps -ef |grep "$redisport" | grep -v grep
  if [ $?  -eq  0 ]; then
    echo " redis is success " >> $logdir/redis-${redis}-${date}.log
  else
     $datadr/redis-server  $datadr/$redisport/redis.conf
echo "is down" |mutt -s -a “日志文件” -- hz7726@163.com
    fi
done
}
redis_mon 7000 7001 7002


脚本C:
#cd $datadr
#redis7000="7000"
#redis7001="7001"
#redis7002="7002"
#ps -ef |grep "$redis7000" |grep -v grep
#if [ $? -eq 0 ]; then
#   echo "redis-7000 is norma"  > /dev/null 2>&1
#  else
#      echo "$data redis 7000 is down" >> ./log/redis-7000.log
echo "is down" |mutt -s -a “日志文件” -- hz7726@163.com
#    ./redis-server  ./$redis7000/redis.conf
#fi
#ps -ef |grep "$redis7001" |grep -v grep
#if [ $? -eq 0 ]; then
#   echo "redis-7001 is norma"  > /dev/null 2>&1
 # else
  #    echo "$data redis 7001 is down" >> ./log/redis-7001.log
echo "is down" |mutt -s -a “日志文件” -- hz7726@163.com
  #  ./redis-server  ./$redis7001/redis.conf
#fi
#ps -ef |grep "$redis7002" |grep -v grep
#if [ $? -eq 0 ]; then
#   echo "redis-7002 is norma"  > /dev/null 2>&1
#  else
#      echo "$date redis 7002 is down" >> ./log/redis-7002.log
echo "is down" |mutt -s -a “日志文件” -- hz7726@163.com
#    ./redis-server  ./$redis7002/redis.conf
#fi
三个脚本实现的功能是一样的 ,脚本仅供参考 ,