f-29: watchdog: add checksubnet #29
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
ea60c0db54
commit
0fa84b8320
7 changed files with 497 additions and 2 deletions
|
|
@ -6,6 +6,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"git.g3e.fr/syonad/two/internal/netif"
|
||||
"git.g3e.fr/syonad/two/internal/watchdog/notify"
|
||||
"git.g3e.fr/syonad/two/pkg/systemd"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -40,6 +42,24 @@ func resourceNames(pairs map[string]string, prefix string) []string {
|
|||
return names
|
||||
}
|
||||
|
||||
type unitChecker interface {
|
||||
Status(unit string) (*systemd.ServiceStatus, error)
|
||||
}
|
||||
|
||||
func checkUnit(kind, name, unit string, u unitChecker, n notify.Notifier) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
st, err := u.Status(unit)
|
||||
if err != nil {
|
||||
n.Notify(kind, name, fmt.Sprintf("unit %s illisible: %v", unit, err))
|
||||
return
|
||||
}
|
||||
if st.ActiveState != "active" {
|
||||
n.Notify(kind, name, fmt.Sprintf("unit %s %s (%s)", unit, st.ActiveState, st.SubState))
|
||||
}
|
||||
}
|
||||
|
||||
func linkProblem(iface string) string {
|
||||
up, err := netif.LinkIsUp(iface)
|
||||
switch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue