Alban’s blog

March 8, 2008

How to make a diagram from dbus-monitor logs

Filed under: Uncategorized — alban @ 6:24 pm

“The dbus-monitor command is used to monitor messages going through a D-Bus message bus” (manpage). But when there is several connections on the bus and lots of method calls and signals, the output is not easily readable. Sometimes I draw a diagram on a piece of paper: it helps me to understand what happens. But it would be better to have diagrams drawn automatically.

This can be achieved with Mscgen (patched to draw D-Bus signals) and some scripts. Mscgen is a simple tool to generate diagrams from a simple text file with a simple syntax. Text files can be put in a SCM.

I wrote a python script that listens on the bus and writes the .msc file.

Example with Quod Libet:

Example with Telepathy:

The python script has a DBusMessagesBox object. I can filter D-Bus connection I don’t want to draw. In this example, I don’t print messages from or to the script itself. I can filter message from or to the dbus-daemon.

The script choose the right name (”salut” instead of “:1.15″). Some programs requests several connection names on the session bus. In this case, you can choose the prefered name with the ‘prefered_names’ option.

   #skip_entities = set(“DBusMessagesBox”, “DBus”)    skip_entities = set(“DBusMessagesBox”)    options = { ’skip_entities’ : skip_entities, \                ‘prefered_names’ : ‘gabble’, ’salut’, ‘ChatFilter’ }
   box = DBusMessagesBox(options)    box.start_recording()    try:        gtk.main()    except:        print
   box.stop_recording()
   box.parse("/tmp/file.msc")    os.system("mscgen -T png -i /tmp/file.msc -o /tmp/file.png")

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress