Ohai network ports plugin


#1

Hi all,
I wrote my first ohai plugin yesterday, based on a little ruby script which emulates netstat. The plugin extends the network attribute by adding which tcp / udp ports are bound on which interfaces. I saw that there was another similar plugin which used sigar, but I wanted something that didn’t have any external dependencies (and it was a good excuse to see what writing a plugin was like). Going this route made it hard to get the process that’s bound to the port without root access though (as far as I could tell…)

Anyhow, the following is the hierarchy of the output under “network” (hopefully this HTML makes it through intact). The plugin can be found here: https://github.com/agoddard/ohai-plugins/blob/master/plugins/network_ports.rb

I don’t think it’s perfect & would really love to hear any feedback that people have.

Cheers,
Anthony

ports
tcp
0
0.0.0.0
22
1
0.0.0.0
25
2
0.0.0.0
5666
3
192.168.0.50
22
udp
0
0.0.0.0
68
1
192.168.0.50
123