Created
November 30, 2014 11:53
-
-
Save marcheiligers/5b66512851889e82ab4c to your computer and use it in GitHub Desktop.
SH2ac log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'nokogiri' | |
def log(name, url) | |
time = Time.now | |
html = HTTParty.get(url) | |
doc = Nokogiri::HTML(html) | |
body = (doc/"table tbody") | |
data = body.children.map { |r| r.children.map { |c| c.text.strip }.join(" ") }.reject { |t| t.nil? || t.to_s.squeeze.strip == "" } | |
puts "#{name} fetched at #{time}" | |
puts data | |
puts | |
File.open("vm_log.log", "a") do |f| | |
f.puts "#{name} fetched at #{time}" | |
f.puts data | |
f.puts | |
end | |
end | |
while(true) | |
log "Downstream", "http://192.168.0.1/cgi-bin/VmRouterStatusDownstreamCfgCgi" | |
log "Upstream", "http://192.168.0.1/cgi-bin/VmRouterStatusUpstreamCfgCgi" | |
log "Network log", "http://192.168.0.1/cgi-bin/VmRouterStatusEvLogCfgCgi" | |
puts | |
print "|" + (" " * 60) + "|" | |
print "\r|" | |
count = 0 | |
while count < 60 | |
print "." | |
count += 1 | |
sleep 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment