Need to enabled checks
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Kekskurse 2021-11-29 06:02:41 +01:00
parent 9df2804eb8
commit 554593a045
Signed by: kekskurse
GPG Key ID: 728ACCB59341E7E4
7 changed files with 27 additions and 1 deletions

View File

@ -8,15 +8,19 @@ auth:
checks:
hdd:
enabled: true
max_percent: 80
load:
enabled: true
max_load_1: 10
max_load_5: 8
max_load_15: 5
memory:
enabled: true
max: 100
max_swap: 80
systemd:
enabled: true
services:
- sshd
- test

View File

@ -6,6 +6,7 @@ import (
type HDDConfig struct {
MaxPercent int `yaml:"max_percent"`
Enabled bool `yaml:"enabled"`
}
type HDD struct {
@ -13,6 +14,9 @@ type HDD struct {
}
func (h HDD) Execute() (ok bool, data interface{}, err error) {
if h.Config.Enabled == false {
return true, nil, nil
}
success := true
parts, _ := disk.Partitions(false)
usage := make(map[string]float64)

View File

@ -8,6 +8,7 @@ type LoadConfig struct {
MaxLoad1 float64 `yaml:"max_load_1"`
MaxLoad5 float64 `yaml:"max_load_5"`
MaxLoad15 float64 `yaml:"max_load_15"`
Enabled bool `yaml:"enabled"`
}
type Load struct {
@ -15,6 +16,9 @@ type Load struct {
}
func (h Load) Execute() (ok bool, data interface{}, err error) {
if h.Config.Enabled == false {
return true, nil, nil
}
load, err := loadavg.Get()
if load.Loadavg1 > h.Config.MaxLoad1 {
return false,load, nil

View File

@ -8,6 +8,7 @@ import (
type MemoryConfig struct {
Max float64 `yaml:"max"`
MaxSwap float64 `yaml:"max_swap"`
Enabled bool `yaml:"enabled"`
}
type Memory struct {
@ -15,6 +16,9 @@ type Memory struct {
}
func (h Memory) Execute() (ok bool, data interface{}, err error) {
if h.Config.Enabled == false {
return true, nil, nil
}
memory, err := memory.Get()
fmt.Println(memory)
p := float64(100) / float64(memory.Total) * float64(memory.Used)

View File

@ -8,6 +8,7 @@ import (
type SystemdConf struct {
Services []string `yaml:"services"`
Enabled bool `yaml:"enabled"`
}
type Systemd struct {
@ -15,6 +16,9 @@ type Systemd struct {
}
func (h Systemd) Execute() (ok bool, data interface{}, err error) {
if h.Config.Enabled == false {
return true, nil, nil
}
success := true
servicelist := make(map[string]bool)

View File

@ -100,6 +100,7 @@ func checkSystem() (map[string]ResultReturn, bool) {
globaleResult := true
wg := sync.WaitGroup{}
res := make(map[string]ResultReturn)
mutex := sync.Mutex{}
for _, c := range checkList {
wg.Add(1)
go func(check checks.Check) {
@ -113,10 +114,12 @@ func checkSystem() (map[string]ResultReturn, bool) {
if s == false {
globaleResult = false
}
mutex.Lock()
res[check.Name()] = ResultReturn{
Success: s,
Data: data,
}
mutex.Unlock()
}(c)
}
wg.Wait()

View File

@ -45,6 +45,7 @@
</div>
<div class="card-body">
{{ if .checks.MemoryUsage.Data }}
<table class="table">
<tr>
<th style="width: 20%">Ram</th>
@ -63,7 +64,7 @@
</td>
</tr>
</table>
{{ end }}
</div>
</div>
</div>
@ -76,6 +77,7 @@
</div>
<div class="card-body">
{{ if .checks.SystemLoad.Data }}
<table class="table">
<tr>
<th style="width: 20%">1</th>
@ -90,6 +92,7 @@
<td>{{ .checks.SystemLoad.Data.Loadavg15 }}</td>
</tr>
</table>
{{ end }}
</div>
</div>
</div>