Skip to content

Instantly share code, notes, and snippets.

@marcheiligers
Created November 30, 2014 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcheiligers/5b66512851889e82ab4c to your computer and use it in GitHub Desktop.
Save marcheiligers/5b66512851889e82ab4c to your computer and use it in GitHub Desktop.
SH2ac log
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