fill in state_change column
Any time the state of the check changes, we need to refresh the column. This will be used in the frontend. This way it is much faster than using the notifications and also doesn't rely on the last of it being still around.
This commit is contained in:
parent
2bfe75c8a7
commit
142f9cf358
@ -145,7 +145,10 @@ func check(thread int, db *sql.DB, waitDuration, timeout time.Duration, hostname
|
||||
msg := output.String()
|
||||
|
||||
if _, err := tx.Exec(`update active_checks ac
|
||||
set next_time = now() + intval, states = ARRAY[$2::int] || states[1:4], msg = $3, acknowledged = case when $4 then false else acknowledged end
|
||||
set next_time = now() + intval, states = ARRAY[$2::int] || states[1:4],
|
||||
msg = $3,
|
||||
acknowledged = case when $4 then false else acknowledged end,
|
||||
state_since = case $2 when states[1] then state_since else now() end
|
||||
where check_id = $1`, id, &state, &msg, states.ToOK()); err != nil {
|
||||
log.Printf("[%d] could not update row '%d': %s", thread, id, err)
|
||||
tx.Rollback()
|
||||
@ -158,6 +161,7 @@ where check_id = $1`, id, &state, &msg, states.ToOK()); err != nil {
|
||||
join checks_notify cn on ac.check_id = cn.check_id
|
||||
join mapping_level ml on ac.mapping_id = ml.mapping_id and s.s = ml.source
|
||||
where ac.check_id = $1
|
||||
and ac.acknowledged = false
|
||||
group by cn.notifier_id;`, &id, &msg, &mapId, &hostname); err != nil {
|
||||
log.Printf("[%d] could not create notification for '%d': %s", thread, id, err)
|
||||
tx.Rollback()
|
||||
|
Loading…
Reference in New Issue
Block a user