Archived
1
0
Fork 0

feat: Add -monitor option

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2022-08-31 18:40:52 +02:00
parent cb53106e1f
commit 3b392700d3
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
4 changed files with 128 additions and 0 deletions

View file

@ -53,6 +53,9 @@ func main() {
pidWaitTimeout := flag.Int("pid-wait-timeout", 0, "Seconds to wait before giving up when another instance is running")
retention := flag.Int("retention", 0, "Automatically remove products from the database with this number of days old (disabled by default)")
api := flag.Bool("api", false, "Start the HTTP API")
monitor := flag.Bool("monitor", false, "Perform health check with Nagios output")
warningTimeout := flag.Int("monitor-warning-timeout", 300, "Raise a warning alert when the last execution time has reached this number of seconds (see -monitor)")
criticalTimeout := flag.Int("monitor-critical-timeout", 600, "Raise a critical alert when the last execution time has reached this number of seconds (see -monitor)")
flag.Parse()
@ -138,6 +141,11 @@ func main() {
}
}
// start monitoring
if *monitor {
os.Exit(Monitor(db, *warningTimeout, *criticalTimeout))
}
// start the api
if *api {
log.Fatal(StartAPI(db, config.APIConfig))