-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
68 lines (55 loc) · 1.29 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
package main
// Use SURF_DEBUG_HEADERS=1 environment variable to print debug headers.
import (
"fmt"
"os"
)
/* Nagios exit status */
const (
OK = iota
WARNING
CRITICAL
UNKNOWN
)
var rmap = map[int]string{
OK: "OK",
WARNING: "WARNING",
CRITICAL: "CRITICAL",
UNKNOWN: "UNKNOWN",
}
/* Application defaults */
type Defaults struct {
Author string
Critical int
Repo string
Version string
Warning int
}
const author = "Claudio Ramirez <[email protected]>"
const repo = "https://github.com/nxadm/check-shib3idp-login"
const warning = 5 // timeout seconds
const critical = 20 // timeout seconds
const version = "v0.3.0"
var defaults = Defaults{
Author: author,
Repo: repo,
Warning: warning,
Critical: critical,
Version: version,
}
func main() {
/* Command line interface */
params := getParams(defaults)
/* Configuration file */
config, err := retrieveValues(params.ConfigFile)
if err != nil {
fmt.Printf("[UNKNOWN] Error reading the configuration file: %v\n", err)
os.Exit(UNKNOWN)
}
/* Login */
result := login(config, params, defaults)
/* Exit status */
fmt.Printf("[%s] Threshold (w:%d,c:%d), transaction performed in %f seconds: %s\n",
rmap[result.Code], params.Warning, params.Critical, result.Elapsed, result.Msg)
os.Exit(result.Code)
}