models

package
v0.0.0-...-1f575cd Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSuccess Status = "success"
	StatusError   Status = "error"
	StatusUnknown Status = "unknown"

	NetworkInternal Network = "internal"
	NetworkPublic   Network = "public"

	CheckTCP  CheckType = "TCP"
	CheckUDP  CheckType = "UDP"
	CheckICMP CheckType = "ICMP"
	CheckHTTP CheckType = "HTTP"
)

Variables

This section is empty.

Functions

func UpdateCurrentHost

func UpdateCurrentHost(db *badger.DB, conf *config.Config, init bool) error

Types

type Check

type Check struct {
	ID                string        `json:"id"`
	HostID            string        `json:"hostId"`
	Status            Status        `json:"status"`
	ResponseTime      time.Duration `json:"responseTime"`
	StatusCode        int           `json:"statusCode"`
	ResponseBody      string        `json:"responseBody"`
	CheckErrorMessage string        `json:"checkErrorMessage"`
	Network           Network       `json:"network"`
	CheckType         CheckType     `json:"checkType"`
	CheckedAt         time.Time     `json:"checkedAt"`
}

type CheckNetworkUptime

type CheckNetworkUptime struct {
	Percent      float64           `json:"percent"`
	TotalSuccess uint64            `json:"totalSuccess"`
	TotalChecks  uint64            `json:"totalChecks"`
	HTTP         CheckUptimeByType `json:"http"`
	TCP          CheckUptimeByType `json:"tcp"`
	UDP          CheckUptimeByType `json:"udp"`
	ICMP         CheckUptimeByType `json:"icmp"`
}

type CheckType

type CheckType string

type CheckTypes

type CheckTypes struct {
	HTTP []Check `json:"http"`
	TCP  []Check `json:"tcp"`
	UDP  []Check `json:"udp"`
	ICMP []Check `json:"icmp"`
}

type CheckUptime

type CheckUptime struct {
	Percent      float64            `json:"percent"`
	TotalSuccess uint64             `json:"totalSuccess"`
	TotalChecks  uint64             `json:"totalChecks"`
	Internal     CheckNetworkUptime `json:"internal"`
	Public       CheckNetworkUptime `json:"public"`
}

type CheckUptimeByType

type CheckUptimeByType struct {
	Percent      float64 `json:"percent"`
	TotalSuccess uint64  `json:"totalSuccess"`
	TotalChecks  uint64  `json:"totalChecks"`
}

type Host

type Host struct {
	ID                string         `json:"id" badgerhold:"key"`
	CurrentHost       bool           `json:"-"`
	Hostname          string         `json:"hostname" badgerhold:"unique"`
	ServiceRestarts   int            `json:"serviceRestarts,omitempty"`
	ServiceFirstStart time.Time      `json:"serviceFirstStart"`
	ServiceLastStart  time.Time      `json:"serviceLastStart"`
	InternalIP        string         `json:"internalIp" badgerhold:"unique"`
	PublicIP          string         `json:"publicIp" badgerhold:"unique"`
	DiscoveredIP      string         `json:"-"`
	ServiceUptime     time.Duration  `json:"serviceUptime,omitempty"`
	HostUptime        time.Duration  `json:"hostUptime,omitempty"`
	FirstSeenAt       time.Time      `json:"firstSeenAt"`
	LastSeenAt        time.Time      `json:"lastSeenAt" badgerhold:"index"`
	LatestChecks      *ServiceChecks `json:"latestChecks,omitempty"`
	Checks            *ServiceChecks `json:"checks,omitempty"`
	CheckUptime       *CheckUptime   `json:"checkUptime"`
	CityCode          string         `json:"cityCode,omitempty"`
	Longitude         string         `json:"longitude,omitempty"`
	Latitude          string         `json:"latitude,omitempty"`
}

func GetCurrentHost

func GetCurrentHost(db *badger.DB) (*Host, error)

func GetHostByHostname

func GetHostByHostname(db *badger.DB, hostname string) (*Host, error)

func GetHostByID

func GetHostByID(db *badger.DB, id string) (*Host, error)

func GetHostByIP

func GetHostByIP(db *badger.DB, ip string) (*Host, error)

func GetHosts

func GetHosts(db *badger.DB) ([]Host, error)

func GetHostsWithStatuses

func GetHostsWithStatuses(db *badger.DB) ([]Host, error)

func (*Host) AddCheck

func (h *Host) AddCheck(db *badger.DB, check *Check) error

func (*Host) Save

func (h *Host) Save(db *badger.DB) error

type Network

type Network string

type ServiceChecks

type ServiceChecks struct {
	Internal CheckTypes `json:"internal"`
	Public   CheckTypes `json:"public"`
}

type Status

type Status string

type Uptime

type Uptime interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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