码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-04-13 09:25:33      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:expect


#!/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

}


本文出自 “小V运维之路” 博客,谢绝转载!

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

标签:expect

原文地址:http://victor2016.blog.51cto.com/6768693/1915392

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!