models

package
v0.0.0-...-b9dc9a6 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoService = errors.New("add config failed:the service is not exist,please refresh")

Functions

func Ormer

func Ormer() orm.Ormer

singleton init ormer ,only use for normal db operation if you begin transaction,please use orm.NewOrm()

func SendAlertsFor

func SendAlertsFor(VUG *common.ValidUserGroup) []string

Types

type Alerts

type Alerts struct {
	Id              int64      `orm:"column(id);auto" json:"id,omitempty"`
	Rule            *Rules     `orm:"rel(fk)" json:"rule_id"`
	Labels          string     `orm:"column(labels);size(4095)" json:"labels"`
	Value           float64    `orm:"column(value)" json:"value"`
	Count           int        `json:"count"`
	Status          int8       `orm:"index" json:"status"`
	Summary         string     `orm:"column(summary);size(1023)" json:"summary"`
	Description     string     `orm:"column(description);size(1023)" json:"description"`
	Hostname        string     `orm:"column(hostname);size(255)" json:"hostname"`
	ConfirmedBy     string     `orm:"column(confirmed_by);size(1023)" json:"confirmed_by"`
	FiredAt         *time.Time `orm:"type(datetime)" json:"fired_at"`
	ConfirmedAt     *time.Time `orm:"null" json:"confirmed_at"`
	ConfirmedBefore *time.Time `orm:"null" json:"confirmed_before"`
	ResolvedAt      *time.Time `orm:"null" json:"resolved_at"`
}

func (*Alerts) AlertsHandler

func (u *Alerts) AlertsHandler(alert *common.Alerts)

func (*Alerts) ClassifyAlerts

func (u *Alerts) ClassifyAlerts() map[string]map[string][]OneAlert

func (*Alerts) ConfirmAll

func (u *Alerts) ConfirmAll(confirmList *common.Confirm) error

func (*Alerts) GetAlerts

func (u *Alerts) GetAlerts(pageNo int64, pageSize int64, timeStart string, timeEnd string, status string, summary string) ShowAlerts

func (*Alerts) ShowAlerts

func (u *Alerts) ShowAlerts(ruleId string, start string, pageNo int64, pageSize int64) ShowAlerts

func (*Alerts) TableName

func (*Alerts) TableName() string

type Configs

type Configs struct {
	Id        int64  `orm:"auto" json:"id,omitempty"` // 可能带orm标记,就会识别为数据库的字段。带json识别为json的
	ServiceId int64  `json:"serviceid"`
	Idc       string `orm:"size(255)" json:"idc"`
	Proto     string `orm:"size(255)" json:"proto"`
	Auto      string `orm:"size(255)" json:"auto"`
	Port      int    `json:"port"`
	Metric    string `orm:"size(255)" json:"metric"`
}

func (*Configs) AddConfig

func (p *Configs) AddConfig() error

func (*Configs) DeleteConfig

func (p *Configs) DeleteConfig(id string) error

func (*Configs) GetAllConfig

func (p *Configs) GetAllConfig(idc string) []Configs

func (*Configs) TableName

func (*Configs) TableName() string

func (*Configs) UpdateConfig

func (p *Configs) UpdateConfig() error

type Groups

type Groups struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"unique;size(255)" json:"name"`
	User string `orm:"size(1023)" json:"user"`
}

func (*Groups) AddGroup

func (g *Groups) AddGroup() error

func (*Groups) DeleteGroup

func (g *Groups) DeleteGroup(id string) error

func (*Groups) GetAll

func (g *Groups) GetAll() []Groups

func (*Groups) TableName

func (*Groups) TableName() string

func (*Groups) UpdateGroup

func (g *Groups) UpdateGroup() error

type Hosts

type Hosts struct {
	Id       int64  `orm:"auto" json:"id,omitempty"`
	Mid      int64  `json:"mid"`
	Hostname string `orm:"size(255)" json:"hostname"`
}

func (*Hosts) GetHosts

func (u *Hosts) GetHosts(mid string) []string

func (*Hosts) TableName

func (*Hosts) TableName() string

func (*Hosts) TableUnique

func (u *Hosts) TableUnique() [][]string

type HttpRes

type HttpRes struct {
	Status int    `json:"status"`
	Msg    string `json:"msg"`
	Data   []struct {
		ID      string `json:"id"`
		Title   string `json:"title"`
		Mobile  string `json:"mobile"`
		Email   string `json:"email"`
		AddTime string `json:"add_time"`
		Account string `json:"account"`
	} `json:"data"`
}

type Maintains

type Maintains struct {
	Id        int64  `orm:"auto" json:"id,omitempty"`
	Flag      bool   `json:"flag"`
	TimeStart string `orm:"size(15)" json:"time_start"`
	TimeEnd   string `orm:"size(15)" json:"time_end"`
	Month     int    `json:"month"`
	DayStart  int8   `json:"day_start"`
	DayEnd    int8   `json:"day_end"`
	//Week_start  int8   `json:"week_start"`
	//Week_end    int8   `json:"week_end"`
	//Month_start int8   `json:"month_start"`
	//Month_end   int8   `json:"month_end"`
	Valid *time.Time `json:"valid"`
}

func (*Maintains) AddMaintains

func (u *Maintains) AddMaintains(hosts string) error

func (*Maintains) DeleteMaintains

func (u *Maintains) DeleteMaintains(id string) error

func (*Maintains) GetAllMaintains

func (u *Maintains) GetAllMaintains() interface{}

func (*Maintains) TableIndex

func (u *Maintains) TableIndex() [][]string

func (*Maintains) TableName

func (*Maintains) TableName() string

func (*Maintains) UpdateMaintains

func (u *Maintains) UpdateMaintains(hosts string) error

type Manages

type Manages struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	ServiceName string `orm:"column(servicename);unique;size(255)" json:"servicename"`
	Type        string `orm:"size(255)" json:"type"`
	Status      int8   `orm:"index" json:"status"`
}

func (*Manages) AddManage

func (p *Manages) AddManage() error

func (*Manages) DeleteManage

func (p *Manages) DeleteManage(id string) error

func (*Manages) GetAllManage

func (p *Manages) GetAllManage() []Manages

func (*Manages) TableName

func (*Manages) TableName() string

func (*Manages) UpdateManage

func (p *Manages) UpdateManage() error

type OneAlert

type OneAlert struct {
	ID              int64      `json:"id"`
	RuleID          int64      `json:"rule_id"`
	Value           float64    `json:"value"`
	Status          int8       `json:"status"`
	Count           int        `json:"count"`
	Summary         string     `json:"summary"`
	Description     string     `json:"description"`
	ConfirmedBy     string     `json:"confirmed_by"`
	FiredAt         *time.Time `json:"fired_at"`
	ConfirmedAt     *time.Time `json:"confirmed_at"`
	ConfirmedBefore *time.Time `json:"confirmed_before"`
	ResolvedAt      *time.Time `json:"resolved_at"`
}

type Plans

type Plans struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	RuleLabels  string `orm:"column(rule_labels);size(255)" json:"rule_labels"`
	Description string `orm:"column(description);size(1023)" json:"description"`
}

func (*Plans) AddPlan

func (plan *Plans) AddPlan() error

func (*Plans) DeletePlan

func (plan *Plans) DeletePlan(id int64) error

func (*Plans) GetAllPlans

func (plan *Plans) GetAllPlans() []Plans

func (*Plans) TableName

func (*Plans) TableName() string

func (*Plans) UpdatePlan

func (plan *Plans) UpdatePlan() error

type Proms

type Proms struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"size(1023)" json:"name"`
	Url  string `orm:"size(1023)" json:"url"`
}

func (*Proms) AddProms

func (p *Proms) AddProms() error

func (*Proms) DeleteProms

func (p *Proms) DeleteProms(id string) error

func (*Proms) GetAllProms

func (p *Proms) GetAllProms() []Proms

func (*Proms) TableName

func (*Proms) TableName() string

func (*Proms) UpdateProms

func (p *Proms) UpdateProms() error

type Rec

type Rec struct {
	Id         int64  `json:"id,omitempty"`
	StartTime  string `json:"start_time"`
	EndTime    string `json:"end_time"`
	Start      int    `json:"start"`
	Period     int    `json:"period"`
	Expression string `json:"expression"`
	User       string `json:"user"`
	Group      string `json:"group"`
	DutyGroup  string `json:"duty_group"`
	Method     string `json:"method"`
}

type Receivers

type Receivers struct {
	Id                    int64  `orm:"auto" json:"id,omitempty"`
	Plan                  *Plans `orm:"index;rel(fk)" json:"plan_id"`
	StartTime             string `orm:"size(31)" json:"start_time"`
	EndTime               string `orm:"size(31)" json:"end_time"`
	Start                 int    `json:"start"`
	Period                int    `json:"period"`
	Expression            string `orm:"size(1023)" json:"expression"`
	ReversePolishNotation string `orm:"size(1023)" json:"reverse_polish_notation"`
	User                  string `orm:"size(1023)" json:"user"`
	Group                 string `orm:"size(1023)" json:"group"`
	DutyGroup             string `orm:"size(255)" json:"duty_group"`
	Method                string `orm:"size(255)" json:"method"`
}

func (*Receivers) AddReceiver

func (p *Receivers) AddReceiver() error

func (*Receivers) DeleteReceiver

func (p *Receivers) DeleteReceiver(id string) error

func (*Receivers) GetAllReceivers

func (p *Receivers) GetAllReceivers(planid string) []Rec

func (*Receivers) TableName

func (*Receivers) TableName() string

func (*Receivers) UpdateReceiver

func (p *Receivers) UpdateReceiver() error

type Rules

type Rules struct {
	Id          int64  `orm:"column(id);auto" json:"id,omitempty"`
	Expr        string `orm:"column(expr);size(1023)" json:"expr"`
	Op          string `orm:"column(op);size(31)" json:"op"`
	Value       string `orm:"column(value);size(1023)" json:"op"`
	For         string `orm:"column(for);size(1023)" json:"for"`
	Summary     string `orm:"column(summary);size(1023)" json:"summary"`
	Description string `orm:"column(description);size(1023)" json:"description"`
	Prom        *Proms `orm:"rel(fk)" json:"prom_id"`
	Plan        *Plans `orm:"rel(fk)" json:"plan_id"`
}

func (*Rules) DeleteRule

func (rule *Rules) DeleteRule(id string) error

func (*Rules) Get

func (*Rules) Get(prom string, id string) []Rules

func (*Rules) InsertRule

func (rule *Rules) InsertRule() error

func (*Rules) TableName

func (*Rules) TableName() string

func (*Rules) UpdateRule

func (rule *Rules) UpdateRule() error

type ShowAlerts

type ShowAlerts struct {
	Alerts []common.AlertForShow `json:"alerts"`
	Total  int64                 `json:"total"`
}

type Users

type Users struct {
	Id       int64  `orm:"auto" json:"id,omitempty"`
	Name     string `orm:"unique;size(255)" json:"name"`
	Password string `orm:"size(1023)" json:"password,omitempty"`
}

func (*Users) AddUser

func (g *Users) AddUser() error

func (*Users) CheckUser

func (g *Users) CheckUser(userInfo common.AuthModel) (*common.AuthModel, error)

func (*Users) DeleteUsers

func (g *Users) DeleteUsers(id string) error

func (*Users) GetAll

func (g *Users) GetAll() []Users

func (*Users) TableName

func (*Users) TableName() string

func (*Users) UpdatePassword

func (g *Users) UpdatePassword(name string, oldPassword string, newPassword string) error

Jump to

Keyboard shortcuts

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