Monitor update
Deploy / deploy (push) Successful in 8s

This commit is contained in:
2026-08-31 22:42:40 +05:00
parent 47ea18d020
commit 28702bd029
13 changed files with 434 additions and 217 deletions
+13 -12
View File
@@ -7,9 +7,9 @@ import (
)
type Config struct {
Links []Link `yaml:"links"`
Monitor []Item `yaml:"monitor"`
Exec []Item `yaml:"exec"`
Links []Link `yaml:"links"`
Monitor []Monitor `yaml:"monitor"`
Exec []Item `yaml:"exec"`
}
func loadConfig(path string) (*Config, error) {
@@ -31,21 +31,22 @@ func loadConfig(path string) (*Config, error) {
}
seen[l.Name] = true
}
for _, list := range [][]Item{cfg.Monitor, cfg.Exec} {
for _, it := range list {
if seen[it.Name] {
return nil, fmt.Errorf("duplicate name %q", it.Name)
}
seen[it.Name] = true
for _, m := range cfg.Monitor {
if seen[m.Name] {
return nil, fmt.Errorf("duplicate name %q", m.Name)
}
seen[m.Name] = true
}
for _, it := range cfg.Exec {
if seen[it.Name] {
return nil, fmt.Errorf("duplicate name %q", it.Name)
}
seen[it.Name] = true
}
for _, it := range cfg.Monitor {
if it.Refresh <= 0 {
return nil, fmt.Errorf("monitor %q: refresh must be > 0", it.Name)
}
if it.Data != "text" && it.Data != "percentage" {
return nil, fmt.Errorf("monitor %q: data must be text|percentage", it.Name)
}
}
for _, it := range cfg.Exec {
if len(it.ArgTypes) != it.Args {