github.com/minio/madmin-go/v3@v3.0.51/net_linux.go (about) 1 //go:build linux 2 // +build linux 3 4 // Copyright (c) 2015-2023 MinIO, Inc. 5 // 6 // This file is part of MinIO Object Storage stack 7 // 8 // This program is free software: you can redistribute it and/or modify 9 // it under the terms of the GNU Affero General Public License as 10 // published by the Free Software Foundation, either version 3 of the 11 // License, or (at your option) any later version. 12 // 13 // This program is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU Affero General Public License for more details. 17 // 18 // You should have received a copy of the GNU Affero General Public License 19 // along with this program. If not, see <http://www.gnu.org/licenses/>. 20 // 21 22 package madmin 23 24 import ( 25 "fmt" 26 27 "github.com/safchain/ethtool" 28 ) 29 30 // GetNetInfo returns information of the given network interface 31 func GetNetInfo(addr string, iface string) (ni NetInfo) { 32 ni.Addr = addr 33 ni.Interface = iface 34 35 ethHandle, err := ethtool.NewEthtool() 36 if err != nil { 37 ni.Error = err.Error() 38 return 39 } 40 defer ethHandle.Close() 41 42 di, err := ethHandle.DriverInfo(ni.Interface) 43 if err != nil { 44 ni.Error = fmt.Sprintf("Error getting driver info for %s: %s", ni.Interface, err.Error()) 45 return 46 } 47 48 ni.Driver = di.Driver 49 ni.FirmwareVersion = di.FwVersion 50 51 return 52 }