uptime

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Uptime is a small, lightweight service that tracks the status of Rotational services and watches for outages. This package is intended to be a stand-alone service and has limited tests since it is not a mission critical application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateEqual

func DateEqual(date1, date2 time.Time) bool

Types

type CSSColor

type CSSColor string
const (
	CSSPrimary   CSSColor = "primary"
	CSSSecondary CSSColor = "secondary"
	CSSSuccess   CSSColor = "success"
	CSSDanger    CSSColor = "danger"
	CSSWarning   CSSColor = "warning"
	CSSInfo      CSSColor = "info"
	CSSLight     CSSColor = "light"
	CSSDark      CSSColor = "dark"
)

func ColorFromStatus

func ColorFromStatus(s health.Status) CSSColor

type CSSIcon

type CSSIcon string
const (
	CSSUnknown     CSSIcon = "circle-question"
	CSSOnline      CSSIcon = "circle-check"
	CSSDegraded    CSSIcon = "battery-quarter"
	CSSPartial     CSSIcon = "triangle-exclamation"
	CSSOutage      CSSIcon = "skull-crossbones"
	CSSMaintenance CSSIcon = "wrench"
)

func IconFromStatus

func IconFromStatus(s health.Status) CSSIcon

type IncidentContext

type IncidentContext struct {
	Description string
	StartTime   time.Time
	EndTime     time.Time
	StatusColor CSSColor
	StatusIcon  CSSIcon
}

func (IncidentContext) TimeFormat

func (i IncidentContext) TimeFormat() string

type IncidentDayContext

type IncidentDayContext struct {
	Date      time.Time
	Incidents []IncidentContext
}

type Monitor

type Monitor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Monitor wraps several service monitors to routinely conduct health checks and save the status (if changed) to the database.

func NewMonitor

func NewMonitor(interval time.Duration, infoPath string) (mon *Monitor, err error)

NewMonitor loads the services definition from the path on disk and creates monitors for each of them to perform heartbeat checks on the specified interval.

func (*Monitor) CheckStatus

func (m *Monitor) CheckStatus(monitor health.Monitor, service *services.Service) (err error)

Check status executes the service status for the specified monitor, saves the status to disk if it has changed and creates any incidents if required. It then updates the service pointer to save the current status after all monitor checks have happened.

func (*Monitor) Run

func (m *Monitor) Run(stop <-chan signal, done chan<- signal)

The background routine that executes every interval; it has self contained signaling.

func (*Monitor) RunChecks

func (m *Monitor) RunChecks() error

func (*Monitor) Start

func (m *Monitor) Start()

Start the monitor background routine.

func (*Monitor) Stop

func (m *Monitor) Stop(ctx context.Context) error

Stop the monitor background routine (blocks until shutdown is complete).

type Server

type Server struct {
	service.Server
	// contains filtered or unexported fields
}

func New

func New(conf config.Config) (s *Server, err error)

func (*Server) Index

func (s *Server) Index(c *gin.Context)

func (*Server) NotAllowed

func (s *Server) NotAllowed(c *gin.Context)

func (*Server) NotFound

func (s *Server) NotFound(c *gin.Context)

func (*Server) Routes

func (s *Server) Routes(router *gin.Engine) (err error)

Setup the server's middleware and routes.

func (*Server) Setup

func (s *Server) Setup() (err error)

Setup the server before the routes are configured.

func (*Server) Started

func (s *Server) Started() (err error)

Called when the server has been started and is ready.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) (err error)

Cleanup when the server is being shutdown. Note that in tests you should call Shutdown() to ensure the server is gracefully closed and not this method.

type ServiceGroupContext

type ServiceGroupContext struct {
	Title         string
	ServiceStates []ServiceStateContext
}

type ServiceStateContext

type ServiceStateContext struct {
	Title       string
	StatusColor CSSColor
	StatusIcon  CSSIcon
}

type StatusPageContext

type StatusPageContext struct {
	StatusMessage   string
	StatusColor     CSSColor
	ServiceGroups   []ServiceGroupContext
	IncidentHistory []IncidentDayContext
}

StatusPageContext is used to render the content into the index page for the uptime HTML status page (info page). Note that the template uses Bootstrap CSS classes for status colors and other properties, which is enforced using the CSSColor type.

Directories

Path Synopsis
Package health implements health check clients to return server system statuses.
Package health implements health check clients to return server system statuses.
Package services provides an Info and Service data structure that is used for two purposes: loading configuration information from disk and storing status information in the database.
Package services provides an Info and Service data structure that is used for two purposes: loading configuration information from disk and storing status information in the database.

Jump to

Keyboard shortcuts

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