|
|
|
@ -12,6 +12,7 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CheckCommand struct {
|
|
|
|
|
Debug bool `short:"d" long:"debug" description:"Turn on debugging"`
|
|
|
|
|
ConfigFile string `short:"f" long:"config-file" description:"Name of config file" value-name:"FILE"`
|
|
|
|
|
Servers ServersCommand `command:"servers" description:"checks on servers"`
|
|
|
|
|
Snapshots SnapshotsCommand `command:"snapshots" description:"checks on snapshots"`
|
|
|
|
@ -31,7 +32,12 @@ type CheckConfig struct {
|
|
|
|
|
func config(configFile string) {
|
|
|
|
|
|
|
|
|
|
if configFile == "" {
|
|
|
|
|
return
|
|
|
|
|
if !checkFileExistance( "config/check.toml") {
|
|
|
|
|
Unknown(fmt.Sprintf("Configuration file is missing: %s", configFile))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
configFile = "config/check.toml"
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
viper.SetConfigFile(configFile)
|
|
|
|
@ -40,29 +46,28 @@ func config(configFile string) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("Config file not found or error parsing: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Config.UserId = viper.GetString("gridscale.userid")
|
|
|
|
|
Config.Token = viper.GetString("gridscale.token")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
if checkFileExistance("config/check.toml") {
|
|
|
|
|
config("config/check.toml")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (os.Getenv("GRIDSCALE_USER") != "") && (os.Getenv("GRIDSCALE_TOKEN") != "") {
|
|
|
|
|
Config.UserId = os.Getenv("GRIDSCALE_USER")
|
|
|
|
|
Config.Token = os.Getenv("GRIDSCALE_TOKEN")
|
|
|
|
|
} else {
|
|
|
|
|
Config.UserId = viper.GetString("gridscale.userid")
|
|
|
|
|
Config.Token = viper.GetString("gridscale.token")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gsConfig := gsclient.DefaultConfiguration(Config.UserId, Config.Token)
|
|
|
|
|
Config.Client = gsclient.NewClient(gsConfig)
|
|
|
|
|
config := gsclient.NewConfiguration(
|
|
|
|
|
"https://api.gridscale.io",
|
|
|
|
|
Config.UserId,
|
|
|
|
|
Config.Token,
|
|
|
|
|
Checker.Debug, true, 120, 500,100)
|
|
|
|
|
Config.Client = gsclient.NewClient(config)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var parser = flags.NewParser(&Checker, flags.Default)
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
if _, err := parser.Parse(); err != nil {
|
|
|
|
|
var parser = flags.NewParser(&Checker, flags.Default)
|
|
|
|
|
_, err := parser.Parse();
|
|
|
|
|
if err != nil {
|
|
|
|
|
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
} else {
|
|
|
|
|