Using Perl and Graphviz to simplify your busy life

We all have to create topology diagrams, high level visual representations of our thoughts or environments (or software solutions etc) from time to time, for as they say – “A picture is worth a thousand words”.

The Graphviz software ( provides us a simple and elegant way to do so, which with a little bit of practice can make a huge difference in time saved. It also lets us take safe shortcuts, where in we bypass the entire cumbersome process of creating visio diagrams ( or some other tool). And do this instead:

Input Configuration file:

cluster11:web:web2:New York
cluster12:middleware:mid2:New York
cluster13:db:db2:New York

Having prepared this type of configuration file (which should take a few minutes), run the script given below to generate the “dot” code needed to generate the diagrams. If you use a wiki (which should be all but ubiquitous in IT by now), most modern wikis (eg: mediawiki, dokuwiki) come with plugins for graphviz. The “dot” code generated by the script can then be pasted into your wiki page and an associated graphviz image will be displayed.

Run the script as follows:

 $ ./ –cfg=”./graphit.cfg” –output=/tmp/

This will generate the necessary framework for your diagram. You do still need to know the “Dot” language in order to edit/modify/improve on the code, but this script will do the bulk of your work for you.  However, that is provided you are drawing topology diagrams (as shown here, in a similar format).

Feel free to pull the script from the git repo here and use/modify it as you deem fit:


The script:


The Dot code:


And the diagram looks like this (needs to tweaked further), provided my graphviz plugin works :


Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.