aboutsummaryrefslogtreecommitdiff
path: root/cmd/monfront
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/monfront')
-rw-r--r--cmd/monfront/main.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go
index e600a9e..6f7c3dc 100644
--- a/cmd/monfront/main.go
+++ b/cmd/monfront/main.go
@@ -10,6 +10,7 @@ import (
"io/ioutil"
"log"
"net/http"
+ "os"
"strings"
"time"
@@ -179,6 +180,25 @@ func checkAction(w http.ResponseWriter, r *http.Request) {
case "ack":
setClause = "acknowledged = true"
setTable = "active_checks"
+
+ hostname, err := os.Hostname()
+ if err != nil {
+ log.Printf("could not resolve hostname: %s", err)
+ con.Error = "could not resolve hostname"
+ returnError(http.StatusInternalServerError, con, w)
+ return
+ }
+ if _, err := DB.Exec(`insert into notifications(check_id, states, output, mapping_id, notifier_id, check_host)
+ select ac.check_id, 0 || states[1:array_length(states, 1)], 'check acknowledged', ac.mapping_id,
+ cn.notifier_id, $2
+ from checks_notify cn
+ join active_checks ac on cn.check_id = ac.check_id
+ where cn.check_id = any ($1::int[])`, pq.Array(&checks), &hostname); err != nil {
+ log.Printf("could not acknowledge check: %s", err)
+ con.Error = "could not acknowledge check"
+ returnError(http.StatusInternalServerError, con, w)
+ return
+ }
case "comment":
if len(r.PostForm["comment"]) == 0 {
w.WriteHeader(http.StatusBadRequest)