-
Notifications
You must be signed in to change notification settings - Fork 29
/
main.go
79 lines (67 loc) · 1.38 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
79
package main
import (
"time"
"github.com/kovetskiy/godocs"
"github.com/kovetskiy/lorg"
"github.com/kovetskiy/spinner-go"
"github.com/reconquest/karma-go"
)
var (
debugMode bool
traceMode bool
logger = getLogger()
)
func init() {
spinner.SetInterval(time.Millisecond * 100)
}
func main() {
args, err := godocs.Parse(
docs, version,
godocs.UsePager, godocs.Usage(usage), godocs.Options(options),
)
if err != nil {
fatalln(err)
}
switch args["--verbosity"].(int) {
case 1:
debugMode = true
logger.SetLevel(lorg.LevelDebug)
case 2:
debugMode = true
traceMode = true
logger.SetLevel(lorg.LevelTrace)
}
config, err := NewConfig(args["--config"].(string))
if err != nil {
fatalln(
karma.Format(
err,
"problem with configuration",
),
)
}
zabbix, err := NewZabbix(
config.Server.Address,
config.Server.Username,
config.Server.Password,
config.Session.Path,
)
if err != nil {
fatalln(err)
}
switch {
case args["--triggers"].(bool):
err = handleTriggers(zabbix, config, args)
case args["--latest-data"].(bool):
err = handleLatestData(zabbix, config, args)
case args["--groups"].(bool):
err = handleUsersGroups(zabbix, config, args)
case args["--maintenances"].(bool):
err = handleMaintenances(zabbix, config, args)
case args["--hosts"].(bool):
err = handleHosts(zabbix, config, args)
}
if err != nil {
fatalln(err)
}
}