mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 19:35:41 +03:00
Making the cli use new apis
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user