mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Separate out memory statistics and system information into two different services
This commit is contained in:
@@ -114,8 +114,9 @@ func getRPCHandler() http.Handler {
|
||||
s.RegisterJSONCodec()
|
||||
s.RegisterService(new(rpc.VersionService), "Version")
|
||||
s.RegisterService(new(rpc.SysInfoService), "SysInfo")
|
||||
s.RegisterService(new(rpc.MemStatsService), "MemStats")
|
||||
s.RegisterService(new(rpc.DiskInfoService), "DiskInfo")
|
||||
s.RegisterService(new(rpc.DonutService), "Donut")
|
||||
// Add new services here
|
||||
// Add new RPC services here
|
||||
return registerRPC(router.NewRouter(), s)
|
||||
}
|
||||
|
||||
@@ -29,13 +29,20 @@ type SysInfoService struct{}
|
||||
|
||||
// SysInfoReply -
|
||||
type SysInfoReply struct {
|
||||
Hostname string `json:"hostname"`
|
||||
SysARCH string `json:"sys.arch"`
|
||||
SysOS string `json:"sys.os"`
|
||||
SysCPUS int `json:"sys.ncpus"`
|
||||
Routines int `json:"goroutines"`
|
||||
GOVersion string `json:"goversion"`
|
||||
MemStats runtime.MemStats `json:"memstats"`
|
||||
Hostname string `json:"hostname"`
|
||||
SysARCH string `json:"sys.arch"`
|
||||
SysOS string `json:"sys.os"`
|
||||
SysCPUS int `json:"sys.ncpus"`
|
||||
Routines int `json:"goroutines"`
|
||||
GOVersion string `json:"goversion"`
|
||||
}
|
||||
|
||||
// MemStatsService -
|
||||
type MemStatsService struct{}
|
||||
|
||||
// MemStatsReply -
|
||||
type MemStatsReply struct {
|
||||
runtime.MemStats `json:"memstats"`
|
||||
}
|
||||
|
||||
func setSysInfoReply(sis *SysInfoReply) error {
|
||||
@@ -50,11 +57,13 @@ func setSysInfoReply(sis *SysInfoReply) error {
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setMemStatsReply(sis *MemStatsReply) error {
|
||||
var memStats runtime.MemStats
|
||||
runtime.ReadMemStats(&memStats)
|
||||
sis.MemStats = memStats
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,3 +71,8 @@ func setSysInfoReply(sis *SysInfoReply) error {
|
||||
func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) error {
|
||||
return setSysInfoReply(reply)
|
||||
}
|
||||
|
||||
// Get method
|
||||
func (s *MemStatsService) Get(r *http.Request, args *Args, reply *MemStatsReply) error {
|
||||
return setMemStatsReply(reply)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user