class Inspec::Resources::LinuxInterface
def interface_info(iface)
def interface_info(iface) # will return "[mtu]\n1500\n[type]\n1" cmd = inspec.command("find /sys/class/net/#{iface}/ -maxdepth 1 -type f -exec sh -c 'echo \"[$(basename {})]\"; cat {} || echo -n' \\;") return nil if cmd.exit_status.to_i != 0 # parse values, we only recieve values, therefore we threat them as keys params = SimpleConfig.new(cmd.stdout.chomp).params # abort if we got an empty result-set return nil if params.empty? # parse state state = false if params.key?('operstate') operstate, _value = params['operstate'].first state = operstate == 'up' end # parse speed speed = nil if params.key?('speed') speed, _value = params['speed'].first speed = convert_to_i(speed) end { name: iface, up: state, speed: speed, } end