Skip to content

Commit

Permalink
get databases list from "barman list-server --minimal" command
Browse files Browse the repository at this point in the history
  • Loading branch information
preved911 committed Apr 15, 2020
1 parent f70e79a commit 594213c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ func barmanCheck() {
barmanUserName = "barman"
}

dbs := strings.Split(os.Getenv("BARMAN_CHECK_DATABASES"), ",")

go func() {
for {
cmd := exec.Command(
sudoExecPath,
fmt.Sprintf("--user=%s", barmanUserName),
barmanExecPath,
"list-server", "--minimal")

out, _ := cmd.CombinedOutput()
dbs := strings.Split(string(out), "\n")
dbs = dbs[:len(dbs)-1]

for _, db := range dbs {
cmd := exec.Command(
sudoExecPath,
Expand All @@ -55,12 +63,13 @@ func barmanCheck() {

err := cmd.Run()
if err != nil {
log.Printf("check failed: %s", err)
log.Printf("check failed: %s\n", err)
barmanCheckExitCode.WithLabelValues(db).Set(1)
} else {
barmanCheckExitCode.WithLabelValues(db).Set(0)
}
}

time.Sleep(30 * time.Second)
}
}()
Expand Down

0 comments on commit 594213c

Please sign in to comment.