fix foramt
This commit is contained in:
parent
3bcbfd3577
commit
2b9fd75474
@ -93,7 +93,6 @@ type StatDiff struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Init is given a cluster, which it then uses to load the initial statistics
|
// Init is given a cluster, which it then uses to load the initial statistics
|
||||||
// Does not close connections, but uses the host connections available to the
|
// Does not close connections, but uses the host connections available to the
|
||||||
// cluster to add statistics together.
|
// cluster to add statistics together.
|
||||||
@ -122,8 +121,6 @@ func (cs *ClusterStats) Update() {
|
|||||||
cs.Memory.Buffers += h.NodeMemory.Buffers
|
cs.Memory.Buffers += h.NodeMemory.Buffers
|
||||||
cs.Memory.Cached += h.NodeMemory.Cached
|
cs.Memory.Cached += h.NodeMemory.Cached
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Storage Pool counting
|
// Storage Pool counting
|
||||||
cs.Storage.Pools += uint32(len(h.StoragePoolList))
|
cs.Storage.Pools += uint32(len(h.StoragePoolList))
|
||||||
countedSharedPools := map[string]struct{}{}
|
countedSharedPools := map[string]struct{}{}
|
||||||
@ -133,10 +130,10 @@ func (cs *ClusterStats) Update() {
|
|||||||
// Already counted this shared pool, move on
|
// Already counted this shared pool, move on
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if sp.HAEnabled == true {
|
if sp.HAEnabled {
|
||||||
countedSharedPools[sp.Name] = struct{}{}
|
countedSharedPools[sp.Name] = struct{}{}
|
||||||
}
|
}
|
||||||
if sp.Active == false {
|
if !sp.Active {
|
||||||
cs.Storage.Inactive++
|
cs.Storage.Inactive++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -178,42 +175,80 @@ func (cs *ClusterStats) Update() {
|
|||||||
// Diff returns a map of all the field and how they changed
|
// Diff returns a map of all the field and how they changed
|
||||||
func (cs *ClusterStats) Diff() StatDiff {
|
func (cs *ClusterStats) Diff() StatDiff {
|
||||||
return StatDiff{
|
return StatDiff{
|
||||||
CPU: struct{Sockets int; Cores int; Threads int; Allocated int}{
|
CPU: struct {
|
||||||
|
Sockets int
|
||||||
|
Cores int
|
||||||
|
Threads int
|
||||||
|
Allocated int
|
||||||
|
}{
|
||||||
Sockets: int(cs.old.CPU.Sockets - cs.CPU.Sockets),
|
Sockets: int(cs.old.CPU.Sockets - cs.CPU.Sockets),
|
||||||
Cores: int(cs.old.CPU.Cores - cs.CPU.Cores),
|
Cores: int(cs.old.CPU.Cores - cs.CPU.Cores),
|
||||||
Threads: int(cs.old.CPU.Threads - cs.CPU.Threads),
|
Threads: int(cs.old.CPU.Threads - cs.CPU.Threads),
|
||||||
Allocated: int(cs.old.CPU.Allocated - cs.CPU.Allocated),
|
Allocated: int(cs.old.CPU.Allocated - cs.CPU.Allocated),
|
||||||
},
|
},
|
||||||
Memory: struct{Total int; Free int; Buffers int; Cached int; Allocated int}{
|
Memory: struct {
|
||||||
|
Total int
|
||||||
|
Free int
|
||||||
|
Buffers int
|
||||||
|
Cached int
|
||||||
|
Allocated int
|
||||||
|
}{
|
||||||
Total: int(cs.old.Memory.Total - cs.Memory.Total),
|
Total: int(cs.old.Memory.Total - cs.Memory.Total),
|
||||||
Free: int(cs.old.Memory.Free - cs.Memory.Free),
|
Free: int(cs.old.Memory.Free - cs.Memory.Free),
|
||||||
Buffers: int(cs.old.Memory.Buffers - cs.Memory.Buffers),
|
Buffers: int(cs.old.Memory.Buffers - cs.Memory.Buffers),
|
||||||
Cached: int(cs.old.Memory.Cached - cs.Memory.Cached),
|
Cached: int(cs.old.Memory.Cached - cs.Memory.Cached),
|
||||||
Allocated: int(cs.old.Memory.Allocated - cs.Memory.Allocated),
|
Allocated: int(cs.old.Memory.Allocated - cs.Memory.Allocated),
|
||||||
},
|
},
|
||||||
Storage: struct{Total int; Used int; Free int; Active int; Inactive int; Pools int; Volumes struct{Total int; Active int; Inactive int}}{
|
Storage: struct {
|
||||||
|
Total int
|
||||||
|
Used int
|
||||||
|
Free int
|
||||||
|
Active int
|
||||||
|
Inactive int
|
||||||
|
Pools int
|
||||||
|
Volumes struct {
|
||||||
|
Total int
|
||||||
|
Active int
|
||||||
|
Inactive int
|
||||||
|
}
|
||||||
|
}{
|
||||||
Total: int(cs.old.Storage.Total - cs.Storage.Total),
|
Total: int(cs.old.Storage.Total - cs.Storage.Total),
|
||||||
Used: int(cs.old.Storage.Used - cs.Storage.Used),
|
Used: int(cs.old.Storage.Used - cs.Storage.Used),
|
||||||
Free: int(cs.old.Storage.Free - cs.Storage.Free),
|
Free: int(cs.old.Storage.Free - cs.Storage.Free),
|
||||||
Active: int(cs.old.Storage.Active - cs.Storage.Active),
|
Active: int(cs.old.Storage.Active - cs.Storage.Active),
|
||||||
Inactive: int(cs.old.Storage.Inactive - cs.Storage.Inactive),
|
Inactive: int(cs.old.Storage.Inactive - cs.Storage.Inactive),
|
||||||
Pools: int(cs.old.Storage.Pools - cs.Storage.Pools),
|
Pools: int(cs.old.Storage.Pools - cs.Storage.Pools),
|
||||||
Volumes: struct{Total int; Active int; Inactive int}{
|
Volumes: struct {
|
||||||
|
Total int
|
||||||
|
Active int
|
||||||
|
Inactive int
|
||||||
|
}{
|
||||||
Total: int(cs.old.Storage.Volumes.Total - cs.Storage.Volumes.Total),
|
Total: int(cs.old.Storage.Volumes.Total - cs.Storage.Volumes.Total),
|
||||||
Active: int(cs.old.Storage.Volumes.Active - cs.Storage.Volumes.Active),
|
Active: int(cs.old.Storage.Volumes.Active - cs.Storage.Volumes.Active),
|
||||||
Inactive: int(cs.old.Storage.Volumes.Inactive - cs.Storage.Volumes.Inactive),
|
Inactive: int(cs.old.Storage.Volumes.Inactive - cs.Storage.Volumes.Inactive),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
VM: struct{Count int; Started int; Stopped int}{
|
VM: struct {
|
||||||
|
Count int
|
||||||
|
Started int
|
||||||
|
Stopped int
|
||||||
|
}{
|
||||||
Count: int(cs.old.VM.Count - cs.VM.Count),
|
Count: int(cs.old.VM.Count - cs.VM.Count),
|
||||||
Started: int(cs.old.VM.Started - cs.VM.Started),
|
Started: int(cs.old.VM.Started - cs.VM.Started),
|
||||||
Stopped: int(cs.old.VM.Stopped - cs.VM.Stopped),
|
Stopped: int(cs.old.VM.Stopped - cs.VM.Stopped),
|
||||||
},
|
},
|
||||||
Host: struct{Count int; Available int}{
|
Host: struct {
|
||||||
|
Count int
|
||||||
|
Available int
|
||||||
|
}{
|
||||||
Count: int(cs.old.Host.Count - cs.Host.Count),
|
Count: int(cs.old.Host.Count - cs.Host.Count),
|
||||||
Available: int(cs.old.Host.Available - cs.Host.Available),
|
Available: int(cs.old.Host.Available - cs.Host.Available),
|
||||||
},
|
},
|
||||||
Network: struct{Count int; Active int; Inactive int}{
|
Network: struct {
|
||||||
|
Count int
|
||||||
|
Active int
|
||||||
|
Inactive int
|
||||||
|
}{
|
||||||
Count: int(cs.old.Network.Count - cs.Network.Count),
|
Count: int(cs.old.Network.Count - cs.Network.Count),
|
||||||
Active: int(cs.old.Network.Active - cs.Network.Active),
|
Active: int(cs.old.Network.Active - cs.Network.Active),
|
||||||
Inactive: int(cs.old.Network.Inactive - cs.Network.Inactive),
|
Inactive: int(cs.old.Network.Inactive - cs.Network.Inactive),
|
||||||
|
Loading…
Reference in New Issue
Block a user