From a6ac23239274c73533cc0b3409469a2440689faf Mon Sep 17 00:00:00 2001 From: Gibheer Date: Mon, 10 Dec 2018 09:35:49 +0100 Subject: monwork - fix an issue with configuration generation New checks were not added to the active_checks, because they were never touched before. --- cmd/monwork/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cmd/monwork') 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;` -- cgit v1.2.3-70-g09d2