-
-
Save fujin/143318 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/ruby | |
| # Requirements | |
| require "csv" | |
| file = File.open("/tmp/play.dot","w") | |
| file.puts "graph G { " | |
| #file.puts "\trankdir=LR " | |
| file.puts "\tratio=expand;" | |
| #file.puts "\tnode [shape=record];" | |
| #file.puts "\tnode [shape=tab shapefile=\"/usr/share/dia/shapes/Network/router-symbol.png\"];" | |
| CSV.open("site_list.csv", "r") do |records| | |
| parents = records[4].strip.split(',') | |
| parents.each do |parent| | |
| parent && parent.strip! | |
| host = records[0].strip | |
| hostname = records[0].strip | |
| ipaddr = records[2].strip | |
| puts "Parent is #{parent} and host is #{host} and ip is #{ipaddr} and name is #{hostname}" | |
| file.puts "\t\"#{host}\" [bottomlabel=\"#{host}\"];" | |
| # image=\"/usr/share/dia/shapes/Network/router-symbol.png\"];" | |
| ##### | |
| #file.puts "\t \"#{host}\" [label=< " | |
| #file.puts "\t <table border=\"0\" cellborder=\"1\" cellspacing=\"0\"> " | |
| #file.puts "\t <tr> " | |
| #file.puts "\t <td href="\"#{hostname}\"];" | |
| file.puts "\t\"#{parent}\" -- \"#{host}\"" | |
| end | |
| end | |
| time = Time.now | |
| #file.puts "label = \"\n\n\(C\) Kanji Group Pty Ltd\n\nCreated #{time}\" ;" | |
| #file.puts "fontsize=20;" | |
| #file.puts "overlap=false;" | |
| file.puts "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment