Skip to content

Instantly share code, notes, and snippets.

@pierreozoux
Last active December 18, 2015 16:39
Show Gist options
  • Save pierreozoux/5813311 to your computer and use it in GitHub Desktop.
Save pierreozoux/5813311 to your computer and use it in GitHub Desktop.
Bug OHAI-478
INTERFACE
Gentoo
type: eth, number: 0:
error here --^
Ubuntu
type: eth, number: 0
Addresse
Gentoo
nil
Ubuntu
address: 172.16.100.5
#!/bin/ruby
# from here https://github.com/opscode/ohai/blob/master/lib/ohai/plugins/linux/network.rb#L332
def interface(line)
if line =~ /^([0-9a-zA-Z@\.\:\-_]+)\s+/
cint = $1
if cint =~ /^(\w+)(\d+.*)/
return "type: #{$1}, number: #{$2}"
end
end
end
# from here : https://github.com/opscode/ohai/blob/master/lib/ohai/plugins/linux/network.rb#L347
def addresse(line)
if line =~ /inet addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
return "address: #{$1}"
end
end
puts "INTERFACE"
puts "Gentoo"
line_gentoo = "eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500"
puts interface(line_gentoo)
puts " error here --^"
puts "Ubuntu"
line_ubuntu = "eth0 Link encap:Ethernet HWaddr 08:00:27:44:2c:96"
puts interface(line_ubuntu)
puts "Addresse"
puts "Gentoo"
line_gentoo = "inet 172.16.100.7 netmask 255.255.0.0 broadcast 172.16.255.255"
p addresse(line_gentoo)
puts "Ubuntu"
line_ubuntu = "inet addr:172.16.100.5 Bcast:172.16.255.255 Mask:255.255.0.0"
puts addresse(line_ubuntu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment