Skip to content

Commit

Permalink
add support for swap in machine/info
Browse files Browse the repository at this point in the history
  • Loading branch information
pacoxu committed Dec 1, 2021
1 parent 99d3532 commit e738b06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions info/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ type MachineInfo struct {
// The amount of memory (in bytes) in this machine
MemoryCapacity uint64 `json:"memory_capacity"`

// The amount of swap (in bytes) in this machine
SwapCapacity uint64 `json:"memory_capacity"`

// Memory capacity and number of DIMMs by memory type
MemoryByType map[string]*MemoryInfo `json:"memory_by_type"`

Expand Down
6 changes: 6 additions & 0 deletions machine/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func Info(sysFs sysfs.SysFs, fsInfo fs.FsInfo, inHostNamespace bool) (*info.Mach
return nil, err
}

swapCapacity, err := GetMachineSwapCapacity()
if err != nil {
return nil, err
}

nvmInfo, err := nvm.GetInfo()
if err != nil {
return nil, err
Expand Down Expand Up @@ -128,6 +133,7 @@ func Info(sysFs sysfs.SysFs, fsInfo fs.FsInfo, inHostNamespace bool) (*info.Mach
CpuFrequency: clockSpeed,
MemoryCapacity: memoryCapacity,
MemoryByType: memoryByType,
SwapCapacity: swapCapacity,
NVMInfo: nvmInfo,
HugePages: hugePagesInfo,
DiskMap: diskMap,
Expand Down

0 comments on commit e738b06

Please sign in to comment.