class Object
Constants
- CMD
- DHCP_HOST
- HOST
- KEY
- PARA1
- USER
- VMRUN
- VM_HOME
Public Instance Methods
exe(ssh, cmd)
click to toggle source
# File bin/dunst, line 23 def exe(ssh, cmd) output = '' ssh.exec!(cmd) do |channel, stream, data| output << "#{data}" if stream == :stdout end output end
get_ip(mac)
click to toggle source
# File bin/dunst, line 31 def get_ip(mac) Net::SSH.start(DHCP_HOST, USER, :password => KEY) do |ssh| l = exe(ssh, "cat /var/log/syslog | grep #{mac} | grep DHCPACK | tail -n1") if l.match(/on\s([0-9\.]*)\s/) $1 else '' end end end
ping(ip)
click to toggle source
# File bin/dunst, line 14 def ping ip begin r = `ping -c 1 -t1 -W1 #{ip} |grep packets` r.match(/transmitted, (.*?) packets/)[1].to_i == 1 rescue false end end