From d266b3a06604fcc132f59dd2eb35eec986041f65 Mon Sep 17 00:00:00 2001 From: kannappanr <30541348+kannappanr@users.noreply.github.com> Date: Wed, 11 Dec 2019 17:56:02 -0800 Subject: [PATCH] Admin Info: Modify Uptime to return seconds (#8635) --- cmd/admin-handlers.go | 12 ++++++------ cmd/admin-server-info.go | 2 +- cmd/peer-rest-server.go | 2 +- pkg/madmin/info-commands.go | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 01ad9d2e0..17fcb16ae 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -219,12 +219,12 @@ func (a adminAPIHandlers) ServiceActionHandler(w http.ResponseWriter, r *http.Re // ServerProperties holds some server information such as, version, region // uptime, etc.. type ServerProperties struct { - Uptime time.Duration `json:"uptime"` - Version string `json:"version"` - CommitID string `json:"commitID"` - DeploymentID string `json:"deploymentID"` - Region string `json:"region"` - SQSARN []string `json:"sqsARN"` + Uptime int64 `json:"uptime"` + Version string `json:"version"` + CommitID string `json:"commitID"` + DeploymentID string `json:"deploymentID"` + Region string `json:"region"` + SQSARN []string `json:"sqsARN"` } // ServerConnStats holds transferred bytes from/to the server diff --git a/cmd/admin-server-info.go b/cmd/admin-server-info.go index 006b712ac..c231eaa14 100644 --- a/cmd/admin-server-info.go +++ b/cmd/admin-server-info.go @@ -242,7 +242,7 @@ func getLocalServerProperty(endpointZones EndpointZones, r *http.Request) madmin return madmin.ServerProperties{ State: "ok", Endpoint: addr, - Uptime: UTCNow().Sub(globalBootTime), + Uptime: UTCNow().Unix() - globalBootTime.Unix(), Version: Version, CommitID: CommitID, Network: network, diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index 5addb0e60..de4501e96 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -52,7 +52,7 @@ func getServerInfo() (*ServerInfoData, error) { ConnStats: globalConnStats.toServerConnStats(), HTTPStats: globalHTTPStats.toServerHTTPStats(), Properties: ServerProperties{ - Uptime: UTCNow().Sub(globalBootTime), + Uptime: UTCNow().Unix() - globalBootTime.Unix(), Version: Version, CommitID: CommitID, DeploymentID: globalDeploymentID, diff --git a/pkg/madmin/info-commands.go b/pkg/madmin/info-commands.go index c7a91df9d..0288ea1be 100644 --- a/pkg/madmin/info-commands.go +++ b/pkg/madmin/info-commands.go @@ -24,7 +24,6 @@ import ( "net/http" "net/url" "strconv" - "time" humanize "github.com/dustin/go-humanize" "github.com/minio/minio/pkg/cpu" @@ -425,7 +424,7 @@ type XlBackend struct { type ServerProperties struct { State string `json:"state"` Endpoint string `json:"endpoint"` - Uptime time.Duration `json:"uptime"` + Uptime int64 `json:"uptime"` Version string `json:"version"` CommitID string `json:"commitID"` Network map[string]string `json:"network"`