check

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckDocsMarkdownTpl = `
Checks Command Documentation
============================

Get latest docs via: ` + "`" + `./sens8 -check-docs` + "`" + `

{{ range $doc := .Docs }}
### ` + "`" + `{{ $doc.Id }}` + "`" + `

**Resources**: {{ StringsJoin $doc.Resources ", " }}

{{ $doc.Description }}

` + "```" + `
{{ $doc.Flags }}
` + "```" + `

{{ end }}
`
View Source
var CheckDocsTextTpl = `` /* 199-byte string literal not displayed */
View Source
var (
	Defaults = make(map[string]interface{})
)

Functions

func CheckFactoryIds

func CheckFactoryIds() []string

CheckFactoryIds gets the list of registered check ids

func GenCheckDocs added in v0.2.0

func GenCheckDocs(tpl string) string

GenCheckDocs generates the usage docs for checks with the given template

func GenCheckDocsMarkdown added in v0.2.0

func GenCheckDocsMarkdown() string

GenCheckDocsMarkdown generates the usage docs for checks in markdown meant for external (github) docs

func GenCheckDocsText added in v0.2.0

func GenCheckDocsText() string

GenCheckDocsText generates the usage docs for checks in a format suitable for CLI

func RegisterCheck

func RegisterCheck(id string, factory CheckFactory, resourceTypes []string) error

RegisterCheck registers checks in the check factory. Call this in init()

Types

type BaseCheck

type BaseCheck struct {
	Config CheckConfig
}

func (*BaseCheck) GetConfig

func (c *BaseCheck) GetConfig() *CheckConfig

func (*BaseCheck) GetHash

func (c *BaseCheck) GetHash() uint64

type Check

type Check interface {
	// GetHash returns the computed hash of the check config
	GetHash() uint64

	// GetConfig return its CheckConfig
	GetConfig() *CheckConfig

	// Update updates the check with the resource that the controller received
	Update(resource interface{})

	// Execute run the check
	Execute() (CheckResult, error)

	// Usage returns the help docs for the check
	Usage() CheckUsage
}

func NewCheck

func NewCheck(config CheckConfig, resourceType string) (Check, error)

NewCheck factory for checks. instantiates checks based on the config Id (first chunk of `command`)

func NewDaemonSetStatus added in v0.2.0

func NewDaemonSetStatus(config CheckConfig) (Check, error)

NewDaemonSetStatus creates a new daemonSet health check

func NewDeploymentStatus

func NewDeploymentStatus(config CheckConfig) (Check, error)

NewDeploymentStatus creates a new deployment health check

func NewHsHealthCheck

func NewHsHealthCheck(config CheckConfig) (Check, error)

NewHsHealthCheck creates a new deployment health check

func NewHsHealthCheckV2 added in v0.2.2

func NewHsHealthCheckV2(config CheckConfig) (Check, error)

NewHsHealthCheckV2 creates a new deployment health check

func NewHttp added in v0.2.0

func NewHttp(config CheckConfig) (Check, error)

NewDeploymentStatus creates a new deployment health check

func ParseCheckConfigs

func ParseCheckConfigs(jsonData string, checkSource string, resourceType string) ([]Check, []error)

ParseCheckConfigs unmarshals config data (an array of checks) and initializes each configs as a check. It collects errors and returns any valid checks as we don't want a bad config in the config array invalidate the whole array.

type CheckConfig

type CheckConfig struct {
	Name        string                 `json:"name"`
	Command     string                 `json:"command"`
	Interval    int                    `json:"interval"`
	Handler     *string                `json:"handler,omitempty"`
	Handlers    *[]string              `json:"handlers,omitempty"`
	Source      *string                `json:"source,omitempty"`
	Deregister  *bool                  `json:"deregister,omitempty"`
	Id          string                 `json:"-"`
	Hash        uint64                 `json:"-"`
	Argv        []string               `json:"-"`
	ExtraFields map[string]interface{} `json:"-"`
}

type CheckDocs added in v0.2.0

type CheckDocs struct {
	CheckUsage
	Id        string
	Resources []string
}

func Docs

func Docs() []CheckDocs

Docs gets the usage docs for all registered checks

type CheckFactory

type CheckFactory func(config CheckConfig) (Check, error)

type CheckResponse

type CheckResponse struct {
	Client string      `json:"client"`
	Check  interface{} `json:"check"` // we have arbitrary fields, so can't type this
}

type CheckResult

type CheckResult struct {
	CheckConfig
	Status   CheckStatus `json:"status"`
	Output   string      `json:"output"`
	Duration float64     `json:"duration,omitempty"`
	Issued   int64       `json:"issued,omitempty"`
	Executed int64       `json:"executed,omitempty"`
}

func NewCheckResultFromConfig

func NewCheckResultFromConfig(conf CheckConfig) CheckResult

NewCheckResultFromConfig creates a new check result from config data and populates timestamps

func (*CheckResult) JsonResponse

func (c *CheckResult) JsonResponse(client string) ([]byte, error)

JsonResponse wraps the result in a response and marshals it into json including all extra check config fields

type CheckStatus

type CheckStatus int
const (
	OK CheckStatus = iota
	WARN
	CRITICAL
)

type CheckUsage

type CheckUsage struct {
	Description string
	Flags       string
}

type DaemonSetStatus added in v0.2.0

type DaemonSetStatus struct {
	BaseCheck
	// contains filtered or unexported fields
}

func (*DaemonSetStatus) Execute added in v0.2.0

func (dh *DaemonSetStatus) Execute() (CheckResult, error)

func (*DaemonSetStatus) Update added in v0.2.0

func (dh *DaemonSetStatus) Update(resource interface{})

func (*DaemonSetStatus) Usage added in v0.2.0

func (dh *DaemonSetStatus) Usage() CheckUsage

type DeploymentStatus

type DeploymentStatus struct {
	BaseCheck
	// contains filtered or unexported fields
}

func (*DeploymentStatus) Execute

func (dh *DeploymentStatus) Execute() (CheckResult, error)

func (*DeploymentStatus) Update

func (dh *DeploymentStatus) Update(resource interface{})

func (*DeploymentStatus) Usage

func (dh *DeploymentStatus) Usage() CheckUsage

type HsHealthCheck

type HsHealthCheck struct {
	BaseCheck
	// contains filtered or unexported fields
}

func (*HsHealthCheck) Execute

func (h *HsHealthCheck) Execute() (CheckResult, error)

func (*HsHealthCheck) Update

func (h *HsHealthCheck) Update(resource interface{})

func (*HsHealthCheck) Usage

func (dh *HsHealthCheck) Usage() CheckUsage

type HsHealthCheckV2 added in v0.2.2

type HsHealthCheckV2 struct {
	BaseCheck
	// contains filtered or unexported fields
}

func (*HsHealthCheckV2) Execute added in v0.2.2

func (h *HsHealthCheckV2) Execute() (CheckResult, error)

func (*HsHealthCheckV2) Update added in v0.2.2

func (h *HsHealthCheckV2) Update(resource interface{})

func (*HsHealthCheckV2) Usage added in v0.2.2

func (dh *HsHealthCheckV2) Usage() CheckUsage

type Http added in v0.2.0

type Http struct {
	BaseCheck
	// contains filtered or unexported fields
}

func (*Http) Execute added in v0.2.0

func (h *Http) Execute() (CheckResult, error)

func (*Http) Update added in v0.2.0

func (h *Http) Update(resource interface{})

func (*Http) Usage added in v0.2.0

func (h *Http) Usage() CheckUsage

Jump to

Keyboard shortcuts

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