diff options
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;` |