Separate out memory statistics and system information into two different services

This commit is contained in:
Harshavardhana
2015-07-07 16:59:20 -07:00
parent 8abb96c030
commit 676b9058de
4 changed files with 58 additions and 12 deletions

View File

@@ -47,8 +47,30 @@ func GetDisks(url string) ([]string, error) {
return reply.Disks, nil
}
// GetMemStats get system info of the server at given url
// GetMemStats get memory status of the server at given url
func GetMemStats(url string) ([]byte, error) {
op := RPCOps{
Method: "MemStats.Get",
Request: rpc.Args{Request: ""},
}
req, err := NewRequest(url, op, http.DefaultTransport)
if err != nil {
return nil, iodine.New(err, nil)
}
resp, err := req.Do()
if err != nil {
return nil, iodine.New(err, nil)
}
defer resp.Body.Close()
var reply rpc.MemStatsReply
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
return nil, iodine.New(err, nil)
}
return json.MarshalIndent(reply, "", "\t")
}
// GetSysInfo get system status of the server at given url
func GetSysInfo(url string) ([]byte, error) {
op := RPCOps{
Method: "SysInfo.Get",
Request: rpc.Args{Request: ""},
@@ -96,4 +118,4 @@ func SetDonut(url, hostname string, disks []string) error {
return reply.Error
}
// Add more functions here for many replies
// Add more functions here for other RPC messages