develop
Norwin 6 years ago
parent bc8f02e0a9
commit ca051cd1cc

@ -5,7 +5,7 @@ Cross platform command line application to run health checks against sensor stat
This tool lets you automatically check if senseBoxes are still runnning correctly,
and when that's not the case, notifies you.
Currently, email notifications are implemented, but other transports can be added easily.
Implemented health checks are [described below](#possible-values-for-defaulthealthchecksevents), and new ones can be added just as easily (given some knowledge of programming).
Implemented health checks are [described below](#available-healthchecks), and new ones can be added just as easily (given some knowledge of programming).
The tool has multiple modes of operation:
@ -61,7 +61,7 @@ Contributions are welcome!
Check out the following locations for plugging in new functionality:
- new notification transports: [core/notifiers.go](core/notifiers.go)
- new health checks: [core/healthcheck*.go](core/healtchecks.go)
- new health checks: [core/healthcheck*.go](core/healthchecks.go)
- new commands: [cmd/](cmd/)
Before committing and submitting a pull request, please run `go fmt ./ cmd/ core/`.

@ -55,11 +55,11 @@ var debugNotificationsCmd = &cobra.Command{
host, _ := os.Hostname()
err = n.Submit(core.Notification{
Subject: "Test notification from opeSenseMap notifier",
Subject: "Test notification from openSenseMap notifier",
Body: fmt.Sprintf("Your notification set up on %s is working fine!", host),
})
if err != nil {
notLog.Warnf("could not submit test notification for %s notifier!", transport)
notLog.Warnf("could not submit test notification for %s notifier: %s", transport, err)
continue
}
notLog.Info("Test notification (successfully?) submitted, check the specified inbox")

@ -4,9 +4,10 @@ import (
"os"
"strings"
"github.com/noerw/osem_notify/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/noerw/osem_notify/utils"
)
// initConfig reads in config file and ENV variables if set.

@ -42,7 +42,9 @@ func (results BoxCheckResults) Log() {
countErr++
}
}
if countErr == 0 {
if len(boxResults) == 0 {
boxLog.Infof("%s: no checks defined", box.Name)
} else if countErr == 0 {
boxLog.Infof("%s: all is fine!", box.Name)
}
}

@ -5,8 +5,13 @@ import (
"strconv"
)
const (
nameMin = "measurement_min"
nameMax = "measurement_max"
)
var checkMeasurementMin = checkType{
name: "measurement_min",
name: nameMin,
toString: func(r CheckResult) string {
return fmt.Sprintf("Sensor %s (%s) reads low value of %s", r.TargetName, r.Target, r.Value)
},
@ -14,7 +19,7 @@ var checkMeasurementMin = checkType{
}
var checkMeasurementMax = checkType{
name: "measurement_min",
name: nameMax,
toString: func(r CheckResult) string {
return fmt.Sprintf("Sensor %s (%s) reads high value of %s", r.TargetName, r.Target, r.Value)
},
@ -41,8 +46,8 @@ func validateMeasurementMinMax(e NotifyEvent, s Sensor, b Box) (CheckResult, err
return result, err
}
if e.Type == eventMeasurementValMax && val > thresh ||
e.Type == eventMeasurementValMin && val < thresh {
if e.Type == nameMax && val > thresh ||
e.Type == nameMin && val < thresh {
result.Status = CheckErr
}

@ -9,13 +9,9 @@ import (
)
const (
CheckOk = "OK"
CheckErr = "FAILED"
eventMeasurementAge = "measurement_age"
eventMeasurementValMin = "measurement_min"
eventMeasurementValMax = "measurement_max"
eventMeasurementValFaulty = "measurement_faulty"
eventTargetAll = "all" // if event.Target is this value, all sensors will be checked
CheckOk = "OK"
CheckErr = "FAILED"
eventTargetAll = "all" // if event.Target is this value, all sensors will be checked
)
type checkType = struct {

Loading…
Cancel
Save