diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2018-12-10 09:35:49 +0100 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2018-12-10 09:35:49 +0100 |
commit | a6ac23239274c73533cc0b3409469a2440689faf (patch) | |
tree | f9cf0495070f4695592965700d89ca2ec6a14e1c /cmd | |
parent | 6c2bea53657395a41b5493c381d798ac233ac139 (diff) |
monwork - fix an issue with configuration generation
New checks were not added to the active_checks, because they were never
touched before.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/monwork/main.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd/monwork/main.go b/cmd/monwork/main.go index 48b43bd..392ab61 100644 --- a/cmd/monwork/main.go +++ b/cmd/monwork/main.go @@ -161,11 +161,13 @@ var ( SQLGetConfigUpdates = `select c.id, co.command, c.options from checks c join commands co on c.command_id = co.id - where c.last_refresh < c.updated + where c.last_refresh < c.updated or c.last_refresh is null limit 1 for update of c skip locked;` - SQLRefreshActiveCheck = `insert into active_checks(check_id, cmdline, intval, enabled, notify) -select id, $2, intval, enabled, notify from checks where id = $1 + SQLRefreshActiveCheck = `insert into active_checks(check_id, cmdline, intval, enabled, notify, msg) +select id, $2, c.intval, c.enabled, c.notify, case when ac.msg is null then '' else ac.msg end from checks c +left join active_checks ac on c.id = ac.check_id +where id = $1 on conflict(check_id) do update set cmdline = $2, intval = excluded.intval, enabled = excluded.enabled, notify = excluded.notify;` SQLUpdateLastRefresh = `update checks set last_refresh = now() where id = $1;` |