-
Notifications
You must be signed in to change notification settings - Fork 2
/
lbclient.go
66 lines (57 loc) · 1.64 KB
/
lbclient.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
package main
import (
"fmt"
"os"
"github.com/jessevdk/go-flags"
logger "github.com/sirupsen/logrus"
"gitlab.cern.ch/lb-experts/golbclient/lbconfig"
)
const (
// OID : SNMP identifier
OID = ".1.3.6.1.4.1.96.255.1"
// Version number
Version = "2.2.1"
// Release number
Release = "3"
)
func main() {
// Create a new instance of the launcher that will be responsible for the runtime
launcher := lbconfig.NewAppLauncher()
// Parse the application arguments
err := launcher.ParseApplicationArguments(os.Args[1:])
if err != nil {
// Check if the help flag [--help || -h] was detected
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
} else {
logger.Fatalf("A fatal error occurred when attempting to parse the application arguments. Error [%s]",
err.Error())
}
}
// Check if the version flag was detected
if launcher.AppOptions.Version {
fmt.Printf("lbclient version %s.%s\n", Version, Release)
os.Exit(0)
}
// Apply the logger settings
err = launcher.ApplyLoggerSettings()
if err != nil {
logger.Fatalf("A fatal error occurred when attempting to apply the logger settings. Error [%s]",
err.Error())
}
// Run the launcher
err = launcher.Run()
if err != nil {
logger.Fatalf("A fatal error occurred when attempting to run the application. Error [%s]", err.Error())
}
if len(launcher.AppOptions.ExecutionConfiguration.CheckConfigFilePath) != 0 {
logger.Info("The configuration file is correct")
} else {
// Print the output
launcher.PrintOutput(OID)
}
//Send to Go-Ermis
if launcher.AppOptions.LbPostFile != "" {
launcher.PostToErmis(launcher.AppOptions.LbPostFile)
}
}