Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
06f8d580
Commit
06f8d580
authored
9 years ago
by
Diptanu Choudhury
Browse files
Options
Download
Email Patches
Plain Diff
Making the cli use new apis
parent
15e79c37
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/allocations.go
+5
-1
api/allocations.go
api/api.go
+0
-1
api/api.go
api/nodes.go
+4
-3
api/nodes.go
api/tasks.go
+6
-2
api/tasks.go
with
15 additions
and
7 deletions
+15
-7
api/allocations.go
+
5
-
1
View file @
06f8d580
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
api/api.go
+
0
-
1
View file @
06f8d580
...
...
@@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
//"io/ioutil"
"net/http"
"net/url"
"os"
...
...
This diff is collapsed.
Click to expand it.
api/nodes.go
+
4
-
3
View file @
06f8d580
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
api/tasks.go
+
6
-
2
View file @
06f8d580
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help