mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
OSS changes from ent fix for openbsd memory lookups. (#11088)
This commit is contained in:
@@ -88,3 +88,17 @@ func CollectHostInfo(ctx context.Context) (*HostInfo, error) {
|
|||||||
|
|
||||||
return info, retErr.ErrorOrNil()
|
return info, retErr.ErrorOrNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CollectHostMemory(ctx context.Context) (*VirtualMemoryStat, error) {
|
||||||
|
m, err := mem.VirtualMemoryWithContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &VirtualMemoryStat{
|
||||||
|
Total: m.Total,
|
||||||
|
Available: m.Available,
|
||||||
|
Used: m.Used,
|
||||||
|
UsedPercent: m.UsedPercent,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,3 +20,7 @@ type HostInfo struct {
|
|||||||
func CollectHostInfo(ctx context.Context) (*HostInfo, error) {
|
func CollectHostInfo(ctx context.Context) (*HostInfo, error) {
|
||||||
return nil, fmt.Errorf("host info not supported on this platform")
|
return nil, fmt.Errorf("host info not supported on this platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CollectHostMemory(ctx context.Context) (*VirtualMemoryStat, error) {
|
||||||
|
return nil, fmt.Errorf("host info not supported on this platform")
|
||||||
|
}
|
||||||
|
|||||||
24
helper/hostutil/hostinfo_util.go
Normal file
24
helper/hostutil/hostinfo_util.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package hostutil
|
||||||
|
|
||||||
|
// VirutalMemoryStat holds commonly used memory measurements. We must have a
|
||||||
|
// local type here in order to avoid building the gopsutil library on certain
|
||||||
|
// arch types.
|
||||||
|
type VirtualMemoryStat struct {
|
||||||
|
// Total amount of RAM on this system
|
||||||
|
Total uint64
|
||||||
|
|
||||||
|
// RAM available for programs to allocate
|
||||||
|
//
|
||||||
|
// This value is computed from the kernel specific values.
|
||||||
|
Available uint64
|
||||||
|
|
||||||
|
// RAM used by programs
|
||||||
|
//
|
||||||
|
// This value is computed from the kernel specific values.
|
||||||
|
Used uint64
|
||||||
|
|
||||||
|
// Percentage of RAM used by programs
|
||||||
|
//
|
||||||
|
// This value is computed from the kernel specific values.
|
||||||
|
UsedPercent float64
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user