site

package
v0.0.0-...-fd533df Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseOutPreviousOutages

func CloseOutPreviousOutages(dbConn *storage.Connection) error

CloseOutPreviousOutages - run this to set any lingering outages to be closed

func GetDeletedSites

func GetDeletedSites(dbConn *storage.Connection) map[int]Website

GetDeletedSites - get all the sites out of the storage connection

func GetSites

func GetSites(dbConn *storage.Connection) map[int]Website

GetSites - get all the sites out of the storage connection

Types

type CertificateInfo

type CertificateInfo struct {
	Valid   bool      `json:"valid"`
	Expires time.Time `json:"expires"`
	Info    string    `json:"error"`
	Names   []string  `json:"names"`
}

type Outage

type Outage struct {
	Start    time.Time `json:"start"`
	End      time.Time `json:"end"`
	Duration float64   `json:"duration"`
}

Outage - a specific instance of a site going down

type Website

type Website struct {
	IsUp bool

	DB     *storage.Connection
	Logger *logrus.Logger

	ID int

	URL string
	// contains filtered or unexported fields
}

Website - a site that we will be checking

func Create

func Create(address string, dbConn *storage.Connection, logger *logrus.Logger, client *http.Client, timeout int) Website

Create - Make a new instance of a Website

func FindWebsiteByID

func FindWebsiteByID(id int, dbConn *storage.Connection, logger *logrus.Logger) (Website, error)

FindWebsiteByID - Find a site in the DB by it's ID

func FindWebsiteByURL

func FindWebsiteByURL(url string, dbConn *storage.Connection, logger *logrus.Logger) (Website, error)

FindWebsiteByURL - Find a site in the DB by it's URL

func (*Website) CalcUptime

func (s *Website) CalcUptime(days int, dbConn *storage.Connection) float64

CalcUptime - Calculate the percentage of uptime over the last X days

func (*Website) Destroy

func (s *Website) Destroy(c *chan string, dbConn *storage.Connection, logger *logrus.Logger)

Destroy - delete a site from the DB and close down the monitoring routine

func (*Website) GetAddressWithoutProtocol

func (s *Website) GetAddressWithoutProtocol() string

func (*Website) GetCertificateInfo

func (s *Website) GetCertificateInfo() (CertificateInfo, error)

func (*Website) GetDomain

func (s *Website) GetDomain() string

func (*Website) GetDomainInfo

func (s *Website) GetDomainInfo() (WhoisInfo, error)

func (*Website) GetSiteID

func (s *Website) GetSiteID(dbConn *storage.Connection) int

GetSiteID - the the ID of the current website by it's URL

func (*Website) Monitor

func (s *Website) Monitor(shutdownChan *chan string)

Monitor - periodically make an HTTP GET request to the site's URL, and optionally log it in the database

func (*Website) Outages

func (s *Website) Outages(dbConn *storage.Connection) []Outage

Outages - return all the outages for a given site

func (*Website) Purge

func (s *Website) Purge(dbConn *storage.Connection, logger *logrus.Logger)

Purge - delete a site from the DB and close down the monitoring routine

func (*Website) Restore

func (s *Website) Restore(dbConn *storage.Connection, logger *logrus.Logger)

Restore - restore a site from the DB and close down the monitoring routine

type WhoisInfo

type WhoisInfo struct {
	Status          []string `json:"status"`
	RegisteredDate  string   `json:"registered"`
	ExpiresDate     string   `json:"expires"`
	RegisteredName  string   `json:"registrant"`
	RegisteredEmail string   `json:"registrantEmail"`
	RegisteredAt    string   `json:"registrar"`
	Error           string   `json:"error"`
}

Jump to

Keyboard shortcuts

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