-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (29 loc) · 831 Bytes
/
main.go
File metadata and controls
36 lines (29 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"log"
"github.com/NETWAYS/go-check"
)
func main() {
defer check.CatchPanic()
config := check.NewConfig()
config.Name = "check_test"
config.Readme = `Test Plugin`
config.Version = "1.0.0"
config.Timeout = 10
value := config.FlagSet.IntP("value", "", 10, "test value")
warning := config.FlagSet.IntP("warning", "w", 20, "warning threshold")
critical := config.FlagSet.IntP("critical", "c", 50, "critical threshold")
config.ParseArguments()
if config.Debug {
log.Println("Start logging")
}
// time.Sleep(20 * time.Second)
if *value > *critical {
check.Exit(check.Critical, fmt.Sprintf("value is %d", *value))
} else if *value > *warning {
check.Exit(check.Warning, fmt.Sprintf("value is %d", *value))
} else {
check.Exit(check.OK, fmt.Sprintf("value is %d", *value))
}
}