面试题大全,快来分享哦!
这样就可以了,里面偶尔涉及到权限问题。一般./ssh文件夹是755 authorized_keys为 600或者644
####脚本如下#######################
#!/bin/bash
#SCRIPT:df_check.sh
#Writeen by codfei Mon Sep 3 07:25:28 CST 2007
#PURPOSE:This script is used to monitor for full filesystems.
#######################Begining####################
####################
FSMAX="80"
remote_user='root' #####完全可以不用root
remote_ip=(192.168.1.5 192.168.1.6 192.168.1.7 192.168.1.8 192.168.1.9
192.168.1.10 192.168.1.11 192.168.1.12 192.168.1.13 192.168.1.14 ) >
这里填写你要监控的主机ip
ip_num='0'
while [ "$ip_num" le "$(expr ${#remote_ip[@]} 1)" ]
do
read_num='1'
ssh "$remote_user"@"${remote_ip[$ip_num]}" df h > /tmp/diskcheck_tmp
grep '^/dev/*' /tmp/diskcheck_tmp|awk '{print $5}'|sed 's/\%//g' >
/tmp/diskcheck_num_tmp
while [ "$read_num" le $(wc l < /tmp/diskcheck_num_tmp) ]
do
size=$(sed n "$read_num"'p' /tmp/diskcheck_num_tmp)
if [ "$size" gt "$FSMAX" ]
then
$(grep '^/dev/*' /tmp/diskcheck_tmp|sed n $read_num'p' >
/tmp/disk_check_mail)
$(echo ${remote_ip[$ip_num]} >> /tmp/disk_check_mail)
$(mail s "diskcheck_alert" admin < /tmp/disk_check_mail)
fi
read_num=$(expr $read_num + 1)
done
ip_num=$(expr $ip_num + 1)
done
#############over################################
################让脚本每十分钟执行一次#############
在cron表中加入
0/10 * * * * /home/codfei/diskcheck.sh 2>&1