reviving router script
This commit is contained in:
@ -4,22 +4,23 @@ require "net/ssh"
|
||||
class Routers
|
||||
|
||||
@@start_address = "10.20.20."
|
||||
@@start_at = 20
|
||||
@@stop_at = 85
|
||||
@@start_at = 32
|
||||
@@stop_at = 130
|
||||
|
||||
def initialize
|
||||
@at = @@start_at
|
||||
end
|
||||
|
||||
# full ip address, ie start_address + @at
|
||||
def at
|
||||
@@start_address + @at.to_s
|
||||
end
|
||||
|
||||
# print info for each ip
|
||||
def print( info )
|
||||
info = "host_name" unless info
|
||||
def print( info = nil)
|
||||
each_router do |ip , connection|
|
||||
message = send(info.to_sym , connection)
|
||||
message = host_name( connection)
|
||||
message += " " + send(info.to_sym , connection).to_s if info
|
||||
puts "#{ip} = #{message}"
|
||||
end
|
||||
end
|
||||
@ -78,6 +79,11 @@ class Routers
|
||||
connection.exec!( "uci get system.@system[0].hostname").strip
|
||||
end
|
||||
|
||||
# check if cron
|
||||
def get_cron(connection)
|
||||
connection.exec!( "cat /etc/crontabs/root" ).strip
|
||||
end
|
||||
|
||||
# get the admin name, ie the dhcp name of the admin interface
|
||||
def admin_name(connection)
|
||||
connection.exec!( "uci get network.admin.hostname").strip
|
||||
@ -96,9 +102,6 @@ class Routers
|
||||
nets.lines.collect{|line| line.split("=").last.strip}#.join(",")
|
||||
end
|
||||
|
||||
def get_info(connection)
|
||||
{machine: machine(connection) , host_name: admin_name(connection)}
|
||||
end
|
||||
# takes a block and yields ip and connection to
|
||||
# every succesful connection
|
||||
def ips(live_only = true)
|
||||
|
Reference in New Issue
Block a user