Added problem state in notification
This commit is contained in:
parent
6629b834fd
commit
f77a65ff66
10
main.go
10
main.go
@ -215,25 +215,25 @@ func entryDatapoint(w http.ResponseWriter, r *http.Request, sess *session.T) { /
|
||||
logger.Debug("entry", "datapoint", dpoint, "value", value, "trigger", trigger, "result", out)
|
||||
|
||||
var problemID int
|
||||
var problemState string
|
||||
switch v := out.(type) {
|
||||
case bool:
|
||||
// Trigger returning true - a problem occurred
|
||||
if v {
|
||||
problemID, err = ProblemStart(trigger)
|
||||
logger.Info("FOO", "problemID", problemID, "err==nil", err == nil)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).Log()
|
||||
logger.Error("entry", "error", err)
|
||||
}
|
||||
|
||||
problemState = "PROBLEM"
|
||||
} else {
|
||||
// A problem didn't occur.
|
||||
problemID, err = ProblemClose(trigger)
|
||||
logger.Info("FOO", "problemID", problemID, "err==nil", err == nil)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).Log()
|
||||
logger.Error("entry", "error", err)
|
||||
}
|
||||
problemState = "OK"
|
||||
}
|
||||
|
||||
// Has a change in problem state happened?
|
||||
@ -244,7 +244,7 @@ func entryDatapoint(w http.ResponseWriter, r *http.Request, sess *session.T) { /
|
||||
logger.Debug("notification", "trigger", trigger.ID, "state", "change")
|
||||
}
|
||||
|
||||
err = notificationManager.Send(problemID, []byte(trigger.Name), func(notificationService *notification.Service, err error) {
|
||||
err = notificationManager.Send(problemID, []byte(problemState+": "+trigger.Name), func(notificationService *notification.Service, err error) {
|
||||
logger.Info(
|
||||
"notification",
|
||||
"service", (*notificationService).GetType(),
|
||||
@ -611,7 +611,7 @@ func pageDatapointValues(w http.ResponseWriter, r *http.Request, _ *session.T) {
|
||||
PAGE: "datapoint_values",
|
||||
MENU: "datapoints",
|
||||
Icon: "datapoints",
|
||||
Label: "Values for "+datapoint.Name,
|
||||
Label: "Values for " + datapoint.Name,
|
||||
}
|
||||
|
||||
page.Data = map[string]any{
|
||||
|
Loading…
Reference in New Issue
Block a user