Iniziando servizio per il monitoring dello spazio su disco, raid, etc.

main
Antonio De Lucreziis 2 years ago
parent abf86ae549
commit d4b9dee6d9

@ -0,0 +1,39 @@
package jobs
import (
"os"
"path"
)
type Config struct {
ScriptsDir string `json:"scriptsDir"`
}
type Service struct {
Config Config
scriptPaths []string
}
func New(config Config) *Service {
return &Service{
Config: config,
}
}
func (s *Service) LoadScripts() error {
entries, err := os.ReadDir(s.Config.ScriptsDir)
if err != nil {
return err
}
s.scriptPaths = []string{}
for _, entry := range entries {
s.scriptPaths = append(s.scriptPaths,
path.Join(s.Config.ScriptsDir, entry.Name()),
)
}
return nil
}

@ -0,0 +1,18 @@
#!/bin/bash
DEVICE="/dev/md0"
TOTAL_DEVICES=$(mdadm -D "$DEVICE" | grep 'Total Devices' | cut -d':' -f 2 | tr -d ' ')
mdadm -D "$DEVICE" | tail -n "$TOTAL_DEVICES" | tr -s ' ' | cut -d' ' -f 6
# Example Output:
#
# active
# active
# active
# active
# active
#
# TODO: Non ho realmente trovato nella documentazione le altre parole, penso siano "missing" e "failing" però boh
Loading…
Cancel
Save