#!/bin/bash
`date >> ./disk.txt`
for host in w3 w4 mc5 n6 m7 m8 n12 m14 w15 w16 mc17
do
MAX_mem=95
MAX_swap=20
Men=`ssh $host free | awk '/Mem/ '`
SWAP=`ssh $host free | awk '/Swap/ '`
IP=`ssh $host ifconfig eth0 |awk 'NR>1 && NR
if [ $Men -gt $MAX_mem -o $SWAP -gt $MAX_swap ];then
echo "Server $IP use Men $Men% SWAP $SWAP%,Please deal with [waring]" >> ./disk.txt
else
echo "Server $IP use Men $Men% SWAP $SWAP%[OK]" >> ./disk.txt
fi
done
# w117 w120 men swap巡检
for host in w117 w120
do
MAX_mem=95
MAX_swap=20
Men=`ssh $host free | awk '/Mem/ '`
SWAP=`ssh $host free | awk '/Swap/ '`
IP=`ssh $host ifconfig em1 |grep Bcast |awk -F ":" '' |cut -d " " -f 1`
if [ $Men -gt $MAX_mem -o $SWAP -gt $MAX_swap ];then
echo "Server $IP use Men $Men% SWAP $SWAP%,Please deal with [waring]" >> ./disk.txt
else
echo "Server $IP use Men $Men% SWAP $SWAP%[OK]" >> ./disk.txt
fi
done
# w55 men swap巡检
MAX_mem=95
MAX_swap=20
Men=`ssh w55 free | awk '/Mem/ '`
SWAP=`ssh w55 free | awk '/Swap/ '`
IP=`ssh w55 ifconfig em2 |grep netmask |awk ''`
if [ $Men -gt $MAX_mem -o $SWAP -gt $MAX_swap ];then
echo "Server $IP use Men $Men% SWAP $SWAP%,Please deal with [waring]" >> ./disk.txt
else
echo "Server $IP use Men $Men% SWAP $SWAP%[OK]" >> ./disk.txt
fi
领取专属 10元无门槛券
私享最新 技术干货