modgraph.rb 894 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/ruby
  2. # display the kernel module dependencies
  3. #based on: modgraph.tcl by: John Ellson <[email protected]>
  4. #ruby adaptation by: Patricio Ros <[email protected]>
  5. #additional fixes: Ralph Mueller <[email protected]>
  6. require 'gv'
  7. G = Gv.digraph("G")
  8. N = Gv.protonode(G)
  9. E = Gv.protoedge(G)
  10. Gv.setv(G, 'rankdir', 'LR')
  11. Gv.setv(G, 'nodesep', '0.05')
  12. Gv.setv(N, 'shape', 'box')
  13. Gv.setv(N, 'width', '0')
  14. Gv.setv(N, 'height', '0')
  15. Gv.setv(N, 'margin', '.03')
  16. Gv.setv(N, 'fontsize', '8')
  17. Gv.setv(N, 'fontname', 'helvetica')
  18. Gv.setv(E, 'arrowsize', '.4')
  19. modules = File.open('/proc/modules', mode="r").readlines
  20. modules.each {|rec|
  21. fields = rec.split(' ')
  22. n = Gv.node(G, fields[0])
  23. fields[3].split(',').each {|usedby|
  24. Gv.edge(n, Gv.node(G, usedby)) if (usedby != '-') and (usedby != '')
  25. }
  26. }
  27. Gv.layout(G, 'dot')
  28. Gv.render(G, 'xlib')