-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mem][linux]: add ExLinux on mem package and move VirtualMemoryEx inf…
…o on it
- Loading branch information
Showing
3 changed files
with
47 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
//go:build linux | ||
|
||
package mem | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
) | ||
|
||
type ExVirtualMemory struct { | ||
ActiveFile uint64 `json:"activefile"` | ||
InactiveFile uint64 `json:"inactivefile"` | ||
ActiveAnon uint64 `json:"activeanon"` | ||
InactiveAnon uint64 `json:"inactiveanon"` | ||
Unevictable uint64 `json:"unevictable"` | ||
} | ||
|
||
func (v ExVirtualMemory) String() string { | ||
s, _ := json.Marshal(v) | ||
return string(s) | ||
} | ||
|
||
type ExLinux struct{} | ||
|
||
func NewExLinux() *ExLinux { | ||
return &ExLinux{} | ||
} | ||
|
||
func (ex *ExLinux) VirtualMemory() (*ExVirtualMemory, error) { | ||
return ex.VirtualMemoryWithContext(context.Background()) | ||
} | ||
|
||
func (ex *ExLinux) VirtualMemoryWithContext(ctx context.Context) (*ExVirtualMemory, error) { | ||
_, vmEx, err := fillFromMeminfoWithContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return vmEx, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters