Skip to content

Commit

Permalink
memInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Oct 18, 2024
1 parent c998523 commit 0eb2e37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions checkMemory.go → checkMemInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ import (
"github.com/infrasonar/go-libagent"
)

func readMemory(state map[string][]map[string]any) error {
func readMemInfo(state map[string][]map[string]any) error {
mem, err := linux.ReadMemInfo("/proc/meminfo")
if err != nil {
return err
}

item := map[string]any{
"name": "memory",
"free": mem.MemFree,
"total": mem.MemTotal,
"name": "memInfo",
"memFree": mem.MemFree,
"memTotal": mem.MemTotal,
}

state["memory"] = []map[string]any{item}
state["memInfo"] = []map[string]any{item}
return nil
}

func CheckMemory(check *libagent.Check) (map[string][]map[string]any, error) {
func CheckMemInfo(check *libagent.Check) (map[string][]map[string]any, error) {
state := map[string][]map[string]any{}

err := readMemory(state)
err := readMemInfo(state)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ func main() {
}
go checkDisk.Plan(quit)

CheckMemory := libagent.Check{
Key: "memory",
checkMemInfo := libagent.Check{
Key: "memInfo",
Collector: collector,
Asset: asset,
IntervalEnv: "CHECK_MEMORY_INTERVAL",
IntervalEnv: "CHECK_MEMINFO_INTERVAL",
DefaultInterval: 300,
NoCount: false,
SetTimestamp: false,
Fn: CheckMemory,
Fn: CheckMemInfo,
}
go CheckMemory.Plan(quit)
go checkMemInfo.Plan(quit)

// Wait for quit
<-quit
Expand Down

0 comments on commit 0eb2e37

Please sign in to comment.