monfront - only ACK when the check is in alarm state
The acknowledged flag gets removed by checkers when the state changes to okay. But if we acknowledge a check when it is okay the notification system stops working.
This commit is contained in:
parent
4f5114fe3a
commit
49dac92034
@ -215,6 +215,9 @@ func checkAction(con *Context) {
|
||||
action = "reschedule"
|
||||
}
|
||||
|
||||
whereFields := []string{}
|
||||
whereVals := []any{}
|
||||
|
||||
switch action {
|
||||
case "mute":
|
||||
setTable = "checks_notify"
|
||||
@ -255,6 +258,8 @@ func checkAction(con *Context) {
|
||||
case "ack":
|
||||
setClause = "acknowledged = true"
|
||||
setTable = "active_checks"
|
||||
whereFields = append(whereFields, "states[0]")
|
||||
whereVals = append(whereVals, 0)
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
@ -312,7 +317,15 @@ func checkAction(con *Context) {
|
||||
whereColumn = "check_id"
|
||||
}
|
||||
|
||||
_, err := DB.Exec("update "+setTable+" set "+setClause+" where "+whereColumn+" = any ($1::bigint[]);", pq.Array(&checks))
|
||||
sql := "update " + setTable + " set " + setClause + " where " + whereColumn + " = any($1::bigint[])"
|
||||
if len(whereFields) > 0 {
|
||||
whereVals = append([]any{pq.Array(&checks)}, whereVals...)
|
||||
for i, column := range whereFields {
|
||||
sql = sql + " and " + column + fmt.Sprintf(" = $%d", i+1)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := DB.Exec(sql, whereVals)
|
||||
if err != nil {
|
||||
con.w.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprintf(con.w, "could not store changes")
|
||||
|
Loading…
Reference in New Issue
Block a user