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"
|
action = "reschedule"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whereFields := []string{}
|
||||||
|
whereVals := []any{}
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case "mute":
|
case "mute":
|
||||||
setTable = "checks_notify"
|
setTable = "checks_notify"
|
||||||
@ -255,6 +258,8 @@ func checkAction(con *Context) {
|
|||||||
case "ack":
|
case "ack":
|
||||||
setClause = "acknowledged = true"
|
setClause = "acknowledged = true"
|
||||||
setTable = "active_checks"
|
setTable = "active_checks"
|
||||||
|
whereFields = append(whereFields, "states[0]")
|
||||||
|
whereVals = append(whereVals, 0)
|
||||||
|
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -312,7 +317,15 @@ func checkAction(con *Context) {
|
|||||||
whereColumn = "check_id"
|
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 {
|
if err != nil {
|
||||||
con.w.WriteHeader(http.StatusInternalServerError)
|
con.w.WriteHeader(http.StatusInternalServerError)
|
||||||
fmt.Fprintf(con.w, "could not store changes")
|
fmt.Fprintf(con.w, "could not store changes")
|
||||||
|
Loading…
Reference in New Issue
Block a user