This commit is contained in:
parent
4f861883fc
commit
27929b8039
1 changed files with 7 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package checks
|
package checks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/mackerelio/go-osstat/memory"
|
"github.com/mackerelio/go-osstat/memory"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,12 +16,18 @@ type Memory struct {
|
||||||
|
|
||||||
func (h Memory) Execute() (ok bool, data interface{}, err error) {
|
func (h Memory) Execute() (ok bool, data interface{}, err error) {
|
||||||
memory, err := memory.Get()
|
memory, err := memory.Get()
|
||||||
|
fmt.Println(memory)
|
||||||
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
||||||
ps := float64(100) / float64(memory.SwapTotal) * float64(memory.SwapUsed)
|
ps := float64(100) / float64(memory.SwapTotal) * float64(memory.SwapUsed)
|
||||||
res := make(map[string]interface{})
|
res := make(map[string]interface{})
|
||||||
res["row"] = memory
|
res["row"] = memory
|
||||||
res["ram"] = p
|
res["ram"] = p
|
||||||
res["swap"] = ps
|
res["swap"] = ps
|
||||||
|
if memory.SwapTotal == 0 {
|
||||||
|
res["swap"] = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(ps)
|
||||||
if p > h.Config.Max {
|
if p > h.Config.Max {
|
||||||
return false, res, nil
|
return false, res, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue