Skip to content

Commit

Permalink
Merge branch 'master' of github.com:vmarmol/vertigo
Browse files Browse the repository at this point in the history
  • Loading branch information
monnand committed Jun 8, 2014
2 parents 47636c0 + c9aacd2 commit 2913537
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions instances/sizes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
// TODO(vmarmol): In real life, we'd probably discover this.
// Map of instance name to number of cores.
var instanceMapping = map[string]int{
"vertigo-0": 1,
"vertigo-1": 2,
"vertigo-2": 4,
"vertigo-demo-0": 1,
"vertigo-demo-1": 2,
"vertigo-demo-2": 4,
"vertigo-demo-3": 8,
}

// Get an instance one size larger than the specified instance.
Expand Down
4 changes: 2 additions & 2 deletions ui/api/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func getUsage(instance string) (int, int, error) {
trackedId := tracked.Tracked

// Get the usage from cAdvisor.
log.Printf("Instance %q is tracking: %q", instance, trackedId)
c, err := cadvisor.NewClient(fmt.Sprintf("http://%s:5000/", instance))
if err != nil {
return -1, -1, err
Expand All @@ -63,9 +64,8 @@ func getUsage(instance string) (int, int, error) {
if err != nil {
return -1, -1, err
}

cpuUsage := cinfo.Stats[statsLen-1].Cpu.Usage.Total - cinfo.Stats[statsLen-2].Cpu.Usage.Total
return int(cpuUsage) * 100 / m.NumCores, int(int64(cinfo.Stats[statsLen-1].Memory.Usage) * int64(100) / m.MemoryCapacity), nil
return int(cpuUsage*uint64(100)/1000000000) / m.NumCores, int(int64(cinfo.Stats[statsLen-1].Memory.Usage) * int64(100) / m.MemoryCapacity), nil
}

func GetInstances(serv *compute.Service, w http.ResponseWriter) error {
Expand Down

0 comments on commit 2913537

Please sign in to comment.