mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
* Add HostPreflight v1beta2 * Work on TCP Load Balancer * Host disk usage collector and analyzer * Host memory analyzer * TCP port status * TCP load balancer * Review changes Co-authored-by: Marc Campbell <marc.e.campbell@gmail.com>
32 lines
598 B
Go
32 lines
598 B
Go
package collect
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/shirou/gopsutil/mem"
|
|
)
|
|
|
|
type MemoryInfo struct {
|
|
Total uint64 `json:"total"`
|
|
}
|
|
|
|
func HostMemory(c *HostCollector) (map[string][]byte, error) {
|
|
memoryInfo := MemoryInfo{}
|
|
|
|
vmstat, err := mem.VirtualMemory()
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to read virtual memory")
|
|
}
|
|
memoryInfo.Total = vmstat.Available
|
|
|
|
b, err := json.Marshal(memoryInfo)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to marshal memory info")
|
|
}
|
|
|
|
return map[string][]byte{
|
|
"system/memory.json": b,
|
|
}, nil
|
|
}
|