feat: Add -monitor option
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
cb53106e1f
commit
3b392700d3
4 changed files with 128 additions and 0 deletions
8
main.go
8
main.go
|
@ -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))
|
||||
|
|
Reference in a new issue