Documentation ¶
Index ¶
- Constants
- Variables
- type CheckResult
- type HealthCheck
- type HealthPool
- type HealthStatus
- type Manager
- func (m *Manager) CleanNodeTracker(expectedNodes []string)
- func (m *Manager) Debug()
- func (m *Manager) GetNodeStatus(nodeUUID string) (Status, string, string, string, []string)
- func (m *Manager) GetPools(workerUUID string) (s []string)
- func (m *Manager) JSON() ([]byte, error)
- func (m *Manager) JSONAuthorized(uuid string) ([]byte, error)
- func (m *Manager) RegisterWorker(w *Worker)
- func (m *Manager) SetCheckPool(nodeUUID string, poolName string, backendName string, nodeName string, ...) bool
- func (m *Manager) SetCheckStatus(workerUUID string, status Status, errorMsg []string)
- func (m *Manager) SetStatus(uuid string, status Status) error
- func (m *Manager) StartWorkers()
- func (m *Manager) StopWorker(id int)
- func (m *Manager) StopWorkers()
- type Status
- type StatusType
- type Worker
- func (w *Worker) Debug()
- func (w *Worker) Description() string
- func (w *Worker) ErrorMsg() string
- func (w *Worker) ExecuteCheck() (Status, error, string)
- func (w *Worker) Poll()
- func (w *Worker) SendUpdate(result Status, errMsg []string)
- func (w *Worker) Start()
- func (w *Worker) Stop()
- func (w *Worker) UUID() string
Constants ¶
const ( Automatic = Status(iota) Online Offline Maintenance )
Status values of a check
Variables ¶
var IntToStatusType = map[int]Status{ 0: Automatic, 1: Online, 2: Offline, 3: Maintenance, }
IntToStatusType converts int to status
var StatusTypeToString = map[Status]string{ Automatic: "automatic", Online: "online", Offline: "offline", Maintenance: "maintance", }
StatusTypeToString converts status to string
var StringToStatusType = map[string]Status{ "automatic": Automatic, "online": Online, "offline": Offline, "maintenance": Maintenance, }
StringToStatusType converts string to status
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct { PoolName string `json:"poolname" toml:"poolname"` // pool this check belongs to BackendName string `json:"backendname" toml:"backendname"` // backend this check belongs to NodeName string `json:"nodename" toml:"nodename"` // node name of the check NodeUUID string `json:"nodeuuid" toml:"nodeuuid"` // node uuid for the check WorkerUUID string `json:"workeruuid" toml:"workeruuid"` // worker uuid who performed the check Description string `json:"description" toml:"description"` // description of the check (?) ActualStatus Status `json:"actualstatus" toml:"actualstatus"` // status of the check as it is performed ReportedStatus Status `json:"reportedstatus" toml:"reportedstatus"` // status of the check after applying state processing ErrorMsg []string `json:"errormsg" toml:"errormsg"` // error message if any }
CheckResult holds the check result output
type HealthCheck ¶
type HealthCheck struct { Type string `json:"type" toml:"type"` // check type TCPRequest string `json:"tcprequest" toml:"tcprequest"` // tcp request to send TCPReply string `json:"tcpreply" toml:"tcpreply"` // tcp reply to expect HTTPRequest string `json:"httprequest" toml:"httprequest"` // http request to send HTTPPostData string `json:"httppostdata" toml:"httppostdata"` // http post data to send HTTPHeaders []string `json:"httpheaders" toml:"httpheaders"` // http headers to send HTTPStatus int `json:"httpstatus" toml:"httpstatus"` // http status expected HTTPReply string `json:"httpreply" toml:"httpreply"` // http reply expected HTTPFollowRedirect string `json:"httpfollowredirect" toml:"httpfollowredirect"` // http follow redirects SSHUser string `json:"sshuser" toml:"sshuser"` // ssh user SSHPassword string `json:"sshpassword" toml:"sshpassword"` // ssh password SSHKey string `json:"sshkey" toml:"sshkey"` // ssh key PINGpackets int `json:"pingpackets" toml:"pingpackets"` // ping packets to send PINGtimeout int `json:"pingtimeout" toml:"pingtimeout"` // ping timeout Interval int `json:"interval" toml:"interval"` // how often to cechk Timeout int `json:"timeout" toml:"timeout"` // timeout performing check ActivePassiveID string `json:"activepassiveid" toml:"activepassiveid"` // used to link active/passive backends TLSConfig tlsconfig.TLSConfig `json:"tls" toml:"tls"` // tls config DisableAutoCheck bool `json:"disableautocheck" toml:"disableautocheck"` // only respond to check requests IP string `json:"ip" toml:"ip"` // specific ip SourceIP string `json:"sourceip" toml:"sourceip"` // specific ip Port int `json:"port" toml:"port"` // specific port OnlineState StatusType `json:"online_state" toml:"online_state"` // alternative online_state - default: online / optional: offline / maintenance OfflineState StatusType `json:"offline_state" toml:"offline_state"` // alternative offline_state - default: offline // contains filtered or unexported fields }
HealthCheck custom HealthCheck
type HealthPool ¶
type HealthPool struct { PoolName string `json:"poolname" toml:"poolname"` // name of the vip pool BackendName string `json:"backendname" toml:"backendname"` // name of the backend NodeName string `json:"nodename" toml:"nodename"` // name of the node Match string `json:"match" toml:"match"` // all/any Checks []string `json:"checks" toml:"checks"` // []checkuuid }
HealthPool contains a per nodeuuid information about all checks that apply to this node
type HealthStatus ¶
type HealthStatus struct { CheckStatus Status `json:"checkstatus" toml:"checkstatus"` // map[checkuuid]status - status returned by worker ManualStatus Status `json:"manualstatus" toml:"manualstatus"` // manual override ErrorMsg []string `json:"errormsg" toml:"errormsg"` // error message }
HealthStatus keeps track of the status of each workers health check
type Manager ¶
type Manager struct { Incoming chan CheckResult Workers []*Worker `json:"workers" toml:"workers"` HealthStatusMap map[string]HealthStatus `json:"healthstatusmap" toml:"healthstatusmap"` // keeps the health of all items HealthPoolMap map[string]HealthPool `json:"healthpoolmap" toml:"healthpoolmap"` // keeps a list of uuids and what checks apply to them Worker sync.RWMutex }
Manager manages Health of Node
func (*Manager) CleanNodeTracker ¶
CleanNodeTracker cleans up nodes beeing tracked, but do not exist anymore
func (*Manager) GetNodeStatus ¶
GetNodeStatus returns the combined status of all checks applicable to a specific backend
func (*Manager) JSONAuthorized ¶
JSONAuthorized returns unfiltered the healtheck status of the manager in json format
func (*Manager) RegisterWorker ¶
RegisterWorker adds the worker to the health manager
func (*Manager) SetCheckPool ¶
func (m *Manager) SetCheckPool(nodeUUID string, poolName string, backendName string, nodeName string, match string, checks []string) bool
SetCheckPool sets which checks for a specified backend are applicable
func (*Manager) SetCheckStatus ¶
SetCheckStatus sets the status of a worker check based on the health check result
func (*Manager) StartWorkers ¶
func (m *Manager) StartWorkers()
StartWorkers starts the workers to do the checking
func (*Manager) StopWorker ¶
StopWorker stops and removes a worker
type StatusType ¶
type StatusType struct {
Status `json:"status" toml:"status"` // status container for toml conversion
}
StatusType contains the status
func (*StatusType) UnmarshalJSON ¶
func (s *StatusType) UnmarshalJSON(text []byte) error
UnmarshalJSON converts json Status to Status uint8
func (*StatusType) UnmarshalText ¶
func (s *StatusType) UnmarshalText(text []byte) error
UnmarshalText converts json Status to Status uint8
type Worker ¶
type Worker struct { Pool string `json:"pool" toml:"pool"` Backend string `json:"backend" toml:"backend"` NodeName string `json:"nodename" toml:"nodename"` NodeUUID string `json:"nodeuuid" toml:"nodeuuid"` IP string `json:"ip" toml:"ip"` // IP used for check SourceIP string `json:"sourceip" toml:"sourceip"` Port int `json:"port" toml:"port"` // Port used for check Check HealthCheck `json:"check" toml:"check"` CheckResult Status `json:"checkresult" toml:"checkresult"` // CheckError string `json:"checkerror" toml:"checkerror"` UUIDStr string `json:"uuid" toml:"uuid"` // contains filtered or unexported fields }
Worker type executes a healthcheck on a single node
func NewWorker ¶
func NewWorker(pool string, backend string, nodeName string, nodeUUID string, ip string, port int, sourceIP string, check HealthCheck, cr chan CheckResult) *Worker
NewWorker creates a new worker for healthchecks
func (*Worker) Description ¶
Description provides a description of the check that the worker is managing
func (*Worker) ExecuteCheck ¶
executeCheck directs the check to the executioner and returns the result
func (*Worker) SendUpdate ¶
SendUpdate sends the updated status to the channel