Comment 2 for bug 272344

Revision history for this message
Jonathan Marsden (jmarsden) wrote :

Herewith a first attempt at a sysinfo/networks.py plugin, which delivers this info to the user landscape-sysinfo .

I have a feeling the code is not exactly portable, but it works for me on Ubuntu 8.10 Intrepid i386. I'd be interested to learn of of a more portable way to do this in Python.

The code in networks.py that enumerates network interfaces and grabs the IP address of a given interface is based largely on from the ActiveState "recipies" by Paul Cannon, which were provided under a MIT copyright at

  http://code.activestate.com/recipes/439093/ and http://code.activestate.com/recipes/439094/

Basically the patch just adds the Networks class to the list of classes in deployment.py and the networks.py file implements that class, adding a Header for each active interface.

Sample output of landscape-sysinfo with this plugin in place is:

 System load: 0.45 Processes: 125
  Usage of /: 37.5% of 74.20GB Users logged in: 1
  Memory usage: 70% IP of lo: 127.0.0.1
  Swap usage: 4% IP of eth0: 192.168.1.100