diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index e9da66285..1573a2f1a 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1567,6 +1567,22 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque } } + getAndWriteSysConfig := func() { + if query.Get(string(madmin.HealthDataTypeSysConfig)) == "true" { + localSysConfig := madmin.GetSysConfig(deadlinedCtx, globalLocalNodeName) + anonymizeAddr(&localSysConfig) + healthInfo.Sys.SysConfig = append(healthInfo.Sys.SysConfig, localSysConfig) + partialWrite(healthInfo) + + peerSysConfig := globalNotificationSys.GetSysConfig(deadlinedCtx) + for _, sc := range peerSysConfig { + anonymizeAddr(&sc) + healthInfo.Sys.SysConfig = append(healthInfo.Sys.SysConfig, sc) + } + partialWrite(healthInfo) + } + } + getAndWriteSysServices := func() { if query.Get(string(madmin.HealthDataTypeSysServices)) == "true" { localSysServices := madmin.GetSysServices(deadlinedCtx, globalLocalNodeName) @@ -1575,9 +1591,9 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque partialWrite(healthInfo) peerSysServices := globalNotificationSys.GetSysServices(deadlinedCtx) - for _, sli := range peerSysServices { - anonymizeAddr(&sli) - healthInfo.Sys.SysServices = append(healthInfo.Sys.SysServices, sli) + for _, ss := range peerSysServices { + anonymizeAddr(&ss) + healthInfo.Sys.SysServices = append(healthInfo.Sys.SysServices, ss) } partialWrite(healthInfo) } @@ -1758,6 +1774,7 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque getAndWriteNetPerfInfo() getAndWriteSysErrors() getAndWriteSysServices() + getAndWriteSysConfig() if query.Get("minioinfo") == "true" { infoMessage := getServerInfo(ctx, r) diff --git a/cmd/notification.go b/cmd/notification.go index cec446138..d5a26b3bb 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1051,6 +1051,32 @@ func (sys *NotificationSys) GetOSInfo(ctx context.Context) []madmin.OSInfo { return reply } +// GetSysConfig - Get information about system config +// (only the config that are of concern to minio) +func (sys *NotificationSys) GetSysConfig(ctx context.Context) []madmin.SysConfig { + reply := make([]madmin.SysConfig, 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].GetSysConfig(ctx) + return err + }, index) + } + + for index, err := range g.Wait() { + if err != nil { + sys.addNodeErr(&reply[index], sys.peerClients[index], err) + } + } + return reply +} + // GetSysServices - Get information about system services // (only the services that are of concern to minio) func (sys *NotificationSys) GetSysServices(ctx context.Context) []madmin.SysServices { diff --git a/cmd/peer-rest-client.go b/cmd/peer-rest-client.go index 44e0b6951..1dfac0a8d 100644 --- a/cmd/peer-rest-client.go +++ b/cmd/peer-rest-client.go @@ -411,7 +411,18 @@ func (client *peerRESTClient) GetSELinuxInfo(ctx context.Context) (info madmin.S return info, err } -// GetSysErrors - fetch memory information for a remote node. +// GetSysConfig - fetch sys config for a remote node. +func (client *peerRESTClient) GetSysConfig(ctx context.Context) (info madmin.SysConfig, err error) { + respBody, err := client.callWithContext(ctx, peerRESTMethodSysConfig, nil, nil, -1) + if err != nil { + return + } + defer http.DrainBody(respBody) + err = gob.NewDecoder(respBody).Decode(&info) + return info, err +} + +// GetSysErrors - fetch sys errors for a remote node. func (client *peerRESTClient) GetSysErrors(ctx context.Context) (info madmin.SysErrors, err error) { respBody, err := client.callWithContext(ctx, peerRESTMethodSysErrors, nil, nil, -1) if err != nil { diff --git a/cmd/peer-rest-common.go b/cmd/peer-rest-common.go index c90cd931a..9f545f875 100644 --- a/cmd/peer-rest-common.go +++ b/cmd/peer-rest-common.go @@ -36,6 +36,7 @@ const ( peerRESTMethodProcInfo = "/procinfo" peerRESTMethodSysErrors = "/syserrors" peerRESTMethodSysServices = "/sysservices" + peerRESTMethodSysConfig = "/sysconfig" peerRESTMethodDispatchNetInfo = "/dispatchnetinfo" peerRESTMethodDeleteBucketMetadata = "/deletebucketmetadata" peerRESTMethodLoadBucketMetadata = "/loadbucketmetadata" diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index cfeebab8c..8f62fc885 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -510,6 +510,24 @@ func (s *peerRESTServer) GetMemInfoHandler(w http.ResponseWriter, r *http.Reques logger.LogIf(ctx, gob.NewEncoder(w).Encode(info)) } +// GetSysConfigHandler - returns system config information. +// (only the config that are of concern to minio) +func (s *peerRESTServer) GetSysConfigHandler(w http.ResponseWriter, r *http.Request) { + if !s.IsValid(w, r) { + fmt.Println("Invalid request") + s.writeErrorResponse(w, errors.New("Invalid request")) + return + } + + ctx, cancel := context.WithCancel(r.Context()) + defer cancel() + + info := madmin.GetSysConfig(ctx, r.Host) + + defer w.(http.Flusher).Flush() + logger.LogIf(ctx, gob.NewEncoder(w).Encode(info)) +} + // GetSysServicesHandler - returns system services information. // (only the services that are of concern to minio) func (s *peerRESTServer) GetSysServicesHandler(w http.ResponseWriter, r *http.Request) { @@ -1320,6 +1338,7 @@ func registerPeerRESTHandlers(router *mux.Router) { subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodMemInfo).HandlerFunc(httpTraceHdrs(server.GetMemInfoHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodSysErrors).HandlerFunc(httpTraceHdrs(server.GetSysErrorsHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodSysServices).HandlerFunc(httpTraceHdrs(server.GetSysServicesHandler)) + subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodSysConfig).HandlerFunc(httpTraceHdrs(server.GetSysConfigHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodOsInfo).HandlerFunc(httpTraceHdrs(server.GetOSInfoHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodDiskHwInfo).HandlerFunc(httpTraceHdrs(server.GetPartitionsHandler)) subrouter.Methods(http.MethodPost).Path(peerRESTVersionPrefix + peerRESTMethodCPUInfo).HandlerFunc(httpTraceHdrs(server.GetCPUsHandler)) diff --git a/go.mod b/go.mod index 8f3b0361f..36ae9f74b 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/minio/csvparser v1.0.0 github.com/minio/highwayhash v1.0.2 github.com/minio/kes v0.14.0 - github.com/minio/madmin-go v1.0.21-0.20210820144629-f47e578ef886 + github.com/minio/madmin-go v1.1.0 github.com/minio/minio-go/v7 v7.0.13-0.20210823191913-cee488b95ff2 github.com/minio/parquet-go v1.0.0 github.com/minio/pkg v1.0.11 diff --git a/go.sum b/go.sum index 12791279e..23b2bf7d5 100644 --- a/go.sum +++ b/go.sum @@ -1025,8 +1025,8 @@ github.com/minio/kes v0.14.0 h1:plCGm4LwR++T1P1sXsJbyFRX54CE1WRuo9PAPj6MC3Q= github.com/minio/kes v0.14.0/go.mod h1:OUensXz2BpgMfiogslKxv7Anyx/wj+6bFC6qA7BQcfA= github.com/minio/madmin-go v1.0.12/go.mod h1:BK+z4XRx7Y1v8SFWXsuLNqQqnq5BO/axJ8IDJfgyvfs= github.com/minio/madmin-go v1.0.17/go.mod h1:4nl9hvLWFnwCjkLfZSsZXEHgDODa2XSG6xGlIZyQ2oA= -github.com/minio/madmin-go v1.0.21-0.20210820144629-f47e578ef886 h1:sZ22LseOBW5OQIih+fi0v+JBDU4RiaqLbEM3t3JF80I= -github.com/minio/madmin-go v1.0.21-0.20210820144629-f47e578ef886/go.mod h1:4nl9hvLWFnwCjkLfZSsZXEHgDODa2XSG6xGlIZyQ2oA= +github.com/minio/madmin-go v1.1.0 h1:Y7YOPQafIVBpW0kwYzlt7FGi0GV23dlr/u3jRRrB4cw= +github.com/minio/madmin-go v1.1.0/go.mod h1:4nl9hvLWFnwCjkLfZSsZXEHgDODa2XSG6xGlIZyQ2oA= github.com/minio/mc v0.0.0-20210626002108-cebf3318546f h1:hyFvo5hSFw2K417YvDr/vAKlgCG69uTuhZW/5LNdL0U= github.com/minio/mc v0.0.0-20210626002108-cebf3318546f/go.mod h1:tuaonkPjVApCXkbtKENHBtsqUf7YTV33qmFrC+Pgp5g= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=