fix foramt

This commit is contained in:
Matthew Stobbs 2024-03-18 22:46:14 -06:00
parent 3bcbfd3577
commit 2b9fd75474

View File

@ -93,7 +93,6 @@ type StatDiff struct {
}
}
// 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
// cluster to add statistics together.
@ -122,8 +121,6 @@ func (cs *ClusterStats) Update() {
cs.Memory.Buffers += h.NodeMemory.Buffers
cs.Memory.Cached += h.NodeMemory.Cached
// Storage Pool counting
cs.Storage.Pools += uint32(len(h.StoragePoolList))
countedSharedPools := map[string]struct{}{}
@ -133,10 +130,10 @@ func (cs *ClusterStats) Update() {
// Already counted this shared pool, move on
continue
}
if sp.HAEnabled == true {
if sp.HAEnabled {
countedSharedPools[sp.Name] = struct{}{}
}
if sp.Active == false {
if !sp.Active {
cs.Storage.Inactive++
continue
}
@ -178,42 +175,80 @@ func (cs *ClusterStats) Update() {
// Diff returns a map of all the field and how they changed
func (cs *ClusterStats) Diff() 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),
Cores: int(cs.old.CPU.Cores - cs.CPU.Cores),
Threads: int(cs.old.CPU.Threads - cs.CPU.Threads),
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),
Free: int(cs.old.Memory.Free - cs.Memory.Free),
Buffers: int(cs.old.Memory.Buffers - cs.Memory.Buffers),
Cached: int(cs.old.Memory.Cached - cs.Memory.Cached),
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),
Used: int(cs.old.Storage.Used - cs.Storage.Used),
Free: int(cs.old.Storage.Free - cs.Storage.Free),
Active: int(cs.old.Storage.Active - cs.Storage.Active),
Inactive: int(cs.old.Storage.Inactive - cs.Storage.Inactive),
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),
Active: int(cs.old.Storage.Volumes.Active - cs.Storage.Volumes.Active),
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),
Started: int(cs.old.VM.Started - cs.VM.Started),
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),
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),
Active: int(cs.old.Network.Active - cs.Network.Active),
Inactive: int(cs.old.Network.Inactive - cs.Network.Inactive),
@ -229,31 +264,31 @@ func (cs *ClusterStats) copy() *ClusterStats {
// reset all values to zero value
func (cs *ClusterStats) reset() {
cs.CPU.Sockets=0
cs.CPU.Cores=0
cs.CPU.Threads=0
cs.CPU.Allocated=0
cs.CPU.Sockets = 0
cs.CPU.Cores = 0
cs.CPU.Threads = 0
cs.CPU.Allocated = 0
cs.Memory.Total=0
cs.Memory.Free=0
cs.Memory.Buffers=0
cs.Memory.Cached=0
cs.Memory.Total = 0
cs.Memory.Free = 0
cs.Memory.Buffers = 0
cs.Memory.Cached = 0
cs.Storage.Total=0
cs.Storage.Used=0
cs.Storage.Free=0
cs.Storage.Active=0
cs.Storage.Inactive=0
cs.Storage.Pools=0
cs.Storage.Total = 0
cs.Storage.Used = 0
cs.Storage.Free = 0
cs.Storage.Active = 0
cs.Storage.Inactive = 0
cs.Storage.Pools = 0
cs.VM.Count=0
cs.VM.Started=0
cs.VM.Stopped=0
cs.VM.Count = 0
cs.VM.Started = 0
cs.VM.Stopped = 0
cs.Host.Count=0
cs.Host.Available=0
cs.Host.Count = 0
cs.Host.Available = 0
cs.Network.Count=0
cs.Network.Active=0
cs.Network.Inactive=0
cs.Network.Count = 0
cs.Network.Active = 0
cs.Network.Inactive = 0
}