-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcheck_orchestrator.go
74 lines (62 loc) · 1.65 KB
/
check_orchestrator.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
package main
import (
"crypto/tls"
"fmt"
"net/http"
"os"
"strings"
"github.com/mackerelio/checkers"
)
var commands = map[string](func([]string) *checkers.Checker){
// "replication": checkReplication,
"clusterhealth": checkClusterHealth,
"clusterinfo": checkClusterInfo,
"status": checkStatus,
}
type StatusResponse struct {
Code string
Message string
Details []string
}
type orchestratorOpts struct {
Host string `short:"H" long:"host" default:"localhost" description:"Hostname"`
Port string `short:"p" long:"port" default:"3000" description:"Port"`
SSL bool `short:"S" long:"ssl" description:"Use SSL"`
NoCert bool `short:"I" long:"insecure" description:"Do not check SSL cert"`
HttpAuthName string `long:"http-auth-name" description:"Http authorization name"`
HttpAuthPass string `long:"http-auth-password" description:"Http authorization password"`
}
func separateSub(argv []string) (string, []string) {
if len(argv) == 0 || strings.HasPrefix(argv[0], "-") {
return "", argv
}
return argv[0], argv[1:]
}
func sslPrefix(useSSL bool) string {
if useSSL {
return "https"
}
return "http"
}
func getHttpTransport(allowInsecure bool) *http.Transport {
return &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: allowInsecure},
}
}
func main() {
subCmd, argv := separateSub(os.Args[1:])
fn, ok := commands[subCmd]
if !ok {
fmt.Println(`Usage:
check_orchestrator [subcommand] [OPTIONS]
SubCommands:`)
for k := range commands {
fmt.Printf(" %s\n", k)
}
os.Exit(1)
}
ckr := fn(argv)
//fmt.Println(result)
ckr.Name = fmt.Sprintf("ORCHESTRATOR_%s", strings.ToUpper(subCmd))
ckr.Exit()
}