aboutsummaryrefslogtreecommitdiff
path: root/cmd/monwork
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2018-12-11 12:37:30 +0100
committerGibheer <gibheer+git@zero-knowledge.org>2018-12-11 12:37:30 +0100
commitdece1ac2dc4554f66f8ec194269cd91d330edae1 (patch)
tree046475e3dcc818efd14d59ddc149e15192442fc9 /cmd/monwork
parentc62916c46e1cdfb0e04a9f17dd72ff7048924c99 (diff)
add level mappings
This allows to map the command exit codes to any other output level which can then be reported by the notification plugin. With the provided colors, the frontend will show them accordingly.
Diffstat (limited to 'cmd/monwork')
-rw-r--r--cmd/monwork/main.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd/monwork/main.go b/cmd/monwork/main.go
index 5c71a60..13c4f39 100644
--- a/cmd/monwork/main.go
+++ b/cmd/monwork/main.go
@@ -218,11 +218,13 @@ var (
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, msg)
-select id, $2, c.intval, c.enabled, c.notify, case when ac.msg is null then '' else ac.msg end from checks c
+ SQLRefreshActiveCheck = `insert into active_checks(check_id, cmdline, intval, enabled, notify, msg, mapping_id)
+select c.id, $2, c.intval, c.enabled, c.notify, case when ac.msg is null then '' else ac.msg end, case when c.mapping_id is not null then c.mapping_id when n.mapping_id is not null then n.mapping_id else 1 end
+from checks c
left join active_checks ac on c.id = ac.check_id
-where id = $1
+left join nodes n on c.node_id = n.id
+where c.id = $1
on conflict(check_id)
-do update set cmdline = $2, intval = excluded.intval, enabled = excluded.enabled, notify = excluded.notify;`
+do update set cmdline = $2, intval = excluded.intval, enabled = excluded.enabled, notify = excluded.notify, mapping_id = excluded.mapping_id;`
SQLUpdateLastRefresh = `update checks set last_refresh = now() where id = $1;`
)