models

package
v0.0.0-...-16cdc5c Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Greater  = ">"
	Less     = "<"
	Equal    = "=="
	NotEqual = "!="

	GraphiteServiceCheckCommand = "check_graphite_metric"
)
View Source
const (
	HTTPServiceCheckCommand = "check_http"
	HTTPServiceTypeSimple   = 0
	HTTPServiceTypeAdvanced = 1
)
View Source
const TCPServiceCheckCommand = "check_tcp"

Variables

View Source
var (
	ErrorDuplicatedName = errors.New("The name is duplicated")
)

Functions

func AddAdmin

func AddAdmin(alertID, adminID int) error

func AddNotifier

func AddNotifier(alertID, notifierID int) error

func AddUserIfNotExists

func AddUserIfNotExists(name string) error

func DeleteAdmin

func DeleteAdmin(alertID, adminID int) error

func DeleteAlert

func DeleteAlert(alertID int) error

func DeleteGraphiteService

func DeleteGraphiteService(serviceID, alertID int) error

func DeleteHTTPService

func DeleteHTTPService(serviceID, alertID int) error

func DeleteNotifier

func DeleteNotifier(alertID, notifierID int) error

func DeleteTCPService

func DeleteTCPService(serviceID, alertID int) error

func DeleteTemplate

func DeleteTemplate(templateID, alertID int) error

func GetAdminsByAlertID

func GetAdminsByAlertID(id int, admins *[]User) error

func GetAlert

func GetAlert(alert *Alert, id int) error

func GetAllAlerts

func GetAllAlerts(alerts *[]Alert) error

func GetAllGraphiteServicesByAlertID

func GetAllGraphiteServicesByAlertID(alertID int, services *[]GraphiteService) error

func GetAllHTTPServicesByAlertID

func GetAllHTTPServicesByAlertID(alertID int, services *[]HTTPService) error

func GetAllTCPServicesByAlertID

func GetAllTCPServicesByAlertID(alertID int, services *[]TCPService) error

func GetAllTemplatesByAlertID

func GetAllTemplatesByAlertID(alertID int, templates *[]Template) error

func GetAllUsers

func GetAllUsers(users *[]User, namePattern string) error

func GetAllUsersDetails

func GetAllUsersDetails(users *[]User, namePattern string) error

func GetDetailedAlert

func GetDetailedAlert(alert *Alert, id int) error

func GetGraphiteService

func GetGraphiteService(serviceID int, service *GraphiteService) error

func GetHTTPService

func GetHTTPService(serviceID int, service *HTTPService) error

func GetNotifiersByAlertID

func GetNotifiersByAlertID(id int, notifiers *[]User) error

func GetTCPService

func GetTCPService(serviceID int, service *TCPService) error

func GetTemplate

func GetTemplate(templateID int, template *Template) error

func GetUser

func GetUser(userName string, user *User) error

func IsSuperUser

func IsSuperUser(userID int) (bool, error)

func SaveAlert

func SaveAlert(alert *Alert) error

func SaveGraphiteService

func SaveGraphiteService(service *GraphiteService) error

func SaveHTTPService

func SaveHTTPService(service *HTTPService) error

func SaveTCPService

func SaveTCPService(service *TCPService) error

func SaveTemplate

func SaveTemplate(template *Template) error

func SynchronizeAlert

func SynchronizeAlert(id int) error

func TestHTTPService

func TestHTTPService(service *HTTPService) (string, error)

func UpdateUser

func UpdateUser(user *User) error

Types

type Alert

type Alert struct {
	ID               int               `gorm:"primary_key" form:"-"`
	Name             string            `gorm:"type:varchar(64);not null;unique" form:"name"`
	Enabled          bool              `gorm:"not null" form:"enabled"`
	GraphiteServices []GraphiteService `gorm:"ForeignKey:AlertID" form:"-"`
	TCPServices      []TCPService      `gorm:"ForeignKey:AlertID" form:"-"`
	HTTPServices     []HTTPService     `gorm:"ForeignKey:AlertID" form:"-"`
	Templates        []Template        `gorm:"ForeignKey:AlertID" form:"-"`
	Notifiers        []User            `gorm:"many2many:alert_to_user_notify" form:"-"`
	Admins           []User            `gorm:"many2many:alert_to_user_admin" form:"-"`

	CreatedAt time.Time `form:"-"`
}

type CheckHTTPCmdParams

type CheckHTTPCmdParams struct {
	HostName      string   `short:"H" long:"hostname"`
	IPAddress     string   `short:"I" long:"IP-Address"`
	Port          string   `short:"p" long:"port"`
	UseIPv4       bool     `short:"4"`
	UseIPv6       bool     `short:"6"`
	SSlVersion    string   `short:"S" long:"ssl"`
	SSlEnable     bool     `long:"sni"`
	Certificate   string   `short:"C" long:"certificate"`
	Expect        string   `short:"e" long:"expect"`
	HeaderExpect  string   `short:"d" long:"header-string"`
	ContentExpect string   `short:"s" long:"string"`
	URI           string   `short:"u" long:"uri"`
	PostData      string   `short:"P" long:"post"`
	Method        string   `short:"j" long:"method"`
	IgnoreBody    bool     `short:"N" long:"no-body"`
	MaxAge        string   `short:"M" long:"max-age"`
	ContentType   string   `short:"T" long:"content-type"`
	LineSpan      bool     `short:"l" long:"linespan"`
	Regex         string   `short:"r" long:"regex" long:"ereg"`
	RegexCaseIns  string   `short:"R" long:"eregi"`
	InvertRegex   bool     `long:"invert-regex"`
	BasicAuth     string   `short:"a" long:"authorization"`
	ProxyAuth     string   `short:"b" long:"proxy-authorization"`
	UserAgent     string   `short:"A" long:"useragent"`
	Header        []string `short:"k" long:"header"`
	WrapLink      bool     `short:"L" long:"link"`
	OnRedirect    string   `short:"f" long:"onredirect"`
	MinPageSize   string   `short:"m" long:"pagesize"`
}

type GraphiteService

type GraphiteService struct {
	ID            int    `gorm:"primary_key" form:"-"`
	AlertID       int    `gorm:"not null" form:"-"`
	Name          string `gorm:"type:varchar(64);not null" form:"name"`
	Metric        string `gorm:"type:varchar(1024);not null" form:"metric"`
	CheckAttempts int    `gorm:"not null; default 3" form:"check_attempts"`
	Warning       string `gorm:"type:varchar(32);not null" form:"warning"`
	Critical      string `gorm:"type:varchar(32);not null" form:"critical"`
	Enabled       bool   `gorm:"not null" form:"enabled"`
	ResendTime    int    `gorm:"not null" form:"resend_time"`
	CheckType     string `gorm:"type:varchar(16);not null" form:"check_type"`
	CreatedAt     time.Time

	Alert Alert `gorm:"ForeignKey:AlertID"`
}

func (*GraphiteService) GenerateServices

func (gs *GraphiteService) GenerateServices(templates []Template) []Icinga2Service

type HTTPService

type HTTPService struct {
	ID            int    `gorm:"primary_key" form:"-"`
	AlertID       int    `gorm:"not null" form:"-"`
	Name          string `gorm:"type:varchar(64);not null" form:"name"`
	Type          int    `gorm:"not null;" form:"type"`
	Parameters    string `gorm:"type:longtext;not null" form:"parameters"`
	CheckAttempts int    `gorm:"not null; default 3" form:"check_attempts"`
	Enabled       bool   `gorm:"not null" form:"enabled"`
	ResendTime    int    `gorm:"not null" form:"resend_time"`
	CreatedAt     time.Time

	Alert Alert `gorm:"ForeignKey:AlertID"`
}

func (*HTTPService) GenerateServices

func (httpS *HTTPService) GenerateServices(templates []Template) []Icinga2Service

type Health

type Health struct {
	Icinga2Alive bool
}

func GetHealthStatus

func GetHealthStatus() *Health

type Icinga2Apply

type Icinga2Apply struct {
	Name             string
	NotificationType string
	Users            string
	ServiceName      string
	Interval         int
}

type Icinga2GraphiteService

type Icinga2GraphiteService struct {
	ID            string
	Name          string
	Warning       string
	Critical      string
	CheckAttempts int
	ResendTime    int
	MetricURL     string
	MetricType    string
}

Implements Icinga2Service

func (Icinga2GraphiteService) GetServiceCheckAttempts

func (gs Icinga2GraphiteService) GetServiceCheckAttempts() int

func (Icinga2GraphiteService) GetServiceCheckCommand

func (gs Icinga2GraphiteService) GetServiceCheckCommand() string

func (Icinga2GraphiteService) GetServiceID

func (gs Icinga2GraphiteService) GetServiceID() string

func (Icinga2GraphiteService) GetServiceName

func (gs Icinga2GraphiteService) GetServiceName() string

func (Icinga2GraphiteService) GetServiceNonStrVars

func (gs Icinga2GraphiteService) GetServiceNonStrVars() map[string]interface{}

func (Icinga2GraphiteService) GetServiceResendTime

func (gs Icinga2GraphiteService) GetServiceResendTime() int

func (Icinga2GraphiteService) GetServiceVars

func (gs Icinga2GraphiteService) GetServiceVars() map[string]interface{}

type Icinga2HTTPService

type Icinga2HTTPService struct {
	ID            string
	Name          string
	Params        CheckHTTPCmdParams
	CheckAttempts int
	ResendTime    int
}

Implements Icinga2Service

func (Icinga2HTTPService) GetServiceCheckAttempts

func (httpS Icinga2HTTPService) GetServiceCheckAttempts() int

func (Icinga2HTTPService) GetServiceCheckCommand

func (httpS Icinga2HTTPService) GetServiceCheckCommand() string

func (Icinga2HTTPService) GetServiceID

func (httpS Icinga2HTTPService) GetServiceID() string

func (Icinga2HTTPService) GetServiceName

func (httpS Icinga2HTTPService) GetServiceName() string

func (Icinga2HTTPService) GetServiceNonStrVars

func (httpS Icinga2HTTPService) GetServiceNonStrVars() map[string]interface{}

func (Icinga2HTTPService) GetServiceResendTime

func (httpS Icinga2HTTPService) GetServiceResendTime() int

func (Icinga2HTTPService) GetServiceVars

func (httpS Icinga2HTTPService) GetServiceVars() map[string]interface{}

type Icinga2Service

type Icinga2Service interface {
	GetServiceID() string
	GetServiceName() string
	GetServiceCheckCommand() string
	GetServiceCheckAttempts() int
	GetServiceResendTime() int
	GetServiceVars() map[string]interface{}
	GetServiceNonStrVars() map[string]interface{}
}

type Icinga2TCPService

type Icinga2TCPService struct {
	ID            string
	Name          string
	Host          string
	Port          int
	CheckAttempts int
	ResendTime    int
}

Implements Icinga2Service

func (Icinga2TCPService) GetServiceCheckAttempts

func (tcpS Icinga2TCPService) GetServiceCheckAttempts() int

func (Icinga2TCPService) GetServiceCheckCommand

func (tcpS Icinga2TCPService) GetServiceCheckCommand() string

func (Icinga2TCPService) GetServiceID

func (tcpS Icinga2TCPService) GetServiceID() string

func (Icinga2TCPService) GetServiceName

func (tcpS Icinga2TCPService) GetServiceName() string

func (Icinga2TCPService) GetServiceNonStrVars

func (tcpS Icinga2TCPService) GetServiceNonStrVars() map[string]interface{}

func (Icinga2TCPService) GetServiceResendTime

func (tcpS Icinga2TCPService) GetServiceResendTime() int

func (Icinga2TCPService) GetServiceVars

func (tcpS Icinga2TCPService) GetServiceVars() map[string]interface{}

type Icinga2TemplatedService

type Icinga2TemplatedService interface {
	GenerateServices(templates []Template) []Icinga2Service
}

type TCPService

type TCPService struct {
	ID            int    `gorm:"primary_key" form:"-"`
	AlertID       int    `gorm:"not null" form:"-"`
	Name          string `gorm:"type:varchar(64);not null" form:"name"`
	Host          string `gorm:"type:varchar(64);not null" form:"host"`
	Port          int    `gorm:"not null;" form:"port"`
	CheckAttempts int    `gorm:"not null; default 3" form:"check_attempts"`
	Enabled       bool   `gorm:"not null" form:"enabled"`
	ResendTime    int    `gorm:"not null" form:"resend_time"`
	CreatedAt     time.Time

	Alert Alert `gorm:"ForeignKey:AlertID"`
}

func (*TCPService) GenerateServices

func (tcps *TCPService) GenerateServices(templates []Template) []Icinga2Service

type Template

type Template struct {
	ID        int    `gorm:"primary_key" form:"-"`
	AlertID   int    `gorm:"not null" form:"-"`
	Name      string `gorm:"type:varchar(64);not null" form:"name"`
	Values    string `gorm:"type:text;not null" form:"values"`
	Alert     Alert  `gorm:"ForeignKey:AlertID" form:"-"`
	CreatedAt time.Time
}

type User

type User struct {
	ID               int    `gorm:"primary_key:true" form:"-"`
	Name             string `gorm:"type:varchar(64);not null;unique" form:"-"`
	EmailAddress     string `gorm:"type:varchar(64);not null" form:"email_address"`
	PhoneNumber      string `gorm:"type:varchar(64);not null" form:"phone_number"`
	BearychatTeam    string `gorm:"type:varchar(64);not null" form:"bearychat_team"`
	BearychatToken   string `gorm:"type:varchar(64);not null" form:"bearychat_token"`
	BearychatChannel string `gorm:"type:varchar(64);not null" form:"bearychat_channel"`
	PushbulletToken  string `gorm:"type:varchar(64);not null" form:"pushbullet_token"`
	SlackTeam        string `gorm:"type:varchar(64);not null" form:"slack_team"`
	SlackToken       string `gorm:"type:varchar(64);not null" form:"slack_token"`
	SlackChannel     string `gorm:"type:varchar(64);not null" form:"slack_channel"`
	CreatedAt        time.Time

	AdminedAlerts  []Alert `gorm:"many2many:alert_to_user_admin"`
	NotifiedAlerts []Alert `gorm:"many2many:alert_to_user_notify"`
}

Jump to

Keyboard shortcuts

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