domain

package
v0.0.0-...-466d66e Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	HEALTHCHECK_STATUS_SUCCESS = "success"
	HEALTHCHECK_STATUS_WARNING = "warning"
	HEALTHCHECK_STATUS_ERROR   = "error"
	HEALTHCHECK_STATUS_TIMEOUT = "timeout"

	HEALTHCHECK_TYPE_PING   = "ping"
	HEALTHCHECK_TYPE_RANGE  = "range"
	HEALTHCHECK_TYPE_MANUAL = "manual"
)
View Source
const (
	NOTIFIER_PLUGIN_CLI_NAME = "cli"
)
View Source
const (
	NOTIFIER_PLUGIN_HTTP_GET_NAME = "httpget"
)
View Source
const (
	NOTIFIER_PLUGIN_PUSHBULLET_NAME = "pushbullet"
)
View Source
const (
	NOTIFIER_PLUGIN_SENDGRID_NAME = "sendgrid"
)
View Source
const (
	NOTIFIER_PLUGIN_SLACK_WEBHOOK_NAME = "slackwebhook"
)

Variables

View Source
var (
	Plugins []INotifierPlugin
)

Functions

func MailCreateBody

func MailCreateBody(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) string

func MailCreateSubject

func MailCreateSubject(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) string

func NotifierManagerAddPlugin

func NotifierManagerAddPlugin(plugin INotifierPlugin)

func NotifierManagerClearPlugins

func NotifierManagerClearPlugins()

func NotifierManagerProcess

func NotifierManagerProcess(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) error

func PushCreateMessage

func PushCreateMessage(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) string

func PushCreateTitle

func PushCreateTitle(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) string

func SlackCreateAttachment

func SlackCreateAttachment(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) *slack.Attachment

func SlackCreateMessage

func SlackCreateMessage(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier) string

Types

type Configuration

type Configuration struct {
	Server       *ConfigurationServer `json:"server"`
	Healthchecks []*Healthcheck       `json:"healthchecks"`
	Notifiers    []*Notifier          `json:"notifiers"`
}

func NewConfigurationFromFile

func NewConfigurationFromFile(file string) (*Configuration, error)

type ConfigurationServer

type ConfigurationServer struct {
	Host     string `json:"host"`
	WarmTime int64  `json:"warmTime"`
}

type Healthcheck

type Healthcheck struct {
	Token            string                 `json:"token"`
	Description      string                 `json:"description"`
	LastUpdateAt     int64                  `json:"lastUpdateAt"`
	Ping             int64                  `json:"ping"`
	Range            float64                `json:"range"`
	Ranges           []float64              `json:"ranges"`
	Status           string                 `json:"status"`
	Type             string                 `json:"type"`
	Timeout          int64                  `json:"timeout"`
	WarningNotifiers []*HealthcheckNotifier `json:"warningNotifiers"`
	ErrorNotifiers   []*HealthcheckNotifier `json:"errorNotifiers"`
	TimeoutNotifiers []*HealthcheckNotifier `json:"timeoutNotifiers"`
}

func (*Healthcheck) GetCurrentTimeInMS

func (This *Healthcheck) GetCurrentTimeInMS() int64

func (*Healthcheck) InErrorRange

func (This *Healthcheck) InErrorRange(value float64) bool

func (*Healthcheck) InSuccessRange

func (This *Healthcheck) InSuccessRange(value float64) bool

func (*Healthcheck) InWarningRange

func (This *Healthcheck) InWarningRange(value float64) bool

func (*Healthcheck) NotifyErrorStatus

func (This *Healthcheck) NotifyErrorStatus()

func (*Healthcheck) NotifyTimeoutStatus

func (This *Healthcheck) NotifyTimeoutStatus()

func (*Healthcheck) NotifyWarningStatus

func (This *Healthcheck) NotifyWarningStatus()

func (*Healthcheck) Run

func (This *Healthcheck) Run()

func (*Healthcheck) SetLastUpdateAtCurrentTime

func (This *Healthcheck) SetLastUpdateAtCurrentTime()

func (*Healthcheck) SetStatusError

func (This *Healthcheck) SetStatusError()

func (*Healthcheck) SetStatusSuccess

func (This *Healthcheck) SetStatusSuccess()

func (*Healthcheck) SetStatusTimeout

func (This *Healthcheck) SetStatusTimeout()

func (*Healthcheck) SetStatusWarning

func (This *Healthcheck) SetStatusWarning()

func (*Healthcheck) UpdateLastPingData

func (This *Healthcheck) UpdateLastPingData()

func (*Healthcheck) UpdateLastRangeData

func (This *Healthcheck) UpdateLastRangeData(newRange float64)

func (*Healthcheck) UpdatePing

func (This *Healthcheck) UpdatePing()

func (*Healthcheck) UpdateTimeoutData

func (This *Healthcheck) UpdateTimeoutData()

type HealthcheckNotifier

type HealthcheckNotifier struct {
	ID                 string                 `json:"id"`
	Interval           int64                  `json:"interval" default:"86400"`
	LastNotificationAt int64                  `json:"lastNotificationAt"`
	Params             map[string]interface{} `json:"params"`
}

func (*HealthcheckNotifier) CanSendNotification

func (This *HealthcheckNotifier) CanSendNotification() bool

func (*HealthcheckNotifier) GetCurrentTimeInMS

func (This *HealthcheckNotifier) GetCurrentTimeInMS() int64

type INotifierPlugin

type INotifierPlugin interface {
	Notify(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier)
	GetId() string
	GetName() string
}

type Notifier

type Notifier struct {
	ID     string                 `json:"id"`
	Plugin string                 `json:"plugin"`
	Params map[string]interface{} `json:"params"`
}

type NotifierPluginCLI

type NotifierPluginCLI struct {
	Params map[string]interface{}
	ID     string
}

func (*NotifierPluginCLI) GetId

func (This *NotifierPluginCLI) GetId() string

func (*NotifierPluginCLI) GetName

func (This *NotifierPluginCLI) GetName() string

func (*NotifierPluginCLI) Notify

func (This *NotifierPluginCLI) Notify(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier)

type NotifierPluginHttpGet

type NotifierPluginHttpGet struct {
	Params map[string]interface{}
	ID     string
}

func (*NotifierPluginHttpGet) ExecuteHttpGet

func (This *NotifierPluginHttpGet) ExecuteHttpGet(url string) (string, error)

func (*NotifierPluginHttpGet) GetId

func (This *NotifierPluginHttpGet) GetId() string

func (*NotifierPluginHttpGet) GetName

func (This *NotifierPluginHttpGet) GetName() string

func (*NotifierPluginHttpGet) Notify

func (This *NotifierPluginHttpGet) Notify(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier)

type NotifierPluginPushBullet

type NotifierPluginPushBullet struct {
	Params map[string]interface{}
	ID     string
}

func (*NotifierPluginPushBullet) GetId

func (This *NotifierPluginPushBullet) GetId() string

func (*NotifierPluginPushBullet) GetName

func (This *NotifierPluginPushBullet) GetName() string

func (*NotifierPluginPushBullet) Notify

func (This *NotifierPluginPushBullet) Notify(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier)

func (*NotifierPluginPushBullet) SendPush

func (This *NotifierPluginPushBullet) SendPush(pbAccessToken string, pbDeviceIden string, pbEmail string, pbChannelTag string, pbClientIden string, pushTitle string, pushBody string) error

type NotifierPluginSendGrid

type NotifierPluginSendGrid struct {
	Params map[string]interface{}
	ID     string
}

func (*NotifierPluginSendGrid) GetId

func (This *NotifierPluginSendGrid) GetId() string

func (*NotifierPluginSendGrid) GetName

func (This *NotifierPluginSendGrid) GetName() string

func (*NotifierPluginSendGrid) Notify

func (This *NotifierPluginSendGrid) Notify(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier)

func (*NotifierPluginSendGrid) SendEmail

func (This *NotifierPluginSendGrid) SendEmail(mailSubject string, mailBody string, mailFromEmail string, mailFromName string, mailToList []string, sendGridKey string) error

type NotifierPluginSlackWebHook

type NotifierPluginSlackWebHook struct {
	Params map[string]interface{}
	ID     string
}

func (*NotifierPluginSlackWebHook) GetId

func (This *NotifierPluginSlackWebHook) GetId() string

func (*NotifierPluginSlackWebHook) GetName

func (This *NotifierPluginSlackWebHook) GetName() string

func (*NotifierPluginSlackWebHook) Notify

func (This *NotifierPluginSlackWebHook) Notify(healthcheck Healthcheck, healthcheckNotifier HealthcheckNotifier)

func (*NotifierPluginSlackWebHook) SendSlack

func (This *NotifierPluginSlackWebHook) SendSlack(webHookURL string, channel string, messageBody string, messageAttachement *slack.Attachment) error

Jump to

Keyboard shortcuts

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