Documentation ¶
Index ¶
- Variables
- type AgentConfig
- type Alert
- type AlertRepo
- type AlertType
- type AppContext
- type AppContextFactory
- type Check
- type CheckRepo
- type CheckResult
- type CheckResultDetail
- type CheckResultRepo
- type CheckState
- type CheckStateByPriority
- type CheckStateDetail
- type CheckStateRepo
- type CheckStatus
- type CheckType
- type CoordinatorInfo
- type CoordinatorLoad
- type Period
- type PeriodRepo
- type PeriodType
- type RoleRepo
- type StatusSummary
- type Subject
- type SubjectCheckID
- type SubjectRepo
- type TagRepo
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("The requested object could not be found")
ErrNotFound is a DB-agnostic object not found error
var LocalCheckTypes = []CheckType{ CheckExec, CheckHTTP, CheckPort, CheckMemory, CheckCPU, CheckDisk, }
LocalCheckTypes lists the Checks that are executed locally by an agent.
var RemoteCheckTypes = []CheckType{ CheckAgentDown, CheckVersion, }
RemoteCheckTypes lists the Checks that are executed remotely by a coordinator.
Functions ¶
This section is empty.
Types ¶
type AgentConfig ¶
type AgentConfig struct { ID uuid.UUID Name string // Coordinator node addresses the agent may use Coordinators []string // Checks the agent is to perform Checks []Check Modified time.Time }
AgentConfig describes a specific subject's agent configuration.
func NewAgentConfig ¶
func NewAgentConfig(subject Subject, checks []Check, periods []Period, coordinators []string) AgentConfig
NewAgentConfig returns a new AgentConfig object with the given settings.
func (AgentConfig) GetModified ¶
func (ac AgentConfig) GetModified() time.Time
GetModified returns the last modified date of the agent config.
type Alert ¶
type Alert struct { ID uuid.UUID `bson:"_id,omitempty"` Name string Type AlertType Parameters map[string]string ReminderInterval int Roles []string Tags []string Modified time.Time }
Alert describes an alert to be executed when a check fails.
func (Alert) GetModified ¶
GetModified returns the last modified date of the Alert.
func (Alert) ReminderDuration ¶
ReminderDuration returns the Alert's ReminderInterval as a time.Duration.
type AlertType ¶
type AlertType int
AlertType is an enumeration of Alert types.
const ( AlertNone AlertType = iota // AlertExec type is an external executable. Parameter "command" defines // the command to execute. AlertExec // AlertEmail type is an email alert. Parameters "to", "cc", and "bcc" define // recipients, while "subject" and "body" are both templates for creating // the message. See https://golang.org/pkg/text/template/. AlertEmail // AlertPagerDuty type raises incidents using the PagerDuty API. Parameter // "service" gives the service endpoint to use, while "subject" and "body" // work as in AlertEmail. AlertPagerDuty // AlertMock is used for integration testing ONLY. AlertMock )
type AppContext ¶
type AppContext interface { SubjectRepo() SubjectRepo CheckRepo() CheckRepo CheckResultRepo() CheckResultRepo CheckStateRepo() CheckStateRepo AlertRepo() AlertRepo TagRepo() TagRepo RoleRepo() RoleRepo PeriodRepo() PeriodRepo CheckConnection() error Close() error }
type AppContextFactory ¶
type AppContextFactory interface { Get() (AppContext, error) Close() error }
type Check ¶
type Check struct { ID uuid.UUID `bson:"_id,omitempty"` Name string // Type of check Type CheckType // Check parameters (varies by CheckType) Parameters map[string]string // Frequency in seconds to perform the check Interval int // Roles that this check applies to Roles []string // Tags for this check Tags []string // Timestamp the check was last modified Modified time.Time }
Check describes a single health check.
func (Check) GetModified ¶
GetModified returns the last modified date of the Check.
func (Check) IntervalDuration ¶
IntervalDuration returns the Check's Interval as a time.Duration.
type CheckRepo ¶
type CheckRepo interface { Find(id uuid.UUID) (Check, error) Create(check *Check) error Update(check Check) error Delete(checkID uuid.UUID) error Count() (int, error) Search(name, role, tag string) ([]Check, error) ForRoles(roles []string) ([]Check, error) OfTypes(types []CheckType) ([]Check, error) OfTypesForRoles(types []CheckType, roles []string) ([]Check, error) }
type CheckResult ¶
type CheckResult struct { SubjectCheckID ID uuid.UUID `bson:"_id"` Time time.Time Status CheckStatus }
CheckResult describes a single result of a single health check on a subject.
func NewCheckResult ¶
func NewCheckResult(subjectID, checkID uuid.UUID, time time.Time, result CheckStatus) CheckResult
NewCheckResult creates and initializes a new CheckResult.
func (CheckResult) GetModified ¶
func (cr CheckResult) GetModified() time.Time
GetModified returns the creation date of the CheckResult, as they are immutable.
type CheckResultDetail ¶
type CheckResultDetail struct { CheckResult Subject Subject Check Check }
CheckResultDetail includes the full details of a CheckResult's Subject and Check.
func (CheckResultDetail) GetModified ¶
func (crd CheckResultDetail) GetModified() time.Time
GetModified returns the most recent of the CheckResult date, the Subject modified date, and the Check modified date.
type CheckResultRepo ¶
type CheckResultRepo interface { Create(check *CheckResult) error Count() (int, error) DeleteBySubject(subjectID uuid.UUID) error DeleteByCheck(checkID uuid.UUID) error DeleteBySubjectCheck(id SubjectCheckID) error }
type CheckState ¶
type CheckState struct { ID SubjectCheckID `bson:"_id"` StatusChanged time.Time Updated time.Time Status CheckStatus Roles []string `json:"-"` Tags []string `json:"-"` Type CheckType Owner uuid.UUID `json:"Owner,omitempty",bson:"omitempty"` Reminders map[string]time.Time `json:"-",bson:"omitempty"` }
CheckState describes the status of a single check on a subject.
func (CheckState) GetModified ¶
func (cs CheckState) GetModified() time.Time
GetModified returns the last updated date of the CheckState.
type CheckStateByPriority ¶
type CheckStateByPriority []CheckState
CheckStateByPriority is a collection type used for sorting CheckStates by status & age.
func (CheckStateByPriority) Len ¶
func (s CheckStateByPriority) Len() int
func (CheckStateByPriority) Less ¶
func (s CheckStateByPriority) Less(i, j int) bool
func (CheckStateByPriority) Swap ¶
func (s CheckStateByPriority) Swap(i, j int)
type CheckStateDetail ¶
type CheckStateDetail struct { CheckState Subject Subject Check Check }
CheckStateDetail includes the full details of a CheckState's Subject and Check.
func (CheckStateDetail) GetModified ¶
func (csd CheckStateDetail) GetModified() time.Time
GetModified returns the most recent of the CheckState update date, the Subject modified date, and the Check modified date.
type CheckStateRepo ¶
type CheckStateRepo interface { Find(id SubjectCheckID) (CheckState, error) Upsert(check CheckState) error DeleteBySubject(subjectID uuid.UUID) error DeleteByCheck(checkID uuid.UUID) error DeleteBySubjectCheck(id SubjectCheckID) error Count() (int, error) ForOwner(owner uuid.UUID) ([]CheckState, error) ForTypes(types []CheckType) ([]CheckState, error) CoordinatorWorkload() (CoordinatorLoad, error) InStatusRoles(statuses []CheckStatus, role []string) ([]CheckState, error) CountInRolesByStatus(role []string) (StatusSummary, error) }
type CheckStatus ¶
type CheckStatus int
CheckStatus describes the basic severity of a check result.
const ( // StatusNone indicates a check that has not been executed StatusNone CheckStatus = iota // StatusOK is the result of a check that is passing. StatusOK // StatusWarning indicates a non-urgent or partial failure state. StatusWarning // StatusCritical indicates an urgent failure state. StatusCritical // StatusFailed is the result when a check fails to execute. StatusFailed = -1 )
func (CheckStatus) String ¶
func (cs CheckStatus) String() string
type CheckType ¶
type CheckType int
CheckType is an enumeration of check types
const ( CheckNone CheckType = iota // CheckExec type is an external executable returning a 0 exit code if OK, // 1 if notice, 2 if warning, 3 if critical. Parameter "command" defines // command to execute. CheckExec // CheckHTTP type is an HTTP check. CheckHTTP // CheckPort type is a simple check if a port is accepting connections. CheckPort // CheckAgentDown type is an inspection of how long ago an agent checked in. CheckAgentDown // CheckMemory type is a memory and/or swap threshold check. CheckMemory // CheckCPU type is a CPU use threshold check. CheckCPU // CheckDisk type is a disk use threshold check. CheckDisk // CheckVersion type is a Coordinator version update check. CheckVersion )
type CoordinatorInfo ¶
CoordinatorInfo describes a coordinator node.
type CoordinatorLoad ¶
type CoordinatorLoad map[uuid.UUID]int
CoordinatorLoad maps Coordinators to the number of remote checks assigned to them.
type Period ¶
type Period struct { ID uuid.UUID `bson:"_id,omitempty"` Name string Type PeriodType Modified time.Time Start time.Time End time.Time Parameters map[string]string Roles []string Tags []string Subjects []uuid.UUID }
Period encapsulates a window of time where check and/or alert behavior is modified, such as a quiet, blackout, redirect, or vigilance period.
func (Period) EffectiveModified ¶
EffectiveModified returns the most recent time of effect for the Period. This is the later of the modified date, the start date (if in the past), and the end date (if in the past).
func (Period) GetModified ¶
GetModified returns the last modified date of the Period.
type PeriodRepo ¶
type PeriodRepo interface { Find(id uuid.UUID) (Period, error) Create(alert *Period) error Update(alert Period) error Delete(alertID uuid.UUID) error Count() (int, error) Search(name, role, tag string) ([]Period, error) FindForSubject(subject Subject, types []PeriodType) ([]Period, error) FindForSubjectChecks(subject Subject, tags []string, types []PeriodType) ([]Period, error) FindByType(types []PeriodType) ([]Period, error) }
type PeriodType ¶
type PeriodType int
PeriodType is an enumeration of Period types.
const ( // PeriodNone is the default, and has no effect. PeriodNone PeriodType = iota // PeriodBlackout ceases monitoring entirely. PeriodBlackout // PeriodQuiet ceases alerting but not monitoring. PeriodQuiet )
type StatusSummary ¶
StatusSummary describes a breakdown of counts by status.
type Subject ¶
type Subject struct { ID uuid.UUID `bson:"_id,omitempty"` Name string Roles []string Modified time.Time LastCheckIn time.Time }
Subject describes a thing being monitored.
func (Subject) GetModified ¶
GetModified returns the last modified date of the Subject.
type SubjectCheckID ¶
type SubjectCheckID struct { SubjectID uuid.UUID CheckID uuid.UUID }
SubjectCheckID is a composite of subject ID and check ID
func (SubjectCheckID) String ¶
func (scid SubjectCheckID) String() string
type SubjectRepo ¶
type SubjectRepo interface { Find(id uuid.UUID) (Subject, error) Create(subject *Subject) error Update(subject Subject) error Delete(subjectID uuid.UUID) error Count() (int, error) Named(name string) (Subject, error) Search(name, role string) ([]Subject, error) ByRoles(roles []string) ([]Subject, error) }