aboutsummaryrefslogtreecommitdiff
path: root/cmd/moncheck
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/moncheck')
-rw-r--r--cmd/moncheck/main.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/cmd/moncheck/main.go b/cmd/moncheck/main.go
index 6aa34a5..3bac52e 100644
--- a/cmd/moncheck/main.go
+++ b/cmd/moncheck/main.go
@@ -27,11 +27,12 @@ var (
type (
Config struct {
- DB string `json:"db"`
- Timeout string `json:"timeout"`
- Wait string `json:"wait"`
- Path []string `json:"path"`
- Workers int `json:"workers"`
+ DB string `json:"db"`
+ Timeout string `json:"timeout"`
+ Wait string `json:"wait"`
+ Path []string `json:"path"`
+ Workers int `json:"workers"`
+ CheckerID int `json:"checker_id"`
}
States []int
@@ -73,14 +74,14 @@ func main() {
}
for i := 0; i < config.Workers; i++ {
- go check(i, db, waitDuration, timeout, hostname)
+ go check(i, db, waitDuration, timeout, hostname, config.CheckerID)
}
wg := sync.WaitGroup{}
wg.Add(1)
wg.Wait()
}
-func check(thread int, db *sql.DB, waitDuration, timeout time.Duration, hostname string) {
+func check(thread int, db *sql.DB, waitDuration, timeout time.Duration, hostname string, checker_id int) {
for {
tx, err := db.Begin()
if err != nil {
@@ -91,14 +92,10 @@ func check(thread int, db *sql.DB, waitDuration, timeout time.Duration, hostname
from active_checks
where next_time < now()
and enabled
+ and checker_id = $1
order by next_time
for update skip locked
- limit 1;`)
- if err != nil {
- log.Printf("[%d] could not start query: %s", thread, err)
- tx.Rollback()
- continue
- }
+ limit 1;`, checker_id)
var (
id int64
cmdLine []string