Need to enabled checks
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9df2804eb8
commit
554593a045
7 changed files with 27 additions and 1 deletions
|
@ -8,15 +8,19 @@ auth:
|
||||||
|
|
||||||
checks:
|
checks:
|
||||||
hdd:
|
hdd:
|
||||||
|
enabled: true
|
||||||
max_percent: 80
|
max_percent: 80
|
||||||
load:
|
load:
|
||||||
|
enabled: true
|
||||||
max_load_1: 10
|
max_load_1: 10
|
||||||
max_load_5: 8
|
max_load_5: 8
|
||||||
max_load_15: 5
|
max_load_15: 5
|
||||||
memory:
|
memory:
|
||||||
|
enabled: true
|
||||||
max: 100
|
max: 100
|
||||||
max_swap: 80
|
max_swap: 80
|
||||||
systemd:
|
systemd:
|
||||||
|
enabled: true
|
||||||
services:
|
services:
|
||||||
- sshd
|
- sshd
|
||||||
- test
|
- test
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
type HDDConfig struct {
|
type HDDConfig struct {
|
||||||
MaxPercent int `yaml:"max_percent"`
|
MaxPercent int `yaml:"max_percent"`
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HDD struct {
|
type HDD struct {
|
||||||
|
@ -13,6 +14,9 @@ type HDD struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h HDD) Execute() (ok bool, data interface{}, err error) {
|
func (h HDD) Execute() (ok bool, data interface{}, err error) {
|
||||||
|
if h.Config.Enabled == false {
|
||||||
|
return true, nil, nil
|
||||||
|
}
|
||||||
success := true
|
success := true
|
||||||
parts, _ := disk.Partitions(false)
|
parts, _ := disk.Partitions(false)
|
||||||
usage := make(map[string]float64)
|
usage := make(map[string]float64)
|
||||||
|
|
|
@ -8,6 +8,7 @@ type LoadConfig struct {
|
||||||
MaxLoad1 float64 `yaml:"max_load_1"`
|
MaxLoad1 float64 `yaml:"max_load_1"`
|
||||||
MaxLoad5 float64 `yaml:"max_load_5"`
|
MaxLoad5 float64 `yaml:"max_load_5"`
|
||||||
MaxLoad15 float64 `yaml:"max_load_15"`
|
MaxLoad15 float64 `yaml:"max_load_15"`
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Load struct {
|
type Load struct {
|
||||||
|
@ -15,6 +16,9 @@ type Load struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Load) Execute() (ok bool, data interface{}, err error) {
|
func (h Load) Execute() (ok bool, data interface{}, err error) {
|
||||||
|
if h.Config.Enabled == false {
|
||||||
|
return true, nil, nil
|
||||||
|
}
|
||||||
load, err := loadavg.Get()
|
load, err := loadavg.Get()
|
||||||
if load.Loadavg1 > h.Config.MaxLoad1 {
|
if load.Loadavg1 > h.Config.MaxLoad1 {
|
||||||
return false,load, nil
|
return false,load, nil
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
type MemoryConfig struct {
|
type MemoryConfig struct {
|
||||||
Max float64 `yaml:"max"`
|
Max float64 `yaml:"max"`
|
||||||
MaxSwap float64 `yaml:"max_swap"`
|
MaxSwap float64 `yaml:"max_swap"`
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Memory struct {
|
type Memory struct {
|
||||||
|
@ -15,6 +16,9 @@ type Memory struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Memory) Execute() (ok bool, data interface{}, err error) {
|
func (h Memory) Execute() (ok bool, data interface{}, err error) {
|
||||||
|
if h.Config.Enabled == false {
|
||||||
|
return true, nil, nil
|
||||||
|
}
|
||||||
memory, err := memory.Get()
|
memory, err := memory.Get()
|
||||||
fmt.Println(memory)
|
fmt.Println(memory)
|
||||||
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
type SystemdConf struct {
|
type SystemdConf struct {
|
||||||
Services []string `yaml:"services"`
|
Services []string `yaml:"services"`
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Systemd struct {
|
type Systemd struct {
|
||||||
|
@ -15,6 +16,9 @@ type Systemd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Systemd) Execute() (ok bool, data interface{}, err error) {
|
func (h Systemd) Execute() (ok bool, data interface{}, err error) {
|
||||||
|
if h.Config.Enabled == false {
|
||||||
|
return true, nil, nil
|
||||||
|
}
|
||||||
success := true
|
success := true
|
||||||
servicelist := make(map[string]bool)
|
servicelist := make(map[string]bool)
|
||||||
|
|
||||||
|
|
3
main.go
3
main.go
|
@ -100,6 +100,7 @@ func checkSystem() (map[string]ResultReturn, bool) {
|
||||||
globaleResult := true
|
globaleResult := true
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
res := make(map[string]ResultReturn)
|
res := make(map[string]ResultReturn)
|
||||||
|
mutex := sync.Mutex{}
|
||||||
for _, c := range checkList {
|
for _, c := range checkList {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(check checks.Check) {
|
go func(check checks.Check) {
|
||||||
|
@ -113,10 +114,12 @@ func checkSystem() (map[string]ResultReturn, bool) {
|
||||||
if s == false {
|
if s == false {
|
||||||
globaleResult = false
|
globaleResult = false
|
||||||
}
|
}
|
||||||
|
mutex.Lock()
|
||||||
res[check.Name()] = ResultReturn{
|
res[check.Name()] = ResultReturn{
|
||||||
Success: s,
|
Success: s,
|
||||||
Data: data,
|
Data: data,
|
||||||
}
|
}
|
||||||
|
mutex.Unlock()
|
||||||
}(c)
|
}(c)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
{{ if .checks.MemoryUsage.Data }}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 20%">Ram</th>
|
<th style="width: 20%">Ram</th>
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,6 +77,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
{{ if .checks.SystemLoad.Data }}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 20%">1</th>
|
<th style="width: 20%">1</th>
|
||||||
|
@ -90,6 +92,7 @@
|
||||||
<td>{{ .checks.SystemLoad.Data.Loadavg15 }}</td>
|
<td>{{ .checks.SystemLoad.Data.Loadavg15 }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue