This commit is contained in:
parent
b5196312d2
commit
96ee365569
3 changed files with 11 additions and 1 deletions
|
@ -10,3 +10,4 @@ checks:
|
|||
max_load_15: 5
|
||||
memory:
|
||||
max: 100
|
||||
max_swap: 80
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
type MemoryConfig struct {
|
||||
Max float64 `yaml:"max"`
|
||||
MaxSwap float64 `yaml:"max_swap"`
|
||||
}
|
||||
|
||||
type Memory struct {
|
||||
|
@ -15,12 +16,17 @@ type Memory struct {
|
|||
func (h Memory) Execute() (ok bool, data interface{}, err error) {
|
||||
memory, err := memory.Get()
|
||||
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
||||
ps := float64(100) / float64(memory.SwapTotal) * float64(memory.SwapUsed)
|
||||
res := make(map[string]interface{})
|
||||
res["row"] = memory
|
||||
res["ram"] = p
|
||||
res["swap"] = ps
|
||||
if p > h.Config.Max {
|
||||
return false, res, nil
|
||||
}
|
||||
if ps > h.Config.MaxSwap {
|
||||
return false, res, nil
|
||||
}
|
||||
|
||||
return true, res,nil
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
if(data.responseText != "") {
|
||||
handleData(data)
|
||||
}
|
||||
|
||||
setTimeout("getData();", 10000);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -88,13 +90,14 @@
|
|||
|
||||
$("#rampercent").empty()
|
||||
$("#rampercent").append('<b>Ram</b><br><div class="progress"><div class="progress-bar" role="progressbar" style="width: '+o.Checks["Memory usage"].data["ram"]+'%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">' +o.Checks["Memory usage"].data["ram"]+ '%</div></div>');
|
||||
$("#rampercent").append('<b>Swap</b><br><div class="progress"><div class="progress-bar" role="progressbar" style="width: '+o.Checks["Memory usage"].data["swap"]+'%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">' +o.Checks["Memory usage"].data["swap"]+ '%</div></div>');
|
||||
|
||||
|
||||
console.log(keys)
|
||||
console.log(o.Checks["Disc space"].success)
|
||||
|
||||
|
||||
setTimeout("getData();", 10000);
|
||||
|
||||
}
|
||||
getData();
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue