expect提取性能数据cpu/disk/mem

#!/usr/bin/expect

set timeout 5

foreach i {192.168.3.8 192.168.3.100} {

spawn ssh root@$i


expect {


"*yes/no" { send "yes\r"; exp_continue}


"*password:" { send "vision\r" }


}

expect "]*"

send "mkdir -p /root/${i}performance\r"

expect "]*"

send "free -m >/root/${i}performance/mem.txt\r"

expect "]*"

send "df -Th >/root/${i}performance/diskmem.txt\r"

expect "]*"

send "top -bn1 | grep 'Cpu(s)' >/root/${i}performance/cpu.txt\r"

sleep 1

spawn scp -rp  $i:/root/${i}performance /root/


expect "*password*"

send "vision\r"


expect eof

sleep 2

}







本文转自chenzudao51CTO博客,原文链接:http://blog.51cto.com/victor2016/1915392 ,如需转载请自行联系原作者


上一篇:谷歌数据中心在用这种CPU 比传统快70倍


下一篇:不懂得如何优化CNN图像分类模型?这有一份综合设计指南请供查阅