标签:linux_disk
# Input parameters PROGNAME=`basename $0` REVISION=v1.00 HOST=$1 TYPE=$2 ONE=`df -Ph | sed -n ‘2p‘|awk ‘{print "Size:"$6"="$2,"Used="$3,"Avail="$4,"Use%="$5 }‘` TWO=`df -Ph | sed -n ‘3p‘|awk ‘{print "Size:"$6"="$2,"Used="$3,"Avail="$4,"Use%="$5 }‘` THREE=`df -Ph | sed -n ‘4p‘|awk ‘{print "Size:"$6"="$2,"Used="$3,"Avail="$4,"Use%="$5 }‘` FOUR=`df -Ph | sed -n ‘5p‘|awk ‘{print "Size:"$6"="$2,"Used="$3,"Avail="$4,"Use%="$5 }‘` ssh_fetch() { /usr/bin/expect<< EOF |grep Size|sed -n ‘1p‘|awk ‘{print $3,$4,$5,$6," "$7,$8,$9,$10," "$11,$12,$13,$14," "$15,$16,$17,$18}‘ set timeout 120 spawn ssh root@$HOST expect "yes/no" { send "yes\r" expect "*?assword" { send "$TYPE\r" } #$TYPE的值需要自己输入对应下面测试那里7.164后面的password(请输入自己ssh需要连接那台机的password) } "*?assword" { send "$TYPE\r" } expect "#" send "$ONE, $TWO, $THREE, $FOUR\r" #注:逗号后面有空格 expect "#" send "exit\r" exit EOF } ssh_fetch
测试:./xiao.sh 192.168.7.164 password Size:/=50G Used=6.3G Avail=41G Use%=14%, Size:/dev/shm=936M Used=88K Avail=936M Use%=1%, Size:/boot=485M Used=54M Avail=407M Use%=12%, Size:/home=72G Used=183M Avail=68G Use%=1%
标签:linux_disk
原文地址:http://liuxiaolan.blog.51cto.com/7789055/1618627