release/release-0.2.0
parent d15b08aa2c
commit e5e91c751d

@ -3,30 +3,28 @@
package main
import (
"os"
"fmt"
"github.com/jessevdk/go-flags"
"github.com/spf13/viper"
"log"
"os"
)
type CheckCommand struct {
Servers ServersCommand `command:"servers" description:"checks on servers"`
Servers ServersCommand `command:"servers" description:"checks on servers"`
Snapshots SnapshotsCommand `command:"snapshots" description:"checks on snapshots"`
Storages StoragesCommand `command:"storages" description:"checks on storages"`
Storages StoragesCommand `command:"storages" description:"checks on storages"`
}
var Checker CheckCommand
var Config CheckConfig
type CheckConfig struct {
UserId string
Token string
Token string
}
func main() {
var parser = flags.NewParser(&Checker, flags.Default)
@ -59,7 +57,6 @@ func main() {
Unknown("no subcommands specificed.")
}
func Ok(msg string) {
fmt.Println("OK - " + msg)
os.Exit(0)

@ -3,8 +3,8 @@
package main
type ServersCommand struct {
List ListServersCommand `command:"list"`
Status ServersStatusCommand `command:"status"`
List ListServersCommand `command:"list"`
Status ServersStatusCommand `command:"status"`
}
var serversCommand StoragesCommand
@ -12,4 +12,3 @@ var serversCommand StoragesCommand
func (x *ServersCommand) Execute(args []string) error {
return nil
}

@ -33,4 +33,3 @@ func (x *ListServersCommand) Execute(args []string) error {
func init() {
}

@ -8,7 +8,7 @@ import (
)
type ServersStatusCommand struct {
Status string `short:"s" long:"status" description:"value of status to compare against" choice:"active" choice:"deleted" required:"yes"`
Status string `short:"s" long:"status" description:"value of status to compare against" choice:"active" choice:"deleted" required:"yes"`
ServerUUID string `short:"u" long:"uuid" description:"uuid of server to check" required:"yes"`
}
@ -26,7 +26,6 @@ func (x *ServersStatusCommand) Execute(args []string) error {
Critical(fmt.Sprintf("Server state critical - State required: '%s' - State found: '%s'", x.Status, server.Status))
}
Ok(fmt.Sprintf("State required: '%s' - State found: '%s'", x.Status, server.Status))
// never reached
@ -35,4 +34,3 @@ func (x *ServersStatusCommand) Execute(args []string) error {
func init() {
}

@ -3,7 +3,7 @@
package main
type SnapshotsCommand struct {
Age SnapshotsAgeCommand `command:"age" description:"commands relating to the age of snapshots"`
Age SnapshotsAgeCommand `command:"age" description:"commands relating to the age of snapshots"`
Count SnapshotsCountCommand `command:"count" description:"commands relating to the amount of snapshots"`
}
@ -12,4 +12,3 @@ var snapshotsCommand SnapshotsCommand
func (x *SnapshotsCommand) Execute(args []string) error {
return nil
}

@ -4,15 +4,15 @@ package main
import (
"fmt"
"time"
"g.hazardous.org/fkr/libretto/virtualmachine/gridscale"
"time"
)
type SnapshotsAgeCommand struct {
Critical int `short:"c" description:"Critical value" required:"yes" description:"Number of <unit> time the youngest snapshot is allowed to be before critical"`
Warning int `short:"w" description:"Warning value" required:"yes" description:"Number of <unit> time the youngest snapshot is allowed to be before warning"`
Critical int `short:"c" description:"Critical value" required:"yes" description:"Number of <unit> time the youngest snapshot is allowed to be before critical"`
Warning int `short:"w" description:"Warning value" required:"yes" description:"Number of <unit> time the youngest snapshot is allowed to be before warning"`
StorageUUID string `short:"u" long:"uuid" description:"uuid of storage to check" required:"yes"`
Unit string `short:"n" long:"unit" description:"unit: hours or days. default: hours" choice:"hours" choice:"days"`
Unit string `short:"n" long:"unit" description:"unit: hours or days. default: hours" choice:"hours" choice:"days"`
}
var snapshotsAgeCommand SnapshotsAgeCommand
@ -30,12 +30,12 @@ func (x *SnapshotsAgeCommand) Execute(args []string) error {
Unknown("Error retrieving snapshots")
}
warningDuration := time.Duration(x.Warning)*time.Hour
criticalDuration := time.Duration(x.Critical)*time.Hour
warningDuration := time.Duration(x.Warning) * time.Hour
criticalDuration := time.Duration(x.Critical) * time.Hour
if x.Unit == "days" {
warningDuration = warningDuration*24
criticalDuration = criticalDuration*24
warningDuration = warningDuration * 24
criticalDuration = criticalDuration * 24
}
checkAge(*snapshot, warningDuration, criticalDuration)

@ -8,8 +8,8 @@ import (
)
type SnapshotsCountCommand struct {
Critical int `short:"c" description:"Critical value" required:"yes" description:"how few snapshots must only exist to count as critical"`
Warning int `short:"w" description:"Warning value" required:"yes" description:"how few snapshots must only exist to count as warning"`
Critical int `short:"c" description:"Critical value" required:"yes" description:"how few snapshots must only exist to count as critical"`
Warning int `short:"w" description:"Warning value" required:"yes" description:"how few snapshots must only exist to count as warning"`
StorageUUID string `short:"u" long:"uuid" description:"uuid of storage to check" optional:"no"`
}

@ -17,4 +17,3 @@ func (x *StoragesCommand) Execute(args []string) error {
fmt.Println("storages")
return nil
}

@ -33,4 +33,3 @@ func (x *StorageListCommand) Execute(args []string) error {
func init() {
}

Loading…
Cancel
Save