happening

package module
v0.0.0-...-8ecc069 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 34 Imported by: 1

Documentation

Index

Constants

View Source
const DROP_DATABASE = false

Variables

View Source
var NullWriter = null{}

Functions

func EventToJSON

func EventToJSON(event *Event) []byte

func GenerateUUIDv4

func GenerateUUIDv4() string

func JwtAuth

func JwtAuth(config ServerConfig) middleware.JWTConfig

func JwtLoginWithConfig

func JwtLoginWithConfig(config ServerConfig) func(echo.Context) error

func PackrHandler

func PackrHandler(config ServerConfig) echo.HandlerFunc

func Ping

func Ping(config *Config)

func SendEvent

func SendEvent(event *Event, config *Config)

Types

type API

type API struct {
	POSTGRES_URL  string
	DB            *gorm.DB
	NOTIFIER      Notifier
	SERVER_CONFIG ServerConfig
}

func (*API) DeleteCheckHandler

func (api *API) DeleteCheckHandler(c echo.Context) error

func (*API) GetCheckByNameInContextHandler

func (api *API) GetCheckByNameInContextHandler(c echo.Context) error

func (*API) GetCheckHandler

func (api *API) GetCheckHandler(c echo.Context) error

func (*API) GetChecksHandler

func (api *API) GetChecksHandler(c echo.Context) error

GetChecksHandler handles listing of checks

func (*API) GetEventHandler

func (api *API) GetEventHandler(c echo.Context) error

func (*API) GetEventsHandler

func (api *API) GetEventsHandler(c echo.Context) error

GetEventsHandler handles listing of events

func (*API) PatchCheckHandler

func (api *API) PatchCheckHandler(c echo.Context) error

func (*API) PatchMailEventHandler

func (api *API) PatchMailEventHandler(c echo.Context) error

func (*API) PatchResetCheckHandler

func (api *API) PatchResetCheckHandler(c echo.Context) error

func (*API) PostCheckHandler

func (api *API) PostCheckHandler(c echo.Context) error

func (*API) PostEventHandler

func (api *API) PostEventHandler(c echo.Context) error

PostEventHandler handles the posting of new events

func (*API) PrepareDatabase

func (api *API) PrepareDatabase()

func (*API) SetupCronJobs

func (api *API) SetupCronJobs()

type AuthPair

type AuthPair struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type Check

type Check struct {
	Id              *string       `json:"id,omitempty" gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	Context         string        `json:"context" gorm:"not null;index:,unique,composite:idx_context_name;default:'default'"`
	Name            string        `json:"name" validate:"required" gorm:"type:text;index:,unique,composite:idx_context_name;not null"`
	Period          time.Duration `json:"period" gorm:"type:bigint;not null;default:3600000000000"`
	LastPingAt      time.Time     `json:"last_ping_at" gorm:"type:timestamptz;index;not null;default:now()::timestamptz"`
	LastEventId     *string       `json:"last_event_id,omitempty" gorm:"type:uuid;default:null"`
	Success         bool          `json:"success"`
	Healthy         bool          `json:"healthy" gorm:"type:boolean;not_null;default:true"`
	Disabled        bool          `json:"disabled" gorm:"type:boolean;not_null;default:false"`
	Failures        int           `json:"failures" gorm:"type:int;not null;default:0"`
	AllowedFailures int           `json:"allowed_failures" gorm:"type:int;not null;default:0"`
}

func (*Check) Init

func (check *Check) Init()

func (Check) State

func (check Check) State() string

func (Check) String

func (check Check) String() string

type CheckNotifierMail

type CheckNotifierMail struct {
	Check               Check
	EnvironmentVariable string
	DrilldownURL        string
	Resolved            bool
}

func (CheckNotifierMail) Subject

func (mail CheckNotifierMail) Subject() string

func (CheckNotifierMail) Text

func (mail CheckNotifierMail) Text() string

type Config

type Config struct {
	Name           string `default:"SomeEvent"`
	Context        string `default:"default" envconfig:"CONTEXT"`
	ReportURL      string `envconfig:"HAPPENING_REPORT_URL"`
	SuccessCode    string `default:"0"`
	PingURL        string
	Hostname       string
	User           string        `envconfig:"USER"`
	Retries        uint          `default:"3"`
	RetryDelay     time.Duration `default:"1s"`
	CollectOutput  bool
	SuppressOutput bool
	Chdir          string
	StoreReport    bool `default:"true"`
	Started        string
	Duration       time.Duration
	Output         string
}

func NewConfig

func NewConfig() *Config

type Event

type Event struct {
	Id          string         `json:"id" validate:"required,uuid" gorm:"type:uuid;primary_key"`
	Context     string         `json:"context" gorm:"not null;index;default:'default'"`
	Name        string         `json:"name" validate:"required,printascii" gorm:"not null;text"`
	Command     pq.StringArray `json:"command,omitempty" gorm:"type:text[]"`
	Output      string         `json:"output,omitempty" gorm:"type:text"`
	Started     time.Time      `json:"started" validate:"required" gorm:"type:timestamptz;index"`
	Duration    time.Duration  `json:"duration" gorm:"type:bigint"`
	Success     bool           `json:"success" gorm:"type:bool;not null"`
	ExitCode    int            `json:"exitCode" gorm:"type:smallint;not null"`
	Signal      string         `json:"signal,omitempty" gorm:"text"`
	Hostname    string         `json:"hostname" gorm:"type:text"`
	User        string         `json:"user", gorm:"type:text"`
	Pid         int            `json:"pid" gorm:"type:int"`
	Load        float32        `json:"load" gorm:"type:real"`
	CpuUsage    float64        `json:"cpuUsage" gorm:"type:real"`
	MemoryUsage float64        `json:"memoryUsage" gorm:"type:real"`
	Store       bool           `json:"store" gorm:"-"`
}

func Execute

func Execute(config Config, block func(output io.Writer) bool) *Event

func ExecuteCmd

func ExecuteCmd(config Config, cmdArgs []string) *Event

func (Event) Result

func (event Event) Result() string

func (Event) String

func (event Event) String() string

type EventNotifierMail

type EventNotifierMail struct {
	Event               Event
	EnvironmentVariable string
	DrilldownURL        string
}

func (EventNotifierMail) Subject

func (mail EventNotifierMail) Subject() string

func (EventNotifierMail) Text

func (mail EventNotifierMail) Text() string

type LoadTicker

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

func (*LoadTicker) Compute

func (lt *LoadTicker) Compute() float32

func (*LoadTicker) Start

func (lt *LoadTicker) Start()

type MailCommandNotifier

type MailCommandNotifier struct {
	EnvironmentVariable string
	DrilldownURL        string
	MailCommand         string
	ContactName         string
	ContactEmail        string
}

func (*MailCommandNotifier) Alert

func (notifier *MailCommandNotifier) Alert(check Check)

func (*MailCommandNotifier) Mail

func (notifier *MailCommandNotifier) Mail(event Event)

func (*MailCommandNotifier) Resolve

func (notifier *MailCommandNotifier) Resolve(check Check)

type Notifier

type Notifier interface {
	Alert(check Check)
	Resolve(check Check)
	Mail(event Event)
}

func NewMailCommandNotifier

func NewMailCommandNotifier(config ServerConfig) Notifier

func NewNotifier

func NewNotifier(config ServerConfig) Notifier

func NewNullNotifier

func NewNullNotifier() Notifier

func NewSMTPNotifier

func NewSMTPNotifier(config ServerConfig) Notifier

func NewSendgridNotifier

func NewSendgridNotifier(config ServerConfig) Notifier

type NotifierMail

type NotifierMail interface {
	Subject() string
	Text() string
}

type NullNotifier

type NullNotifier struct {
}

func (*NullNotifier) Alert

func (notifier *NullNotifier) Alert(check Check)

func (*NullNotifier) Mail

func (notifier *NullNotifier) Mail(event Event)

func (*NullNotifier) Resolve

func (notifier *NullNotifier) Resolve(check Check)

type SMTPNotifier

type SMTPNotifier struct {
	EnvironmentVariable string
	DrilldownURL        string
	SMTPServerURL       string
	NoReplyName         string
	NoReplyEmail        string
	ContactName         string
	ContactEmail        string
	SkipSSLVerify       bool
}

func (*SMTPNotifier) Alert

func (notifier *SMTPNotifier) Alert(check Check)

func (*SMTPNotifier) Mail

func (notifier *SMTPNotifier) Mail(event Event)

func (*SMTPNotifier) Resolve

func (notifier *SMTPNotifier) Resolve(check Check)

type SendGridNotifier

type SendGridNotifier struct {
	EnvironmentVariable string
	DrilldownURL        string
	SendgridApiKey      string
	NoReplyName         string
	NoReplyEmail        string
	ContactName         string
	ContactEmail        string
}

func (*SendGridNotifier) Alert

func (notifier *SendGridNotifier) Alert(check Check)

func (*SendGridNotifier) Mail

func (notifier *SendGridNotifier) Mail(event Event)

func (*SendGridNotifier) Resolve

func (notifier *SendGridNotifier) Resolve(check Check)

type ServerConfig

type ServerConfig struct {
	PORT                          string `default:"8080"`
	POSTGRES_URL                  string `default:"postgresql://flori@localhost:5432/happening?sslmode=disable"`
	HAPPENING_SERVER_URL          string `default:"http://localhost:8080"`
	HTTP_AUTH                     string
	SIGNING_SECRET                string
	WEBUI_DIR                     string `default:"/webui"`
	NOTIFIER_KIND                 string
	NOTIFIER_ENVIRONMENT_VARIABLE string `default:"RAILS_ENV"`
	NOTIFIER_NO_REPLY_NAME        string `default:"Happening"`
	NOTIFIER_NO_REPLY_EMAIL       string `default:"no-reply@localhost"`
	NOTIFIER_CONTACT_NAME         string `default:"Root"`
	NOTIFIER_CONTACT_EMAIL        string `default:"root@localhost"`
	NOTIFIER_SENDGRID_API_KEY     string
	NOTIFIER_MAIL_COMMAND         string `default:"mail"`
	NOTIFIER_SMTP_SERVER_URL      string `default:"smtp://username:password@localhost:25?sslVerify=disable"`
	RETENTION_DAYS                string `default:"180"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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