Commit 06f8d580 authored by Diptanu Choudhury's avatar Diptanu Choudhury
Browse files

Making the cli use new apis

parent 15e79c37
No related merge requests found
Showing with 15 additions and 7 deletions
+15 -7
......@@ -58,8 +58,12 @@ func (a *Allocations) Stats(alloc *Allocation, q *QueryOptions) (map[string]*Tas
if err != nil {
return nil, err
}
resp := make(map[string][]*TaskResourceUsage)
client.query("/v1/client/allocation/"+alloc.ID+"/stats", &resp, nil)
res := make(map[string]*TaskResourceUsage)
client.query("/v1/client/allocation/"+alloc.ID+"/stats", &res, nil)
for task, ru := range resp {
res[task] = ru[0]
}
return res, nil
}
......
......@@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
//"io/ioutil"
"net/http"
"net/url"
"os"
......
......@@ -89,11 +89,12 @@ func (n *Nodes) Stats(nodeID string, q *QueryOptions) (*HostStats, error) {
if err != nil {
return nil, err
}
var hostStats HostStats
if _, err := client.query("/v1/client/stats/", &hostStats, nil); err != nil {
var resp []HostStats
if _, err := client.query("/v1/client/stats/", &resp, nil); err != nil {
return nil, err
}
return &hostStats, nil
return &resp[0], nil
}
// Node is used to deserialize a node entry.
......
......@@ -4,6 +4,7 @@ import (
"time"
)
// MemoryStats holds memory usage related stats
type MemoryStats struct {
RSS uint64
Cache uint64
......@@ -13,6 +14,7 @@ type MemoryStats struct {
KernelMaxUsage uint64
}
// CpuStats holds cpu usage related stats
type CpuStats struct {
SystemMode float64
UserMode float64
......@@ -21,15 +23,17 @@ type CpuStats struct {
Percent float64
}
// ResourceUsage holds information related to cpu and memory stats
type ResourceUsage struct {
MemoryStats *MemoryStats
CpuStats *CpuStats
Timestamp time.Time
}
// TaskResourceUsage holds aggregated resource usage of all processes in a Task
// and the resource usage of the individual pids
type TaskResourceUsage struct {
ResourceUsage *ResourceUsage
Timestamp time.Time
Timestamp int64
Pids map[string]*ResourceUsage
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment