common

package
v0.0.0-...-6eec0fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const NOT_AVAILABLE = "N/A"
View Source
const NOT_SUPPORTED = "N/S"

Variables

View Source
var AMCBuild string

AMCBuild - AMC Build

View Source
var AMCEdition string

AMCEdition - AMC Edition (EE)

View Source
var AMCEnv string

AMCEnv - AMC Environment (dev/prod)

View Source
var AMCVersion string

AMCVersion - AMC Version

View Source
var ByFloatField = func(fieldName string, p1, p2 Stats) bool {
	return p1.TryFloat(fieldName, 0) < p2.TryFloat(fieldName, 0)
}

ByFloatField - sort by float field

View Source
var ByIntField = func(fieldName string, p1, p2 Stats) bool {
	return p1.TryInt(fieldName, 0) < p2.TryInt(fieldName, 0)
}

ByIntField - sort by int field

View Source
var ByStringField = func(fieldName string, p1, p2 Stats) bool {
	return p1.TryString(fieldName, "") < p2.TryString(fieldName, "")
}

ByStringField - sort by string field

Functions

func AMCIsEnterprise

func AMCIsEnterprise() bool

AMCIsEnterprise was originally for knowing if this is the EE version of AMC. It is now always true

func AMCIsProd

func AMCIsProd() bool

AMCIsProd - check if prod

func Comma

func Comma(v int64, sep string) string

Comma - convert integer into comma string

func DeleteEmpty

func DeleteEmpty(s []string) []string

DeleteEmpty - remove empty item from slice

func InitConfig

func InitConfig(configFile, configDir string, config *Config)

InitConfig - init the config struct

func MaxInt64

func MaxInt64(a, b int64) int64

MaxInt64 - Max function for Int64

func ParseTimeStrict

func ParseTimeStrict(layout, value string) (time.Time, error)

ParseTimeStrict parses a formatted string and returns the time value it represents. The output is identical to time.Parse except it returns an error for strings that don't format to the input value.

An example where the output differs from time.Parse would be: parseTimeStrict("1/2/06", "11/31/15")

  • time.Parse returns "2015-12-01 00:00:00 +0000 UTC"
  • parseTimeStrict returns an error

func PublicKeyFile

func PublicKeyFile(file string) ssh.AuthMethod

PublicKeyFile - return Public Key

func Round

func Round(val float64, roundOn float64, places int) (newVal float64)

Round - convert float to rounded int

func SSHAgent

func SSHAgent() ssh.AuthMethod

SSHAgent - get agent

func SetupDatabase

func SetupDatabase(filepath string)

SetupDatabase - create memsql tables

func SortStrings

func SortStrings(s []string) []string

SortStrings - sort slice (?)

func SplitHostPort

func SplitHostPort(addr string) (host string, port int, err error)

SplitHostPort - convert aerospike host string to basic parts

func StrDiff

func StrDiff(o, n []string) (added, removed []string)

StrDiff - compare slices into added and remove slices

func StrUniq

func StrUniq(l []string) []string

StrUniq is checking for uniqe strings

func ToNullString

func ToNullString(s string) sql.NullString

ToNullString - convert string into sql.NullString

Types

type Alert

type Alert struct {
	ID          int64
	Type        AlertType
	ClusterID   string
	NodeAddress string
	Namespace   sql.NullString
	Desc        string
	Created     time.Time
	LastOccured time.Time
	Resolved    NullTime
	Recurrence  int64
	Status      AlertStatus
}

Alert structure

type AlertBucket

type AlertBucket struct {
	// contains filtered or unexported fields
}

AlertBucket structure

func NewAlertBucket

func NewAlertBucket(size int) *AlertBucket

NewAlertBucket - new alert bucket

func (*AlertBucket) AlertsFrom

func (ad *AlertBucket) AlertsFrom(nodeAddress string, id int64) []*Alert

AlertsFrom - get alert from table

func (*AlertBucket) DrainNewAlerts

func (ad *AlertBucket) DrainNewAlerts() []*Alert

DrainNewAlerts - frain the news alerts

func (*AlertBucket) Recurring

func (ad *AlertBucket) Recurring(alert *Alert) *Alert

Recurring - recurring alert

func (*AlertBucket) RedAlertsFrom

func (ad *AlertBucket) RedAlertsFrom(nodeAddress string, ID int64) int

RedAlertsFrom - get red alerts

func (*AlertBucket) Register

func (ad *AlertBucket) Register(alert *Alert) (recurring bool)

Register - register alert

func (*AlertBucket) ResolveAlert

func (ad *AlertBucket) ResolveAlert(alert *Alert)

ResolveAlert - clear alert

type AlertStatus

type AlertStatus string

AlertStatus - type

const (
	AlertStatusRed    AlertStatus = "red"
	AlertStatusYellow AlertStatus = "yellow"
	AlertStatusGreen  AlertStatus = "green"
)

Alert colors

func (*AlertStatus) Scan

func (nt *AlertStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (AlertStatus) Value

func (nt AlertStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type AlertType

type AlertType int

AlertType - type

const (
	AlertTypeNodeStatus          AlertType = 0
	AlertTypeNodeVisibility      AlertType = 1
	AlertTypeNodeDisk            AlertType = 2
	AlertTypeNodeMemory          AlertType = 3
	AlertTypeNodeTransQueue      AlertType = 4
	AlertTypeNodeFileDescriptors AlertType = 5

	AlertTypeNamespaceAvailablePct           AlertType = 6
	AlertTypeNamespaceDiskPctHighWatermark   AlertType = 7
	AlertTypeNamespaceDiskPctStopWrites      AlertType = 8
	AlertTypeNamespaceMemoryPctHighWatermark AlertType = 9
	AlertTypeNamespaceMemoryPctStopWrites    AlertType = 10
)

Alert Types

type AlertsByID

type AlertsByID []*Alert

AlertsByID implements sort.Interface for []*Alert based on the Age field.

func (AlertsByID) Len

func (a AlertsByID) Len() int

func (AlertsByID) Less

func (a AlertsByID) Less(i, j int) bool

func (AlertsByID) Swap

func (a AlertsByID) Swap(i, j int)

type BackupRestore

type BackupRestore struct {
	Type      BackupRestoreType
	ID        string
	ClusterID string

	Namespace                string
	DestinationAddress       string
	Username                 string
	Password                 string
	DestinationPath          string
	Sets                     sql.NullString
	MetadataOnly             bool
	TerminateOnClusterChange bool
	ScanPriority             int
	Created                  time.Time
	Finished                 NullTime
	Status                   BackupRestoreStatus

	ModifiedBefore string
	ModifiedAfter  string

	Progress int
	Error    string

	SSHClient *SSHClient
	// contains filtered or unexported fields
}

BackupRestore struct

func NewBackupRestore

func NewBackupRestore(
	Type BackupRestoreType,
	ClusterID string,
	Namespace string,
	DestinationAddress string,
	Username string,
	Password string,
	DestinationPath string,
	Sets string,
	MetadataOnly bool,
	TerminateOnClusterChange bool,
	ScanPriority int,
	ModifiedBefore string,
	ModifiedAfter string,
	Status BackupRestoreStatus) *BackupRestore

NewBackupRestore - Create new backup/restore

func SuccessfulBackups

func SuccessfulBackups() ([]*BackupRestore, error)

SuccessfulBackups - return list of successful backups

func (*BackupRestore) Save

func (br *BackupRestore) Save() error

Save - save backup

func (*BackupRestore) UpdateError

func (br *BackupRestore) UpdateError(errorMsg string) error

UpdateError - update on error

func (*BackupRestore) UpdateProgress

func (br *BackupRestore) UpdateProgress(percent int) error

UpdateProgress - update progrss

func (*BackupRestore) UpdateStatus

func (br *BackupRestore) UpdateStatus(status BackupRestoreStatus) error

UpdateStatus - update status

type BackupRestoreStatus

type BackupRestoreStatus string

BackupRestoreStatus type

const (
	BackupStatusInProgress BackupRestoreStatus = "In Progress"
	BackupStatusFailed     BackupRestoreStatus = "Failure"
	BackupStatusFinished   BackupRestoreStatus = "Success"
)

BackupRestoreStatus

func (*BackupRestoreStatus) Scan

func (nt *BackupRestoreStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (BackupRestoreStatus) Value

func (nt BackupRestoreStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type BackupRestoreType

type BackupRestoreType string

BackupRestoreType type

const (
	BackupRestoreTypeBackup  BackupRestoreType = "backup"
	BackupRestoreTypeRestore BackupRestoreType = "restore"
)

BackupRestoreType

func (*BackupRestoreType) Scan

func (nt *BackupRestoreType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (BackupRestoreType) Value

func (nt BackupRestoreType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Config

type Config struct {
	AMC struct {
		UpdateInterval           int    `toml:"update_interval"`
		InactiveDurBeforeRemoval int    `toml:"cluster_inactive_before_removal"`
		CertFile                 string `toml:"certfile"`
		KeyFile                  string `toml:"keyfile"`
		ForceTLS12               bool   `toml:"force_tls12"`
		MaxTLSSecurity           bool   `toml:"max_tls_security"`
		StaticPath               string `toml:"static_dir"`

		// BackupHost         string `toml:"backup_host"`
		// BackupHostUser     string `toml:"backup_host_user"`
		// BackupHostPassword string `toml:"backup_host_password"`
		BackupHostKeyFile string `toml:"backup_host_public_key_file"`

		Database string `toml:"database"`

		Clusters map[string]struct {
			Host                 string `toml:"host"`
			TLSName              string `toml:"tls_name"`
			Port                 uint16 `toml:"port"`
			User                 string `toml:"user"`
			Password             string `toml:"password"`
			Alias                string `toml:"alias"`
			UseServicesAlternate bool   `toml:"use_services_alternate"`
			ShowInUI             bool   `toml:"show_in_ui"`
		} `toml:"clusters"`

		Bind     string `toml:"bind"`
		LogLevel string `toml:"loglevel"`
		ErrorLog string `toml:"errorlog"`
		Chdir    string `toml:"chdir"`
		Timeout  int    `toml:"timeout"`
		PIDFile  string `toml:"pidfile"`
	}

	Mailer struct {
		TemplatePath      string   `toml:"template_path"`
		Host              string   `toml:"host"`
		Port              uint16   `toml:"port"`
		User              string   `toml:"user"`
		Password          string   `toml:"password"`
		FromAddress       string   `toml:"from_address"`
		SendTo            []string `toml:"send_to"`
		AcceptInvalidCert bool     `toml:"accept_invalid_cert"`
		// contains filtered or unexported fields
	} `toml:"mailer"`

	BasicAuth struct {
		User     string `toml:"user"`
		Password string `toml:"password"`
	} `toml:"basic_auth"`

	TLS struct {
		ServerPool []string `toml:"server_cert_pool"`
		ClientPool map[string]struct {
			CertFile string `toml:"cert_file"`
			KeyFile  string `toml:"key_file"`
		} `toml:"client_certs"`
	} `toml:"tls"`

	LogFile *os.File
	// contains filtered or unexported fields
}

Config struct

func (*Config) AeroLogLevel

func (c *Config) AeroLogLevel() aslog.LogPriority

AeroLogLevel - return aslog.LogPriority

func (*Config) AlertEmails

func (c *Config) AlertEmails() []string

AlertEmails ?

func (*Config) AppendAlertEmails

func (c *Config) AppendAlertEmails(emails []string) error

AppendAlertEmails - send email

func (*Config) ClientPool

func (c *Config) ClientPool() []tls.Certificate

ClientPool - return clientPool

func (*Config) DeleteAlertEmails

func (c *Config) DeleteAlertEmails(emails []string) error

DeleteAlertEmails - delete email

func (*Config) FromAddress

func (c *Config) FromAddress() string

FromAddress - parse from address

func (*Config) LogLevel

func (c *Config) LogLevel() log.Level

LogLevel - return log.Level

func (*Config) ServerPool

func (c *Config) ServerPool() *x509.CertPool

ServerPool - return serverPool

type IndexType

type IndexType string

IndexType - Value should be a string

type Info

type Info map[string]string

Info - map type

func (Info) Clone

func (s Info) Clone() Info

Clone - clone Info object

func (Info) Float

func (s Info) Float(name string, aliases ...string) float64

Float - Value MUST exist, and MUST be an float64 or a convertible string. Panics if the above constraints are not met

func (Info) Get

func (s Info) Get(name string, aliases ...string) interface{}

Get - get info value from Info object

func (Info) GetMulti

func (s Info) GetMulti(names ...string) Info

GetMulti - get info value(s) from Info object

func (Info) Int

func (s Info) Int(name string, aliases ...string) int64

Int - Value MUST exist, and MUST be an int64 or a convertible string. Panics if the above constraints are not met

func (Info) ToInfo

func (s Info) ToInfo(name string) Info

ToInfo - Value should be an stats or a convertible string; otherwise nil is returns this function never panics

func (Info) ToInfoMap

func (s Info) ToInfoMap(name string, alias string, delim string) map[string]Info

ToInfoMap - Value should be an stats or a convertible string; otherwise nil is returns this function never panics

func (Info) ToStats

func (s Info) ToStats() Stats

ToStats - Value should be an stats or a convertible string; otherwise nil is returns this function never panics

func (Info) ToStatsMap

func (s Info) ToStatsMap(name string, alias string, delim string) map[string]Stats

ToStatsMap - Value should be an stats or a convertible string; otherwise nil is returns this function never panics

func (Info) TryFloat

func (s Info) TryFloat(name string, defValue float64, aliases ...string) float64

TryFloat - Value should be an float64 or a convertible string; otherwise defValue is returned this function never panics

func (Info) TryInt

func (s Info) TryInt(name string, defValue int64, aliases ...string) int64

TryInt - Value should be an int64 or a convertible string; otherwise defValue is returned this function never panics

func (Info) TryNumericValue

func (s Info) TryNumericValue(name string, defVal interface{}, aliases ...string) interface{}

TryNumericValue - Value should be an float64, int64 or a convertible string; otherwise defValue is returned this function never panics

func (Info) TryString

func (s Info) TryString(name string, defValue string, aliases ...string) string

TryString - Value should be a string; otherwise defValue is returned this function never panics

type InfoParser

type InfoParser struct {
	*bufio.Reader
}

InfoParser struct

func NewInfoParser

func NewInfoParser(s string) *InfoParser

NewInfoParser - new info parser

func (*InfoParser) Expect

func (ip *InfoParser) Expect(s string) error

Expect expect a value, assert if not expected value

func (*InfoParser) ReadFloat

func (ip *InfoParser) ReadFloat(delim byte) (float64, error)

ReadFloat - read float

func (*InfoParser) ReadUntil

func (ip *InfoParser) ReadUntil(delim byte) (string, error)

ReadUntil - read until delimiter

type JSONRawString

type JSONRawString string

JSONRawString - Value should be a string

func (*JSONRawString) MarshalJSON

func (m *JSONRawString) MarshalJSON() ([]byte, error)

MarshalJSON returns *m as the JSON encoding of m.

type NullTime

type NullTime struct {
	// contains filtered or unexported fields
}

NullTime to store time and nullibility

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*NullTime) Set

func (nt *NullTime) Set(t time.Time)

Set - sets the time

func (*NullTime) Valid

func (nt *NullTime) Valid() bool

Valid - check if Time is not NULL

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type SSHClient

type SSHClient struct {
	Config *ssh.ClientConfig
	Host   string
	Port   int
}

SSHClient struct

func (*SSHClient) RunCommand

func (client *SSHClient) RunCommand(cmd *SSHCommand) error

RunCommand - run ssh command

func (*SSHClient) Session

func (client *SSHClient) Session(cmd *SSHCommand) (*ssh.Session, error)

Session - return new ssh session

type SSHCommand

type SSHCommand struct {
	Path   string
	Env    []string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

SSHCommand struct

type SinglePointValue

type SinglePointValue struct {
	// contains filtered or unexported fields
}

SinglePointValue struct

func NewSinglePointValue

func NewSinglePointValue(timestamp *int64, value *float64) *SinglePointValue

NewSinglePointValue - create new PointValue for graphs

func (*SinglePointValue) Timestamp

func (spv *SinglePointValue) Timestamp(mult int64) *int64

Timestamp - get timestamp for graph

func (*SinglePointValue) TimestampJSON

func (spv *SinglePointValue) TimestampJSON(defVal *time.Time) *int64

TimestampJSON - return timestamp at unix time

func (*SinglePointValue) Value

func (spv *SinglePointValue) Value(defVal *float64) *float64

Value - return SinglePointValue value or default

type Stats

type Stats map[string]interface{}

Stats - map type

func AggregateInfo

func AggregateInfo(s Info, other Info) Stats

AggregateInfo - Value should be an float64 or a convertible string; otherwise defValue is returned this function never panics

func (Stats) AggregateStats

func (s Stats) AggregateStats(other Stats)

AggregateStats - Value should be an float64 or a convertible string this function never panics

func (Stats) Clone

func (s Stats) Clone() Stats

Clone - clone Stats

func (Stats) Del

func (s Stats) Del(names ...string)

Del - delete item from Stats

func (Stats) ExistsGet

func (s Stats) ExistsGet(name string) (interface{}, bool)

ExistsGet - get item from stats if exists

func (Stats) Get

func (s Stats) Get(name string, aliases ...string) interface{}

Get - get item from Stats

func (Stats) GetMulti

func (s Stats) GetMulti(names ...string) Stats

GetMulti - get item(s) from stats

func (Stats) Int

func (s Stats) Int(name string, aliases ...string) int64

Int - Value should be an int64, and should exist; otherwise panics

func (Stats) ToStringValues

func (s Stats) ToStringValues() map[string]interface{}

ToStringValues - conver Stats to string

func (Stats) TryFloat

func (s Stats) TryFloat(name string, defValue float64, aliases ...string) float64

TryFloat - Value should be an float64 or a convertible string; otherwise defValue is returned this function never panics

func (Stats) TryInt

func (s Stats) TryInt(name string, defValue int64, aliases ...string) int64

TryInt - Value should be an int64 or a convertible string; otherwise defValue is returned this function never panics

func (Stats) TryString

func (s Stats) TryString(name string, defValue string, aliases ...string) string

TryString - Value should be an int64 or a convertible string; otherwise defValue is returned this function never panics

type StatsBy

type StatsBy func(fieldName string, p1, p2 Stats) bool

StatsBy is the type of a "less" function that defines the ordering of its Stats arguments.

func (StatsBy) Sort

func (by StatsBy) Sort(fieldName string, statsList []Stats)

Sort - stats sorter

func (StatsBy) SortReverse

func (by StatsBy) SortReverse(fieldName string, statsList []Stats)

SortReverse - stats reverse sorter

type SyncInfo

type SyncInfo struct {
	// contains filtered or unexported fields
}

SyncInfo struct

func NewSyncInfo

func NewSyncInfo(info Info) *SyncInfo

NewSyncInfo - return sync info

func (*SyncInfo) Clone

func (s *SyncInfo) Clone() Info

Clone - clone sync info

func (*SyncInfo) Float

func (s *SyncInfo) Float(name string, aliases ...string) float64

Float - Value MUST exist, and MUST be an float64 or a convertible string. Panics if the above constraints are not met

func (*SyncInfo) Get

func (s *SyncInfo) Get(name string, aliases ...string) interface{}

Get SyncInfo

func (*SyncInfo) GetMulti

func (s *SyncInfo) GetMulti(names ...string) Info

GetMulti SyncInfo

func (*SyncInfo) Int

func (s *SyncInfo) Int(name string, aliases ...string) int64

Int - Value MUST exist, and MUST be an int64 or a convertible string. Panics if the above constraints are not met

func (*SyncInfo) SetInfo

func (s *SyncInfo) SetInfo(info Info)

SetInfo - set sync info

func (*SyncInfo) ToInfo

func (s *SyncInfo) ToInfo(name string) Info

ToInfo Syncinfo to info

func (*SyncInfo) ToInfoMap

func (s *SyncInfo) ToInfoMap(name string, alias string, delim string) map[string]Info

ToInfoMap - Value should be an stats or a convertible string; otherwise nil is returns this function never panics

func (*SyncInfo) ToStatsMap

func (s *SyncInfo) ToStatsMap(name string, alias string, delim string) map[string]Stats

ToStatsMap Syncinfo to statsMap

func (*SyncInfo) TryFloat

func (s *SyncInfo) TryFloat(name string, defValue float64, aliases ...string) float64

TryFloat - Value should be an float64 or a convertible string; otherwise defValue is returned this function never panics

func (*SyncInfo) TryInt

func (s *SyncInfo) TryInt(name string, defValue int64, aliases ...string) int64

TryInt - Value should be an int64 or a convertible string; otherwise defValue is returned this function never panics

func (*SyncInfo) TryNumericValue

func (s *SyncInfo) TryNumericValue(name string, defVal interface{}, aliases ...string) interface{}

TryNumericValue - Value should be an float64, int64 or a convertible string; otherwise defValue is returned this function never panics

func (*SyncInfo) TryString

func (s *SyncInfo) TryString(name string, defValue string, aliases ...string) string

TryString - Value should be a string; otherwise defValue is returned this function never panics

type SyncStats

type SyncStats struct {
	// contains filtered or unexported fields
}

SyncStats strunct

func NewSyncStats

func NewSyncStats(stats Stats) *SyncStats

NewSyncStats - create new SyncStats

func (*SyncStats) AggregateStatsTo

func (s *SyncStats) AggregateStatsTo(other Stats)

AggregateStatsTo - Value should be an float64 or a convertible string this function never panics

func (*SyncStats) Clone

func (s *SyncStats) Clone() Stats

Clone - SyncStats clone

func (*SyncStats) CloneInto

func (s *SyncStats) CloneInto(res Stats)

CloneInto - SyncStats clone info

func (*SyncStats) Del

func (s *SyncStats) Del(names ...string)

Del - SyncStats - delete stat

func (*SyncStats) Exists

func (s *SyncStats) Exists(name string) bool

Exists - SyncStats check if key exists

func (*SyncStats) ExistsGet

func (s *SyncStats) ExistsGet(name string) (interface{}, bool)

ExistsGet - SyncStats get stat if exists

func (*SyncStats) Get

func (s *SyncStats) Get(name string, aliases ...string) interface{}

Get - SyncStats get value

func (*SyncStats) GetMulti

func (s *SyncStats) GetMulti(names ...string) Stats

GetMulti - SyncStats - get multi keys

func (*SyncStats) Int

func (s *SyncStats) Int(name string, aliases ...string) int64

Int - Value MUST exist, and MUST be an int64 or a convertible string. Panics if the above constraints are not met

func (*SyncStats) Set

func (s *SyncStats) Set(name string, value interface{})

Set - SyncStats set value

func (*SyncStats) SetStats

func (s *SyncStats) SetStats(info Stats)

SetStats SyncStats set stats

func (*SyncStats) TryFloat

func (s *SyncStats) TryFloat(name string, defValue float64, aliases ...string) float64

TryFloat - Value should be an float64 or a convertible string; otherwise defValue is returned this function never panics

func (*SyncStats) TryInt

func (s *SyncStats) TryInt(name string, defValue int64, aliases ...string) int64

TryInt - Value should be an int64 or a convertible string; otherwise defValue is returned this function never panics

func (*SyncStats) TryString

func (s *SyncStats) TryString(name string, defValue string, aliases ...string) string

TryString - Value should be a string; otherwise defValue is returned this function never panics

type SyncValue

type SyncValue struct {
	// contains filtered or unexported fields
}

SyncValue struct

func NewSyncValue

func NewSyncValue(val interface{}) SyncValue

NewSyncValue - new sync value

func (*SyncValue) Get

func (sv *SyncValue) Get() interface{}

Get - get sync value

func (*SyncValue) Set

func (sv *SyncValue) Set(val interface{})

Set - set sync value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL