#!/bin/bash
#用途:监控磁盘的使用情况。
#定义检查磁盘的空间使用率函数
user=root
topnum=10
local_diskdir=/data/jiankong/disk
mkdirdisk()
{
if [ ! -d $disktmpdir ];then
mkdir $disktmpdir
fi
}
chk_sp()
{ip=$1n=$(wc -l $local_diskdir/$ip/chk_sp.log | awk '{print $1}')if [ $n -gt 0 ]then echo -e "$ip:">>$local_diskdir/most_sp.txtcat $local_diskdir/$ip/chk_sp.log>>$local_diskdir/most_sp.txt#>>$local_diskdir/most_sp.txt#for d in `awk -F ' ' '{print $2}' $disktmpdir/$ip/chk_sp.log`#do # find $d -type d | sed '1d' | xargs du -sm | sort -nr | head -3# done >> $local_diskdir/most_sp.txtelseecho -e "$ip无磁盘使用率大于90%!!"fi }
remote_ssh()
{ip=$1
# ssh $ip df -m | sed '1d' | awk -F '% | +' '$5>10 {print $5,$6}'ssh $ip df -m | sed '1d' | awk -F '% | +' '$5>90 {print $5,$6}'>$local_diskdir/$ip/chk_sp.log
}
remote_ssh *>$local_diskdir/most_sp.txt
chk_sp *cat $local_diskdir/most_sp.txt