Accueil > Uncategorized > Showing kernel modules dependencies graphically using graphviz

Showing kernel modules dependencies graphically using graphviz

A few time ago, I had problems with my sound card module on my new linux laptop, I did not understand well how modules were loaded.

I finally solved my problem, but I was curious about the modules depency structure, and I started playing with graphviz to have a graphical view of that.

I finally came with this small & dirty python script :

#!/usr/bin/python
# -*-coding:utf-8-*-
import os, re
#usual usage is : ./mods_graph.py | dot -Tpng > modules.png

print 'digraph linux_modules {'
lines = [line for line in os.popen('lsmod')]
for line in lines[1:] :
    line = [x for x in re.split('\ |,', line.replace('\n','')) if not len(x)==0]
    for dep in line[3:]:
        print '\t' + line[0] + ' -> ' + dep + ';'
print '}'
exit(0)

It reads the dependencies between the linux modules by calling lsmod(8), and then formats the output into a file acceptable by the dot utility, from the graphviz package.

The png output is quite cool, … And you can see how complex the sound handling is under linux compared to video !!

The other conclusion is to see how fast and easy it is to generate graphs using graphviz !

Publicités
Catégories :Uncategorized
  1. Aucun commentaire pour l’instant.
  1. No trackbacks yet.

Laisser un commentaire

Choisissez une méthode de connexion pour poster votre commentaire:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

w

Connexion à %s

%d blogueurs aiment cette page :