9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/vmc/cli/app/stats.rb', line 9
def stats
app = input[:app]
stats =
with_progress("Getting stats for #{c(app.name, :name)}") do |s|
begin
app.stats
rescue CFoundry::StatsError
s.fail do
err "Application #{b(app.name)} is not running."
return
end
end
end
line unless quiet?
table(
%w{instance cpu memory disk},
stats.sort_by { |idx, _| idx.to_i }.collect { |idx, info|
idx = c("\##{idx}", :instance)
if info[:state] == "DOWN"
[idx, c("down", :bad)]
else
stats = info[:stats]
usage = stats[:usage]
if usage
[ idx,
"#{percentage(usage[:cpu])}",
"#{usage(usage[:mem], stats[:mem_quota])}",
"#{usage(usage[:disk], stats[:disk_quota])}"
]
else
[idx, c("n/a", :neutral)]
end
end
})
end
|