diff --git a/CREDITS b/CREDITS index f4e33c508..ae023b6f9 100644 --- a/CREDITS +++ b/CREDITS @@ -31256,3 +31256,29 @@ limitations under the License. ================================================================ +github.com/safchain/ethtool +https://github.com/safchain/ethtool +---------------------------------------------------------------- +MIT License + +Copyright (C) 2021-2022 Matt Layher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +================================================================ diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index e02376aac..997b154ab 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -2089,6 +2089,20 @@ func fetchHealthInfo(healthCtx context.Context, objectAPI ObjectLayer, query *ur } } + getAndWriteNetInfo := func() { + if query.Get(string(madmin.HealthDataTypeSysNet)) == "true" { + localNetInfo := madmin.GetNetInfo(globalLocalNodeName, globalInternodeInterface) + healthInfo.Sys.NetInfo = append(healthInfo.Sys.NetInfo, localNetInfo) + + peerNetInfos := globalNotificationSys.GetNetInfo(healthCtx) + for _, n := range peerNetInfos { + anonymizeAddr(&n) + healthInfo.Sys.NetInfo = append(healthInfo.Sys.NetInfo, n) + } + partialWrite(healthInfo) + } + } + getAndWriteOSInfo := func() { if query.Get("sysosinfo") == "true" { localOSInfo := madmin.GetOSInfo(healthCtx, globalLocalNodeName) @@ -2310,6 +2324,7 @@ func fetchHealthInfo(healthCtx context.Context, objectAPI ObjectLayer, query *ur getAndWritePlatformInfo() getAndWriteCPUs() getAndWritePartitions() + getAndWriteNetInfo() getAndWriteOSInfo() getAndWriteMemInfo() getAndWriteProcInfo() diff --git a/cmd/notification.go b/cmd/notification.go index 87b63f006..515e5ecd4 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -701,6 +701,31 @@ func (sys *NotificationSys) GetCPUs(ctx context.Context) []madmin.CPUs { return reply } +// GetNetInfo - Network information +func (sys *NotificationSys) GetNetInfo(ctx context.Context) []madmin.NetInfo { + reply := make([]madmin.NetInfo, len(sys.peerClients)) + + g := errgroup.WithNErrs(len(sys.peerClients)) + for index, client := range sys.peerClients { + if client == nil { + continue + } + index := index + g.Go(func() error { + var err error + reply[index], err = sys.peerClients[index].GetNetInfo(ctx) + return err + }, index) + } + + for index, err := range g.Wait() { + if err != nil { + sys.addNodeErr(&reply[index], sys.peerClients[index], err) + } + } + return reply +} + // GetPartitions - Disk partition information func (sys *NotificationSys) GetPartitions(ctx context.Context) []madmin.Partitions { reply := make([]madmin.Partitions, len(sys.peerClients)) diff --git a/cmd/peer-rest-client.go b/cmd/peer-rest-client.go index e30c028f7..7744fb4aa 100644 --- a/cmd/peer-rest-client.go +++ b/cmd/peer-rest-client.go @@ -134,6 +134,17 @@ func (client *peerRESTClient) GetCPUs(ctx context.Context) (info madmin.CPUs, er return info, err } +// GetNetInfo - fetch network information for a remote node. +func (client *peerRESTClient) GetNetInfo(ctx context.Context) (info madmin.NetInfo, err error) { + respBody, err := client.callWithContext(ctx, peerRESTMethodNetHwInfo, nil, nil, -1) + if err != nil { + return + } + defer xhttp.DrainBody(respBody) + err = gob.NewDecoder(respBody).Decode(&info) + return info, err +} + // GetPartitions - fetch disk partition information for a remote node. func (client *peerRESTClient) GetPartitions(ctx context.Context) (info madmin.Partitions, err error) { respBody, err := client.callWithContext(ctx, peerRESTMethodDiskHwInfo, nil, nil, -1) diff --git a/cmd/peer-rest-common.go b/cmd/peer-rest-common.go index 622384f29..80fe49580 100644 --- a/cmd/peer-rest-common.go +++ b/cmd/peer-rest-common.go @@ -31,6 +31,7 @@ const ( peerRESTMethodLocalStorageInfo = "/localstorageinfo" peerRESTMethodCPUInfo = "/cpuinfo" peerRESTMethodDiskHwInfo = "/diskhwinfo" + peerRESTMethodNetHwInfo = "/nethwinfo" peerRESTMethodOsInfo = "/osinfo" peerRESTMethodMemInfo = "/meminfo" peerRESTMethodProcInfo = "/procinfo" diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index 194a9c5af..2b047374b 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -375,6 +375,21 @@ func (s *peerRESTServer) GetCPUsHandler(w http.ResponseWriter, r *http.Request) logger.LogIf(ctx, gob.NewEncoder(w).Encode(info)) } +// GetNetInfoHandler - returns network information. +func (s *peerRESTServer) GetNetInfoHandler(w http.ResponseWriter, r *http.Request) { + if !s.IsValid(w, r) { + s.writeErrorResponse(w, errors.New("Invalid request")) + return + } + + ctx, cancel := context.WithCancel(r.Context()) + defer cancel() + + info := madmin.GetNetInfo(r.Host, globalInternodeInterface) + + logger.LogIf(ctx, gob.NewEncoder(w).Encode(info)) +} + // GetPartitionsHandler - returns disk partition information. func (s *peerRESTServer) GetPartitionsHandler(w http.ResponseWriter, r *http.Request) { if !s.IsValid(w, r) { @@ -1460,6 +1475,7 @@ func registerPeerRESTHandlers(router *mux.Router) { subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodSysConfig).HandlerFunc(h(server.GetSysConfigHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodOsInfo).HandlerFunc(h(server.GetOSInfoHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodDiskHwInfo).HandlerFunc(h(server.GetPartitionsHandler)) + subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodNetHwInfo).HandlerFunc(h(server.GetNetInfoHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodCPUInfo).HandlerFunc(h(server.GetCPUsHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodGetAllBucketStats).HandlerFunc(h(server.GetAllBucketStatsHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodDeleteBucketMetadata).HandlerFunc(h(server.DeleteBucketMetadataHandler)).Queries(restQueries(peerRESTBucket)...) diff --git a/go.mod b/go.mod index 2cf829b4a..27d2e5313 100644 --- a/go.mod +++ b/go.mod @@ -42,13 +42,13 @@ require ( github.com/lithammer/shortuuid/v4 v4.0.0 github.com/miekg/dns v1.1.56 github.com/minio/cli v1.24.2 - github.com/minio/console v0.40.0 + github.com/minio/console v0.40.1-0.20231101212124-ec5fbbcd1ead github.com/minio/csvparser v1.0.0 github.com/minio/dnscache v0.1.1 github.com/minio/dperf v0.5.0 github.com/minio/highwayhash v1.0.2 github.com/minio/kes-go v0.2.0 - github.com/minio/madmin-go/v3 v3.0.22 + github.com/minio/madmin-go/v3 v3.0.29 github.com/minio/minio-go/v7 v7.0.64-0.20230920204636-e783c9ba11b3 github.com/minio/mux v1.9.0 github.com/minio/pkg/v2 v2.0.2 @@ -105,6 +105,8 @@ require ( cloud.google.com/go/iam v1.1.3 // indirect github.com/Azure/azure-pipeline-go v0.2.3 // indirect github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect + github.com/VividCortex/ewma v1.2.0 // indirect + github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/apache/thrift v0.19.0 // indirect github.com/armon/go-metrics v0.4.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect @@ -180,7 +182,7 @@ require ( github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/minio/colorjson v1.0.6 // indirect github.com/minio/filepath v1.0.0 // indirect - github.com/minio/mc v0.0.0-20231020090326-eb6f304e2e82 // indirect + github.com/minio/mc v0.0.0-20231030184332-9f2fb2b6a9f8 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/pkg v1.7.5 // indirect github.com/minio/websocket v1.6.0 // indirect @@ -209,6 +211,7 @@ require ( github.com/rivo/uniseg v0.4.4 // indirect github.com/rjeczalik/notify v0.9.3 // indirect github.com/rs/xid v1.5.0 // indirect + github.com/safchain/ethtool v0.3.0 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/tidwall/match v1.1.1 // indirect @@ -216,6 +219,7 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/unrolled/secure v1.13.0 // indirect + github.com/vbauerster/mpb/v8 v8.6.2 // indirect github.com/xdg/stringprep v1.0.3 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect diff --git a/go.sum b/go.sum index 501417847..40856c254 100644 --- a/go.sum +++ b/go.sum @@ -38,6 +38,10 @@ github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c= github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= +github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= +github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= +github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alecthomas/participle v0.7.1 h1:2bN7reTw//5f0cugJcTOnY/NYZcWQOaajW+BwZB5xWs= github.com/alecthomas/participle v0.7.1/go.mod h1:HfdmEuwvr12HXQN44HPWXR0lHmVolVYe4dyL6lQ3duY= github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= @@ -461,8 +465,8 @@ github.com/minio/cli v1.24.2 h1:J+fCUh9mhPLjN3Lj/YhklXvxj8mnyE/D6FpFduXJ2jg= github.com/minio/cli v1.24.2/go.mod h1:bYxnK0uS629N3Bq+AOZZ+6lwF77Sodk4+UL9vNuXhOY= github.com/minio/colorjson v1.0.6 h1:m7TUvpvt0u7FBmVIEQNIa0T4NBQlxrcMBp4wJKsg2Ik= github.com/minio/colorjson v1.0.6/go.mod h1:LUXwS5ZGNb6Eh9f+t+3uJiowD3XsIWtsvTriUBeqgYs= -github.com/minio/console v0.40.0 h1:zldPHumWA5SN6uAUyAsctUFQ80LvLDv3n0VlONmBJMc= -github.com/minio/console v0.40.0/go.mod h1:ra5pDF0mFQ9DI8K5iyk6Q5gV6KQuZq3MKPGYU66a+vc= +github.com/minio/console v0.40.1-0.20231101212124-ec5fbbcd1ead h1:/0e+NnaklJKsifGFkt1sne3GGIcveiaqS3gHQxBr5nc= +github.com/minio/console v0.40.1-0.20231101212124-ec5fbbcd1ead/go.mod h1:LTDngEa3Z/s9+2oUb3eBtaVsS/vQFuWTH9d8Z2Pe1mo= github.com/minio/csvparser v1.0.0 h1:xJEHcYK8ZAjeW4hNV9Zu30u+/2o4UyPnYgyjWp8b7ZU= github.com/minio/csvparser v1.0.0/go.mod h1:lKXskSLzPgC5WQyzP7maKH7Sl1cqvANXo9YCto8zbtM= github.com/minio/dnscache v0.1.1 h1:AMYLqomzskpORiUA1ciN9k7bZT1oB3YZN4cEIi88W5o= @@ -475,10 +479,10 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/kes-go v0.2.0 h1:HA33arq9s3MErbsj3PAXFVfFo4U4yw7lTKQ5kWFrpCA= github.com/minio/kes-go v0.2.0/go.mod h1:VorHLaIYis9/MxAHAtXN4d8PUMNKhIxTIlvFt0hBOEo= -github.com/minio/madmin-go/v3 v3.0.22 h1:RGMP7oe+DF8G1jpWgXKS0rC1gOG/iS6nT7i91uakyxQ= -github.com/minio/madmin-go/v3 v3.0.22/go.mod h1:B2EgtEGrfWx+AkXv+OAcS6IHwoIJcd1p75QfDPSPd6Q= -github.com/minio/mc v0.0.0-20231020090326-eb6f304e2e82 h1:D5noC02YalJnWw31AtQ3fTxm0PljP80mjM6h+UA5u20= -github.com/minio/mc v0.0.0-20231020090326-eb6f304e2e82/go.mod h1:Fk34LAtB3k7IPHUMrPnW5alaTN3YLzGkIVs7xmlAXAo= +github.com/minio/madmin-go/v3 v3.0.29 h1:3bNLArtxIFud5wyb5/DnF5DGLBvcSJyzCA44EclX1Ow= +github.com/minio/madmin-go/v3 v3.0.29/go.mod h1:4QN2NftLSV7MdlT50dkrenOMmNVHluxTvlqJou3hte8= +github.com/minio/mc v0.0.0-20231030184332-9f2fb2b6a9f8 h1:3WUMQABG8FytpYHRtLHjrnztcUB09hlIrh7rQI9H+tY= +github.com/minio/mc v0.0.0-20231030184332-9f2fb2b6a9f8/go.mod h1:SoPU55ntH5d6IEq6jRBn6e/7SpwI/eSNdBDWmH7nwHk= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= @@ -640,6 +644,8 @@ github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0= +github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc= github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs= @@ -701,6 +707,8 @@ github.com/unrolled/secure v1.13.0 h1:sdr3Phw2+f8Px8HE5sd1EHdj1aV3yUwed/uZXChLFs github.com/unrolled/secure v1.13.0/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/vbauerster/mpb/v8 v8.6.2 h1:9EhnJGQRtvgDVCychJgR96EDCOqgg2NsMuk5JUcX4DA= +github.com/vbauerster/mpb/v8 v8.6.2/go.mod h1:oVJ7T+dib99kZ/VBjoBaC8aPXiSAihnzuKmotuihyFo= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=