-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
78 lines (56 loc) · 1.3 KB
/
main.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
"os"
"github.com/NETWAYS/go-check"
"github.com/NETWAYS/go-check/result"
)
const readme = `Check plugin for the AKCP Sensorprobe X plus`
const license = `
Copyright (C) 2023 NETWAYS GmbH <[email protected]>
`
// nolint: gochecknoglobals
var (
// These get filled at build time with the proper vaules
version = "development"
commit = "HEAD"
date = "latest"
)
//goland:noinspection GoBoolExpressions
func buildVersion() string {
result := version
if commit != "" {
result = fmt.Sprintf("%s\ncommit: %s", result, commit)
}
if date != "" {
result = fmt.Sprintf("%s\ndate: %s", result, date)
}
result += "\n" + license
return result
}
func main() {
defer check.CatchPanic()
plugin := check.NewConfig()
version := buildVersion()
plugin.Name = "check_akcp_sensorprobeXplus"
plugin.Version = version
plugin.Readme = readme
plugin.Timeout = 30
config := &Config{}
config.BindArguments(plugin.FlagSet)
plugin.ParseArguments()
if len(os.Args) <= 1 {
plugin.FlagSet.Usage()
check.ExitRaw(check.Unknown, "No arguments given")
}
err := config.Validate()
if err != nil {
check.ExitError(err)
}
var overall result.Overall
err = config.Run(&overall)
if err != nil {
check.ExitError(err)
}
check.ExitRaw(overall.GetStatus(), overall.GetOutput())
}