标签:stp art exec ams fdisk -l host turn ruby start
#安装gems包:net-ssh
#方法名称:get_disk_size
#作用:获取/dev/sda分区的大小
#作者: xiaowei
require ‘net/ssh‘
def get_disk_size(params={})
hostip = params[:hostip] #
hostuser = params[:hostuser]
hostpasswd = params[:hostpasswd]
command = params[:command]
ssh = Net::SSH.start(hostip,hostuser,:password=>hostpasswd)
ret = ssh.exec!(command)
ret =~ /disk\s+\/dev\/sda:\s+(\d+\.\d)\s+GB/i
return $1.to_f
end
p get_disk_size(
:hostip => "192.168.255.129",
:hostuser => "root",
:hostpasswd => "redhat",
:command => "fdisk -l"
)
标签:stp art exec ams fdisk -l host turn ruby start
原文地址:http://www.cnblogs.com/xw1104/p/7043794.html