models

package
v0.0.0-...-6cfffdc Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Online The service is online
	Online = "ONLINE"
	// Pending The service is potentially offline, and will be marked so after meeting the Config.FailedCheckThreshold
	Pending = "PENDING"
	// Offline The service is offline
	Offline = "OFFLINE"
)

Variables

View Source
var (
	// CurrentServices The currently monitored services
	CurrentServices []Service
)
View Source
var Database *sqlx.DB

Database The sqlite3 database

View Source
var (
	RandomString string
)

Functions

func Connect

func Connect()

Connect Connects to the sqlite3 database, and creates the database if it does not already exist

func GenerateToken

func GenerateToken(name string) (string, error)

生成jwt

func LoadServices

func LoadServices()

LoadServices Loads all the services into CurrentServices and sets defaults

func RandAuthToken

func RandAuthToken() string

func RandString

func RandString(length int64) string

生成长度为length的随机字符串

func RestoreToken

func RestoreToken(authToken string) error

还原jwt

Types

type CheckLog

type CheckLog struct {
	ID      int    `db:"id" json:"id"`
	LogTime string `db:"logtime" json:"logtime"`
	Status  string `db:"status" json:"status"`
}

func (*CheckLog) MarshalJSON2

func (s *CheckLog) MarshalJSON2() ([]byte, error)

type Config

type Config struct {
	Verbose                     bool     `json:"verbose"`
	WebUIHost                   string   `json:"web_ui_host"`
	WebUIPort                   int      `json:"web_ui_port"`
	CheckInterval               int      `json:"check_interval"`
	PendingOfflineCheckInterval int      `json:"pending_offline_check_interval"`
	MaxConcurrentChecks         int      `json:"max_concurrent_checks"`
	ConnectionTimeout           int      `json:"connection_timeout"`
	SuccessfulHTTPStatusCodes   []int    `json:"successful_http_status_codes"`
	IgnoreHTTPSCertErrors       bool     `json:"ignore_https_cert_errors"`
	FailedCheckThreshold        int      `json:"failed_check_threshold"`
	SendEmail                   bool     `json:"send_email"`
	EmailRecipients             []string `json:"email_recipients"`
	SMTPHost                    string   `json:"smtp_host"`
	SMTPPort                    int      `json:"smtp_port"`
	SMTPEmailAddress            string   `json:"smtp_email_address"`
	SMTPUsername                string   `json:"smtp_username"`
	SMTPPassword                string   `json:"smtp_password"`
	SMTPAuth                    bool     `json:"smtp_auth"`
	SendSMS                     bool     `json:"send_sms"`
	SMSRecipients               []string `json:"sms_recipients"`
	TwilioAccountSID            string   `json:"twilio_account_sid"`
	TwilioAuthToken             string   `json:"twilio_auth_token"`
	TwilioPhoneNumber           string   `json:"twilio_phone_number"`
	ConfigPassword              string   `json:"config_password"`
	ArchiveDay                  int      `json:"archive_day"`
	UserName                    string   `json:"user_name"`
	UserPassword                string   `json:"user_password"`
}

Config The application configuration and settings

var (
	// CurrentConfig The current configuration
	CurrentConfig Config
)

func ParseConfigFile

func ParseConfigFile() Config

ParseConfigFile Parses the config.json file

type Service

type Service struct {
	ID            int           `db:"id" json:"id"`
	Name          string        `db:"name" json:"name"`
	Protocol      string        `db:"protocol" json:"protocol"`
	Host          string        `db:"host" json:"host"`
	Port          jsonNullInt64 `db:"port" json:"port"`
	Grp           string        `db:"grp" json:"grp"`
	Emails        string        `db:"emails" json:"emails"`
	UptimeStart   int64         `json:"uptime_start"`
	Status        string        `json:"status"`
	FailureCount  int           `json:"failure_count"`
	FailtimeStart int64         `json:"failtime_start"`
	Enabled       int           `json:"enabled"`
}

Service Represents a service that is being monitored

func (*Service) CheckService

func (service *Service) CheckService() bool

CheckService Checks whether a service is online or offline

func (*Service) MarshalJSON2

func (s *Service) MarshalJSON2() ([]byte, error)

Jump to

Keyboard shortcuts

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