models

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FLAG_SEND = iota
	FLAG_CALLBACK
	FLAG_MASK
	FLAG_CONVERGE
	FLAG_NONEUSER
	FLAG_UPGRADE
)

0 0 0 0 0 0 处理中 0 0 0 0 x 1 已发送 0 0 0 0 1 x 已回调 0 0 0 1 0 0 已屏蔽 0 0 1 0 0 0 被收敛 0 1 0 0 x 0 无接收人 1 0 0 0 x 0 升级发送

View Source
const (
	STATUS_DOING    = "doing"     // 处理中
	STATUS_SEND     = "send"      // 已发送
	STATUS_NONEUSER = "none-user" // 无接收人
	STATUS_CALLBACK = "callback"  // 已回调
	STATUS_MASK     = "mask"      // 已屏蔽
	STATUS_CONVERGE = "converge"  // 频率限制
	STATUS_UPGRADE  = "upgrade"   // 升级报警
)
View Source
const (
	PWD_INCLUDE_UPPER = 1 << iota
	PWD_INCLUDE_LOWER
	PWD_INCLUDE_NUMBER
	PWD_INCLUDE_SPEC_CHAR
)
View Source
const (
	LOGIN_T_SMS      = "sms-code"
	LOGIN_T_EMAIL    = "email-code"
	LOGIN_T_PWD      = "password"
	LOGIN_T_LDAP     = "ldap"
	LOGIN_T_RST      = "rst-code"
	LOGIN_T_LOGIN    = "login-code"
	LOGIN_EXPIRES_IN = 300
)
View Source
const (
	USER_S_ACTIVE = iota
	USER_S_INACTIVE
	USER_S_LOCKED
	USER_S_FROZEN
	USER_S_WRITEN_OFF
)
View Source
const (
	USER_T_NATIVE = iota
	USER_T_TEMP
)
View Source
const ALERT = "alert"
View Source
const InnerTenantIdent = "inner"
View Source
const RECOVERY = "recovery"

Variables

View Source
var DB = map[string]*xorm.Engine{}
View Source
var DefaultAuthConfig = AuthConfig{
	MaxConnIdleTime: 30,
	PwdMustInclude:  []string{},
}
View Source
var (
	EventTypeMap = map[string]string{RECOVERY: "恢复", ALERT: "报警"}
)
View Source
var MathOperators = map[string]bool{
	">":  true,
	"<":  true,
	">=": true,
	"<=": true,
	"!=": true,
	"=":  true,
}

Functions

func AggrCalcDel

func AggrCalcDel(id int64) error

func AlertUpgradeMarshal

func AlertUpgradeMarshal(alterUpgrade AlertUpgrade) (string, error)

func AuthConfigSet

func AuthConfigSet(config *AuthConfig) error

func CancelTask

func CancelTask(id int64) error

func CancelWaitingHosts

func CancelWaitingHosts(id int64) error

func CleanDoneTask

func CleanDoneTask(id int64) error

func CleanExpireMask

func CleanExpireMask(now int64) error

func ConfigsGet

func ConfigsGet(ckey string) (string, error)

func ConfigsGets

func ConfigsGets(ckeys []string) (map[string]string, error)

func ConfigsSet

func ConfigsSet(ckey, cval string) error

func CreateCollect

func CreateCollect(collectType, creator string, collect interface{}, dryRun bool) (err error)

func CryptoPass

func CryptoPass(raw string) (string, error)

CryptoPass crypto password use salt

func DeadTaskSchedulers

func DeadTaskSchedulers() ([]string, error)

func DelById

func DelById(id int64) error

func DelDeadTaskScheduler

func DelDeadTaskScheduler(scheduler string) error

func DelEventCurOlder

func DelEventCurOlder(ts int64, batch int) error

func DelEventOlder

func DelEventOlder(ts int64, batch int) error

func DeleteCollectById

func DeleteCollectById(collectType, creator string, cid int64) error

func DeleteCollectRule

func DeleteCollectRule(sid int64) error

func DoingHostCount

func DoingHostCount(where string, args ...interface{}) (int64, error)

func EventAlertUpgradeMarshal

func EventAlertUpgradeMarshal(alertUpgrade AlertUpgrade) (string, error)

func EventCnt

func EventCnt(hashid uint64, stime, etime int64, isUpgrade bool) (int64, error)

func EventCurDel

func EventCurDel(hashid uint64) error

func EventCurDelById

func EventCurDelById(id interface{}) error

func EventCurTotal

func EventCurTotal(stime, etime int64, nodePath, query string, priorities, sendTypes []string) (int64, error)

func EventDelById

func EventDelById(id interface{}) error

func EventTotal

func EventTotal(stime, etime int64, nodePath, query, eventType string, priorities, sendTypes []string) (int64, error)

func GenUUIDForUser

func GenUUIDForUser(username string) string

func GetFlagsByStatus

func GetFlagsByStatus(ss []string) []uint16

func GetRelatedNidsForMon

func GetRelatedNidsForMon(nid int64, exclNid []int64) ([]int64, error)

func GetStatus

func GetStatus(status string) int

func GetStatusByFlag

func GetStatusByFlag(flag uint16) []string

func GetTeamsNameByIds

func GetTeamsNameByIds(ids string) ([]string, error)

func GetUsernameByToken

func GetUsernameByToken(token string) (string, error)

GetUsernameByToken 使用方:rbac-proxy

func HostFieldNew

func HostFieldNew(objPtr *HostField) error

func HostFieldValuePuts

func HostFieldValuePuts(hostId int64, objs []HostFieldValue) error

func HostIdsByIps

func HostIdsByIps(ips []string) (ids []int64, err error)

func HostRegister

func HostRegister(f HostRegisterForm) error

func HostTotalForAdmin

func HostTotalForAdmin(tenant, query, batch, field string) (int64, error)

func HostUpdateCate

func HostUpdateCate(ids []int64, cate string) error

func HostUpdateNote

func HostUpdateNote(ids []int64, note string) error

func HostUpdateTenant

func HostUpdateTenant(ids []int64, tenant string) error

func IngStatusHostCount

func IngStatusHostCount(id int64) (int64, error)

func InitLDAP

func InitLDAP(conf LDAPSection)

func InitMySQL

func InitMySQL(names ...string)

func InitRooter

func InitRooter()

func InitSalt

func InitSalt()

InitSalt generate random salt

func InviteNew

func InviteNew(token, creator string) error

func KillTask

func KillTask(id int64) error

func LeafIdsByNodes

func LeafIdsByNodes(nodes []Node) ([]int64, error)

根据一堆节点获取下面的叶子节点的ID列表

func LoginLogNew

func LoginLogNew(username, client, inout string, err error) error

func LoginLogTotal

func LoginLogTotal(username string, btime, etime int64) (int64, error)

func LongTaskIds

func LongTaskIds() ([]int64, error)

LongTaskIds two weeks ago

func MapKeyClear

func MapKeyClear(src map[string]interface{}, save map[string]struct{})

mapKeyClear map key clear

func MarkDoneStatus

func MarkDoneStatus(id, clock int64, host, status, stdout, stderr string) error

func MaskconfDel

func MaskconfDel(id int64) error

func MibDel

func MibDel(id int64) error

func MibTotal

func MibTotal(query string) (int64, error)

func NetworkHardwareCount

func NetworkHardwareCount(where string, args ...interface{}) (int64, error)

func NetworkHardwareDel

func NetworkHardwareDel(id int64) error

func NetworkHardwareNew

func NetworkHardwareNew(objPtr *NetworkHardware) error

func NetworkHardwareResourceRegister

func NetworkHardwareResourceRegister(hws []*NetworkHardware, tenant string) error

ResourceRegister 资源分配给某个租户的时候调用

func NetworkHardwareTotal

func NetworkHardwareTotal(query string) (int64, error)

func NodeAdminExists

func NodeAdminExists(session *xorm.Session, nodeId, userId int64) (bool, error)

func NodeAdminNew

func NodeAdminNew(session *xorm.Session, nodeId, userId int64) error

func NodeCateFieldNew

func NodeCateFieldNew(objPtr *NodeCateField) error

func NodeCateNew

func NodeCateNew(objPtr *NodeCate) error

func NodeClearAdmins

func NodeClearAdmins(session *xorm.Session, nodeId int64) error

func NodeFieldValuePuts

func NodeFieldValuePuts(nodeId int64, objs []NodeFieldValue) error

func NodeIdsBindingUsername

func NodeIdsBindingUsername(username string) ([]int64, error)

NodeIdsBindingUsername 某人在哪些节点配置过权限

func NodeIdsBindingUsernameWithOp

func NodeIdsBindingUsernameWithOp(username, op string) ([]int64, error)

NodeIdsBindingUsernameWithOp 我在哪些节点上有这个操作权限

func NodeIdsBindingUsernameWithRoles

func NodeIdsBindingUsernameWithRoles(username string, roleIds []int64) ([]int64, error)

NodeIdsBindingUsernameWithRoles 我以某些角色的名义绑定在哪些节点

func NodeIdsByPaths

func NodeIdsByPaths(paths []string) ([]int64, error)

func NodeIdsGetByResIds

func NodeIdsGetByResIds(rids []int64) ([]int64, error)

func NodeIdsIamAdmin

func NodeIdsIamAdmin(userId int64) ([]int64, error)

NodeIdsIamAdmin 我是管理员的节点ID列表

func NodeNew

func NodeNew(objPtr *Node, adminIds []int64) error

func NodeResourceBind

func NodeResourceBind(nid, rid int64) error

func NodeResourceUnbind

func NodeResourceUnbind(nid, rid int64) error

func NodeResourceUnbindByRids

func NodeResourceUnbindByRids(rids []int64) error

func NodeRoleDel

func NodeRoleDel(nodeId, roleId int64, username string) error

func NodeRoleExists

func NodeRoleExists(nodeIds, roleIds []int64, username string) (bool, error)

func NodeTrashRecycle

func NodeTrashRecycle(ids []int64) error

从node_trash表回收部分node,前端一个一个操作,也可以同一层级同时操作 之前的父节点可能已经挪动过,所以回收的时候要注意重新更新path信息

func NodeTrashTotal

func NodeTrashTotal(query string) (int64, error)

func NodesAdminExists

func NodesAdminExists(nodeIds []int64, userId int64) (bool, error)

func NwTotalForAdmin

func NwTotalForAdmin(tenant, query, batch, field string) (int64, error)

func OperationLogNew

func OperationLogNew(username, rescl string, resid interface{}, detail string) error

func OperationLogTotal

func OperationLogTotal(query string, btime, etime int64) (int64, error)

func OperationLogTotalByRes

func OperationLogTotalByRes(rescl, resid string, btime, etime int64) (int64, error)

func OperationsOfRoles

func OperationsOfRoles(rids []int64) ([]string, error)

func OrphanTaskIds

func OrphanTaskIds() ([]int64, error)

func ParseEtime

func ParseEtime(etime int64) string

func Paths

func Paths(longPath string) []string

Paths 把长路径切成多个path,比如: cop.sre.falcon.judge.hna被切成: cop、cop.sre、cop.sre.falcon、cop.sre.falcon.judge、cop.sre.falcon.judge.hna

func ReportHeartBeat

func ReportHeartBeat(rev Instance) error

func ResCountGetByNodeIdsAndCate

func ResCountGetByNodeIdsAndCate(nids []int64, cate string) (int, error)

ResCountGetByNodeIdsAndWhere 根据叶子节点和Where条件获取资源数量表

func ResIdsGetByNodeIds

func ResIdsGetByNodeIds(nids []int64) ([]int64, error)

ResIdsGetByNodeIds 根据叶子节点获取资源ID列表

func ResourceBindingsForMon

func ResourceBindingsForMon(idents []string) ([]string, error)

ResourceBindingsForMon 告警消息里要看到资源挂载的节点信息

func ResourceIdentsByIds

func ResourceIdentsByIds(ids []int64) ([]string, error)

func ResourceIdsByIdents

func ResourceIdsByIdents(idents []string) ([]int64, error)

func ResourceIdsByUUIDs

func ResourceIdsByUUIDs(uuids []string) ([]int64, error)

func ResourceOrphanTotal

func ResourceOrphanTotal(tenant, query, batch, field string) (int64, error)

func ResourceRegister

func ResourceRegister(hosts []Host, tenant string) error

ResourceRegister 资源分配给某个租户的时候调用

func ResourceRegisterFor3rd

func ResourceRegisterFor3rd(item ResourceRegisterItem) (errCode int, err error)

ResourceRegisterFor3rd 用于第三方资源注册 errCode=400: 表示传入的参数有问题 errCode=500: 表示DB出了问题 之所以要通过errCode对错误做区分,是因为这个方法同时被同步和异步两种方式调用,上层需要依托这个信息做判断

func ResourceUnderNodeTotal

func ResourceUnderNodeTotal(leafIds []int64, query, batch, field string) (int64, error)

func ResourceUnregister

func ResourceUnregister(uuids []string) error

func RoleBiggerThan

func RoleBiggerThan(roleid int64) ([]int64, error)

func RoleIdsBindingUsername

func RoleIdsBindingUsername(username string, nids []int64) ([]int64, error)

func RoleIdsGetByUserId

func RoleIdsGetByUserId(userId int64) ([]int64, error)

func RoleIdsHasOp

func RoleIdsHasOp(op string) ([]int64, error)

RoleIdsHasOp 看哪些role里边包含operation

func RoleMap

func RoleMap(cate string) (map[int64]string, error)

RoleMap key: role_id, value: role_name

func RunWaitingHosts

func RunWaitingHosts(hosts []TaskHost) error

func SaveEvent

func SaveEvent(event *Event) error

func SaveEventCur

func SaveEventCur(eventCur *EventCur) error

func SaveEventCurStatus

func SaveEventCurStatus(hashid uint64, status string) error

func SaveEventStatus

func SaveEventStatus(id int64, status string) error

func SaveStraCommit

func SaveStraCommit(id int64, action, username, body string, session *xorm.Session) error

func SessionAll

func SessionAll() (int64, error)

func SessionCleanupByCreatedAt

func SessionCleanupByCreatedAt(ts int64) error

func SessionCleanupByUpdatedAt

func SessionCleanupByUpdatedAt(ts int64) error

func SessionDelete

func SessionDelete(sid string) error

func SessionTotal

func SessionTotal(where string, args ...interface{}) (int64, error)

func SessionUpdate

func SessionUpdate(in *Session) error

func SessionUserAll

func SessionUserAll(username string) (int64, error)

func SetDoingCache

func SetDoingCache(v map[string][]TaskHostDoing)

func StartTask

func StartTask(id int64) error

func StatusConvert

func StatusConvert(s []string) []string

func StraDel

func StraDel(id int64) error

func StraDelByNid

func StraDelByNid(nid int64) error

func TakeOverTask

func TakeOverTask(id int64, pre, current string) (bool, error)

func TaskActionExistsIds

func TaskActionExistsIds(ids []int64) ([]int64, error)

func TaskMetaTotal

func TaskMetaTotal(creator, query string, before time.Time) (int64, error)

func TaskSchedulerHeartbeat

func TaskSchedulerHeartbeat(endpoint string) error

func TaskTplTotal

func TaskTplTotal(nodeId int64, query string) (int64, error)

func TasksOfScheduler

func TasksOfScheduler(scheduler string) ([]int64, error)

func TeamAdd

func TeamAdd(ident, name, note string, mgmt int, creator int64) (int64, error)

func TeamHasMember

func TeamHasMember(tid, uid int64, isAdmin ...int) (bool, error)

func TeamIdentByIds

func TeamIdentByIds(ids []int64) ([]string, error)

func TeamIdsByUserId

func TeamIdsByUserId(uid int64, isAdmin ...int) ([]int64, error)

func TeamTotal

func TeamTotal(query string) (int64, error)

func TeamTotalInIds

func TeamTotalInIds(ids []int64, query string) (int64, error)

func TokenAll

func TokenAll() (int64, error)

func TokenDelete

func TokenDelete(token string) error

func UnexpectedHostCount

func UnexpectedHostCount(id int64) (int64, error)

func UpdateClaimantsById

func UpdateClaimantsById(userId, id int64) error

func UpdateClaimantsByNodePath

func UpdateClaimantsByNodePath(userId int64, nodePath string) error

func UpdateEventCurPriority

func UpdateEventCurPriority(hashid uint64, priority int) error

func UpdateEventPriority

func UpdateEventPriority(id int64, priority int) error

func UpdateIconColor

func UpdateIconColor(newColor, cate string) error

func UserFillUUIDs

func UserFillUUIDs() error

func UserHasGlobalRole

func UserHasGlobalRole(userId int64, roleIds []int64) (bool, error)

UserHasGlobalRole 查看某个用户是否有某个全局角色

func UserIdsByTeamIds

func UserIdsByTeamIds(tids []int64, isAdmin ...int) ([]int64, error)

func UserIdsGetByRoleIds

func UserIdsGetByRoleIds(roleIds []int64) ([]int64, error)

func UserSearchTotalInIds

func UserSearchTotalInIds(ids []int64, query string) (int64, error)

func UserTotal

func UserTotal(ids []int64, where string, args ...interface{}) (int64, error)

func UsernameByUUID

func UsernameByUUID(uuid string) string

Deprecated

func UsernameCandoGlobalOp

func UsernameCandoGlobalOp(username, operation string) (bool, error)

UsernameCandoGlobalOp 使用方:RDB、rbac-proxy

func UsernameCandoNodeOp

func UsernameCandoNodeOp(username, operation string, nodeId int64) (bool, error)

func WaitingHostCount

func WaitingHostCount(id int64) (int64, error)

func WarningStr

func WarningStr(s string) bool

func WhiteListAccess

func WhiteListAccess(addr string) error

func WhiteListTotal

func WhiteListTotal(query string) (int64, error)

Types

type AggrCalc

type AggrCalc struct {
	Id               int64     `xorm:"id pk autoincr" json:"id"`
	Nid              int64     `xorm:"nid" json:"nid"`
	Category         int       `xorm:"category" json:"category"`
	NewMetric        string    `xorm:"new_metric" json:"new_metric"`
	NewStep          int       `xorm:"new_step" json:"new_step"`
	GroupByString    string    `xorm:"groupby" json:"-"`
	RawMetricsString string    `xorm:"raw_metrics" json:"-"`
	GlobalOperator   string    `xorm:"global_operator"json:"global_operator"` //指标聚合方式
	Expression       string    `xorm:"expression" json:"expression"`
	RPN              string    `xorm:"rpn" json:"rpn"`     //用途?
	Status           int       `xorm:"status" json:"-"`    //审核状态
	Quota            int       `xorm:"quota" json:"quota"` //用途?
	Comment          string    `xorm:"comment" json:"comment"`
	Creator          string    `xorm:"creator" json:"creator"`
	Created          time.Time `xorm:"created" json:"created"`
	LastUpdator      string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated      time.Time `xorm:"<-" json:"last_updated"`

	RawMetrics []*dataobj.RawMetric `xorm:"-" json:"raw_metrics"`
	GroupBy    []string             `xorm:"-" json:"groupby"`
	VarNum     int                  `xorm:"-" json:"var_num"`
}

func AggrCalcGet

func AggrCalcGet(where string, args ...interface{}) (*AggrCalc, error)

func AggrCalcsList

func AggrCalcsList(name string, nid int64) ([]*AggrCalc, error)

func (*AggrCalc) Decode

func (a *AggrCalc) Decode() error

func (*AggrCalc) Encode

func (a *AggrCalc) Encode() error

func (*AggrCalc) Save

func (a *AggrCalc) Save() error

func (*AggrCalc) Update

func (a *AggrCalc) Update(cols ...string) error

type AggrTagsFilter

type AggrTagsFilter struct {
	TagK string   `json:"tagk"`
	Opt  string   `json:"opt"`
	TagV []string `json:"tagv"`
}

type AlertUpgrade

type AlertUpgrade struct {
	Users    []int64 `json:"users"`
	Groups   []int64 `json:"groups"`
	Duration int     `json:"duration"`
	Level    int     `json:"level"`
}

func AlertUpgradeUnMarshal

func AlertUpgradeUnMarshal(str string) (AlertUpgrade, error)

type ApiCollect

type ApiCollect struct {
	Id               int64     `json:"id"`
	Nid              int64     `json:"nid"`
	CollectType      string    `json:"collect_type"`
	Name             string    `json:"name"`
	Domain           string    `json:"domain"`
	Path             string    `json:"path"`
	HeaderStr        string    `xorm:"header" json:"-"`
	Step             int       `json:"step"`
	Timeout          int       `json:"timeout"`
	Protocol         string    `json:"protocol"`
	PortStr          string    `xorm:"port" json:"-"`
	Method           string    `json:"method"`
	MaxRedirect      int       `json:"max_redirect"`
	PostBody         string    `json:"post_body"`
	ExpectedCodeStr  string    `xorm:"expected_code" json:"-"`
	ExpectedString   string    `json:"expected_string"`
	UnexpectedString string    `json:"unexpected_string"`
	Region           string    `json:"region"`
	Comment          string    `json:"comment"`
	LastUpdator      string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated      time.Time `xorm:"updated" json:"last_updated"`
	Creator          string    `json:"creator"`
	Created          time.Time `xorm:"updated" json:"created"`

	Header       map[string]string `xorm:"-" json:"header"`
	ExpectedCode []string          `xorm:"-" json:"expected_code"`
	Port         int               `xorm:"-" json:"port"`
}

func GetApiCollects

func GetApiCollects() ([]*ApiCollect, error)

func (*ApiCollect) Decode

func (a *ApiCollect) Decode() error

func (*ApiCollect) Encode

func (a *ApiCollect) Encode() error

func (*ApiCollect) Update

func (a *ApiCollect) Update() error

type ApiCollectRpcResp

type ApiCollectRpcResp struct {
	Data []*ApiCollect
	Msg  string
}

type Auth

type Auth struct {
	Community     Secret `json:"community,omitempty"`
	SecurityLevel string `json:"security_level,omitempty"`
	Username      string `json:"username,omitempty"`
	Password      Secret `json:"password,omitempty"`
	AuthProtocol  string `json:"auth_protocol,omitempty"`
	PrivProtocol  string `json:"priv_protocol,omitempty"`
	PrivPassword  Secret `json:"priv_password,omitempty"`
	ContextName   string `json:"context_name,omitempty"`
}

type AuthConfig

type AuthConfig struct {
	MaxNumErr          int      `json:"maxNumErr"`
	MaxSessionNumber   int64    `json:"maxSessionNumber"`
	MaxConnIdleTime    int64    `json:"maxConnIdleTime" description:"minute"`
	LockTime           int64    `json:"lockTime" description:"minute"`
	PwdHistorySize     int      `json:"pwdHistorySize"`
	PwdMinLenght       int      `json:"pwdMinLenght"`
	PwdExpiresIn       int64    `json:"pwdExpiresIn" description:"month"`
	PwdMustInclude     []string `json:"pwdMustInclude" description:"upper,lower,number,specChar"`
	PwdMustIncludeFlag int      `json:"pwdMustIncludeFlag"`
}

func AuthConfigGet

func AuthConfigGet() (*AuthConfig, error)

func (AuthConfig) MustInclude

func (p AuthConfig) MustInclude() string

func (AuthConfig) PwdRules

func (p AuthConfig) PwdRules() []string

func (*AuthConfig) Validate

func (p *AuthConfig) Validate() error

type AuthState

type AuthState struct {
	State     string `json:"state"`
	Typ       string `json:"typ"`
	Redirect  string `json:"redirect"`
	ExpiresAt int64  `json:"expiresAt"`
}

func AuthStateGet

func AuthStateGet(where string, args ...interface{}) (*AuthState, error)

func (AuthState) CleanUp

func (p AuthState) CleanUp() error

func (*AuthState) Del

func (p *AuthState) Del() error

func (*AuthState) Save

func (p *AuthState) Save() error

type Captcha

type Captcha struct {
	CaptchaId string `json:"captchaId"`
	Answer    string `json:"-"`
	Image     string `xorm:"-" json:"image"`
	CreatedAt int64  `json:"createdAt"`
}

func CaptchaGet

func CaptchaGet(where string, args ...interface{}) (*Captcha, error)

func (Captcha) CleanUp

func (p Captcha) CleanUp() error

func (*Captcha) Del

func (p *Captcha) Del() error

func (*Captcha) Save

func (p *Captcha) Save() error

type Chart

type Chart struct {
	Id         int64  `json:"id"`
	SubclassId int64  `json:"subclass_id"`
	Configs    string `json:"configs"`
	Weight     int    `json:"weight"`
}

func ChartGet

func ChartGet(col string, val interface{}) (*Chart, error)

func ChartGets

func ChartGets(subclassId int64) ([]Chart, error)

func (*Chart) Add

func (c *Chart) Add() error

func (*Chart) Del

func (c *Chart) Del() error

func (*Chart) Update

func (c *Chart) Update(cols ...string) error

type Collect

type Collect struct {
	sync.RWMutex
	Ports   map[int]*PortCollect      `json:"ports"`
	Procs   map[string]*ProcCollect   `json:"procs"`
	Logs    map[string]*LogCollect    `json:"logs"`
	Plugins map[string]*PluginCollect `json:"plugins"`
}

func NewCollect

func NewCollect() *Collect

func (*Collect) GetLogConfig

func (c *Collect) GetLogConfig() map[string]*LogCollect

func (*Collect) GetPlugin

func (c *Collect) GetPlugin() map[string]*PluginCollect

func (*Collect) GetPorts

func (c *Collect) GetPorts() map[int]*PortCollect

func (*Collect) GetProcs

func (c *Collect) GetProcs() map[string]*ProcCollect

func (*Collect) Update

func (c *Collect) Update(cc *Collect)

type CollectHist

type CollectHist struct {
	Id          int64     `json:"id"`
	Cid         int64     `json:"cid"`
	CollectType string    `json:"collect_type"`
	Action      string    `json:"action"`
	Body        string    `json:"body"`
	Creator     string    `json:"creator"`
	Created     time.Time `xorm:"created" json:"created"`
}

type CollectRule

type CollectRule struct {
	Id          int64           `json:"id"`
	Nid         int64           `json:"nid"`
	Step        int64           `json:"step" description:"interval"`
	Timeout     int             `json:"timeout"`
	CollectType string          `json:"collect_type" description:"plugin name"`
	Name        string          `json:"name" describes:"customize name"`
	Region      string          `json:"region"`
	Comment     string          `json:"comment"`
	DryRun      bool            `json:"dryrun" xorm:"-"`
	Data        json.RawMessage `json:"data"`
	Tags        string          `json:"tags" description:"k1=v1,k2=v2,k3=v3,..."`
	Creator     string          `json:"creator" description:"just for output"`
	Updater     string          `json:"updater" description:"just for output"`
	CreatedAt   int64           `json:"created_at" description:"just for output"`
	UpdatedAt   int64           `json:"updated_at" description:"just for output"`
}

func DumpCollectRules

func DumpCollectRules() ([]*CollectRule, error)

func GetCollectRules

func GetCollectRules(typ string, nid int64, limit, offset int) (total int64, list []*CollectRule, err error)

func (CollectRule) PluginName

func (p CollectRule) PluginName() string

func (*CollectRule) String

func (p *CollectRule) String() string

func (*CollectRule) Update

func (p *CollectRule) Update() (err error)

func (*CollectRule) Validate

func (p *CollectRule) Validate(v ...interface{}) error

type CollectRuleRpcResp

type CollectRuleRpcResp struct {
	Data []*CollectRule
	Msg  string
}

type Configs

type Configs struct {
	Id   int64
	Ckey string
	Cval string
}

type Event

type Event struct {
	Id           int64     `json:"id"`
	Sid          int64     `json:"sid"`
	Sname        string    `json:"sname"`
	Nid          int64     `json:"nid"`
	NodePath     string    `json:"node_path"`
	CurNodePath  string    `json:"cur_node_path"`
	Endpoint     string    `json:"endpoint"`
	Priority     int       `json:"priority"`
	EventType    string    `json:"event_type"` // alert|recovery
	Category     int       `json:"category"`
	Status       uint16    `json:"status"`
	HashId       uint64    `json:"hashid"  xorm:"hashid"`
	Etime        int64     `json:"etime"`
	Value        string    `json:"value"`
	Info         string    `json:"info"`
	Created      time.Time `json:"created" xorm:"created"`
	Detail       string    `json:"detail"`
	Users        string    `json:"users"`
	Groups       string    `json:"groups"`
	Runbook      string    `json:"runbook"`
	NeedUpgrade  int       `json:"need_upgrade"`
	AlertUpgrade string    `json:"alert_upgrade"`
	RecvUserIDs  []int64   `json:"recv_user_ids" xorm:"-"`
	RealUpgrade  bool      `json:"real_upgrade" xorm:"-"`
	WorkGroups   []int     `json:"work_groups" xorm:"-"`
	CurNid       string    `json:"cur_nid"`
}

func EventGet

func EventGet(col string, value interface{}) (*Event, error)

func EventGets

func EventGets(stime, etime int64, nodePath, query, eventType string, priorities, sendTypes []string, limit, offset int) ([]Event, error)

func (*Event) GetEventDetail

func (e *Event) GetEventDetail() ([]EventDetail, error)

type EventAlertUpgrade

type EventAlertUpgrade struct {
	Users    string `json:"users"`
	Groups   string `json:"groups"`
	Duration int    `json:"duration"`
	Level    int    `json:"level"`
}

func EventAlertUpgradeUnMarshal

func EventAlertUpgradeUnMarshal(str string) (EventAlertUpgrade, error)

type EventCur

type EventCur struct {
	Id           int64     `json:"id"`
	Sid          int64     `json:"sid"`
	Sname        string    `json:"sname"`
	NodePath     string    `json:"node_path"`
	CurNodePath  string    `json:"cur_node_path"`
	Endpoint     string    `json:"endpoint"`
	Priority     int       `json:"priority"`
	EventType    string    `json:"event_type"` // alert|recovery
	Category     int       `json:"category"`
	Status       uint16    `json:"status"`
	HashId       uint64    `json:"hashid"  xorm:"hashid"`
	Etime        int64     `json:"etime"`
	Value        string    `json:"value"`
	Info         string    `json:"info"`
	Created      time.Time `json:"created" xorm:"created"`
	Detail       string    `json:"detail"`
	Users        string    `json:"users"`
	Groups       string    `json:"groups"`
	Runbook      string    `json:"runbook"`
	Nid          int64     `json:"nid"`
	IgnoreAlert  int       `json:"ignore_alert"`
	Claimants    string    `json:"claimants"`
	NeedUpgrade  int       `json:"need_upgrade"`
	AlertUpgrade string    `json:"alert_upgrade"`
	CurNid       string    `json:"cur_nid"`
	WorkGroups   []int     `json:"work_groups" xorm:"-"`
}

func AllEventCurGet added in v4.0.4

func AllEventCurGet() ([]EventCur, error)

func EventCurGet

func EventCurGet(col string, value interface{}) (*EventCur, error)

func EventCurGets

func EventCurGets(stime, etime int64, nodePath, query string, priorities, sendTypes []string, limit, offset int) ([]EventCur, error)

func (*EventCur) EventIgnore

func (e *EventCur) EventIgnore() error

type EventDetail

type EventDetail struct {
	Metric     string              `json:"metric"`
	Tags       map[string]string   `json:"tags"`
	Points     []*EventDetailPoint `json:"points"`
	PredPoints []*EventDetailPoint `json:"pred_points,omitempty"` // 预测值, 预测值不为空时, 现场值对应的是实际值
}

type EventDetailPoint

type EventDetailPoint struct {
	Timestamp int64   `json:"timestamp"`
	Value     float64 `json:"value"`
	Extra     string  `json:"extra"`
}

type EventSlice

type EventSlice []*Event

func (EventSlice) Len

func (e EventSlice) Len() int

func (EventSlice) Less

func (e EventSlice) Less(i, j int) bool

func (EventSlice) Swap

func (e EventSlice) Swap(i, j int)

type Exp

type Exp struct {
	Eopt      string  `json:"eopt"`
	Func      string  `json:"func"`      //all,max,min
	Metric    string  `json:"metric"`    //metric
	Params    []int   `json:"params"`    //连续n秒
	Threshold float64 `json:"threshold"` //阈值
}

type Host

type Host struct {
	Id     int64  `json:"id"`
	SN     string `json:"sn" xorm:"'sn'"`
	IP     string `json:"ip" xorm:"'ip'"`
	Ident  string `json:"ident"`
	Name   string `json:"name"`
	Note   string `json:"note"`
	CPU    string `json:"cpu" xorm:"'cpu'"`
	Mem    string `json:"mem"`
	Disk   string `json:"disk"`
	Cate   string `json:"cate"`
	Clock  int64  `json:"clock"`
	Tenant string `json:"tenant"`
}

func HostByIds

func HostByIds(ids []int64) (hosts []Host, err error)

func HostGet

func HostGet(where string, args ...interface{}) (*Host, error)

func HostGets

func HostGets(where string, args ...interface{}) (hosts []Host, err error)

func HostGetsForAdmin

func HostGetsForAdmin(tenant, query, batch, field string, limit, offset int) ([]Host, error)

func HostNew

func HostNew(sn, ip, ident, name, cate string, fields map[string]interface{}) (*Host, error)

func HostSearch

func HostSearch(batch, field string) ([]Host, error)

func (*Host) Del

func (h *Host) Del() error

func (*Host) Save

func (h *Host) Save() error

func (*Host) Update

func (h *Host) Update(fields map[string]interface{}) error

type HostField

type HostField struct {
	Id            int64  `json:"id"`
	FieldIdent    string `json:"field_ident"`
	FieldName     string `json:"field_name"`
	FieldType     string `json:"field_type"`
	FieldRequired int    `json:"field_required"`
	FieldExtra    string `json:"field_extra"`
	FieldCate     string `json:"field_cate"`
}

func HostFieldGet

func HostFieldGet(where string, args ...interface{}) (*HostField, error)

func HostFieldGets

func HostFieldGets() ([]HostField, error)

HostFieldGets 条数非常少,全部返回

func (*HostField) Del

func (hf *HostField) Del() error

func (*HostField) Update

func (hf *HostField) Update(cols ...string) error

func (*HostField) Validate

func (hf *HostField) Validate() error

type HostFieldValue

type HostFieldValue struct {
	Id         int64  `json:"id"`
	HostId     int64  `json:"host_id"`
	FieldIdent string `json:"field_ident"`
	FieldValue string `json:"field_value"`
}

func HostFieldValueGets

func HostFieldValueGets(hostId int64) ([]HostFieldValue, error)

HostFieldValueGets 条数非常少,全部返回

func (*HostFieldValue) Validate

func (hfv *HostFieldValue) Validate() error

type HostRegisterForm

type HostRegisterForm struct {
	SN      string                 `json:"sn"`
	IP      string                 `json:"ip"`
	Ident   string                 `json:"ident"`
	Name    string                 `json:"name"`
	Cate    string                 `json:"cate"`
	UniqKey string                 `json:"uniqkey"`
	Fields  map[string]interface{} `json:"fields"`
	Digest  string                 `json:"digest"`
}

func (HostRegisterForm) Validate

func (f HostRegisterForm) Validate() error

type Index

type Index struct {
	TagKey  string    `json:"tagKey"`
	Type    string    `json:"type"`
	Oid     string    `json:"oid"`
	Lookups []*Lookup `json:"lookups"`
}

type Instance

type Instance struct {
	Id       int64  `json:"id"`
	Module   string `json:"module"`
	Identity string `json:"identity"` //ip 或者 机器名
	RPCPort  string `json:"rpc_port" xorm:"rpc_port"`
	HTTPPort string `json:"http_port" xorm:"http_port"`
	TS       int64  `json:"ts" xorm:"ts"`
	Remark   string `json:"remark"`
	Region   string `json:"region"`
	Active   bool   `xorm:"-" json:"active"`
}

func GetAllInstances

func GetAllInstances(mod string, alive int) ([]*Instance, error)

func GetInstanceBy

func GetInstanceBy(mod, identity, rpcPort, httpPort string) (*Instance, error)

func (*Instance) Add

func (i *Instance) Add() error

func (*Instance) Update

func (i *Instance) Update() error

type InstancesResp

type InstancesResp struct {
	Data []*Instance
	Msg  string
}

rpc

type Invite

type Invite struct {
	Id      int64
	Token   string
	Expire  int64
	Creator string
}

func InviteGet

func InviteGet(where string, args ...interface{}) (*Invite, error)

func InviteMustGet

func InviteMustGet(where string, args ...interface{}) (*Invite, error)

func (*Invite) Del

func (i *Invite) Del() error

type LDAPSection

type LDAPSection struct {
	DefaultUse      bool           `yaml:"defaultUse"`
	Host            string         `yaml:"host"`
	Port            int            `yaml:"port"`
	BaseDn          string         `yaml:"baseDn"`
	BindUser        string         `yaml:"bindUser"`
	BindPass        string         `yaml:"bindPass"`
	AuthFilter      string         `yaml:"authFilter"`
	Attributes      ldapAttributes `yaml:"attributes"`
	CoverAttributes bool           `yaml:"coverAttributes"`
	TLS             bool           `yaml:"tls"`
	StartTLS        bool           `yaml:"startTLS"`
}
var LDAPConfig LDAPSection

type LogCollect

type LogCollect struct {
	Id          int64     `json:"id"`
	Nid         int64     `json:"nid"`
	CollectType string    `json:"collect_type"`
	Name        string    `json:"name"`
	TagsStr     string    `xorm:"tags" json:"-"`
	Step        int       `json:"step"`
	Comment     string    `json:"comment"`
	Creator     string    `json:"creator"`
	Created     time.Time `xorm:"updated" json:"created"`
	LastUpdator string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated time.Time `xorm:"updated" json:"last_updated"`

	Tags map[string]string `xorm:"-" json:"tags"`

	FilePath   string `json:"file_path"`
	TimeFormat string `json:"time_format"`
	Pattern    string `json:"pattern"`
	Func       string `json:"func"`
	FuncType   string `json:"func_type"`
	Unit       string `json:"unit"`

	Degree    int    `json:"degree"`
	Zerofill  int    `xorm:"zero_fill" json:"zerofill"`
	Aggregate string `json:"aggregate"`

	LocalUpdated            int64                     `xorm:"-" json:"-"`
	TimeReg                 *regexp.Regexp            `xorm:"-" json:"-"`
	PatternReg              *regexp.Regexp            `xorm:"-" json:"-"`
	ExcludeReg              *regexp.Regexp            `xorm:"-" json:"-"`
	TagRegs                 map[string]*regexp.Regexp `xorm:"-" json:"-"`
	ParseSucc               bool                      `xorm:"-" json:"-"`
	WhetherAttachOneLogLine int                       `json:"whether_attach_one_log_line" xorm:"'whether_attach_one_log_line'"`
}

func GetLogCollects

func GetLogCollects() ([]*LogCollect, error)

func (*LogCollect) Decode

func (l *LogCollect) Decode() error

func (*LogCollect) Encode

func (l *LogCollect) Encode() error

func (*LogCollect) Update

func (p *LogCollect) Update() error

type LoginCode

type LoginCode struct {
	Username  string `json:"username"`
	Code      string `json:"code"`
	LoginType string `json:"login_type"`
	CreatedAt int64  `json:"created_at"`
}

func LoginCodeGet

func LoginCodeGet(where string, args ...interface{}) (*LoginCode, error)

func (*LoginCode) Del

func (p *LoginCode) Del() error

func (*LoginCode) Save

func (p *LoginCode) Save() error

type LoginLog

type LoginLog struct {
	Id       int64  `json:"id"`
	Username string `json:"username"`
	Client   string `json:"client"`
	Clock    int64  `json:"clock"`
	Loginout string `json:"loginout"`
	Err      string `json:"err"`
}

func LoginLogGets

func LoginLogGets(username string, btime, etime int64, limit, offset int) ([]LoginLog, error)

type Lookup

type Lookup struct {
	Labels    []string `yaml:"labels" json:"labels"`
	Labelname string   `yaml:"labelname" json:"labelname"`
	Oid       string   `yaml:"oid" json:"oid,omitempty"`
	Type      string   `yaml:"type" json:"type,omitempty"`
}

type Maskconf

type Maskconf struct {
	Id          int64             `json:"id"`
	Category    int               `json:"category"`
	Nid         int64             `json:"nid"`
	NodePath    string            `json:"node_path" xorm:"-"`
	Metric      string            `json:"metric"`
	Tags        string            `json:"tags"`
	Cause       string            `json:"cause"`
	User        string            `json:"user"`
	Btime       int64             `json:"btime"`
	Etime       int64             `json:"etime"`
	Endpoints   []string          `json:"endpoints" xorm:"-"`
	Nids        []string          `json:"nids" xorm:"-"`
	CurNidPaths map[string]string `json:"cur_nid_paths" xorm:"-"`
}

func MaskconfGet

func MaskconfGet(col string, value interface{}) (*Maskconf, error)

func MaskconfGetAll

func MaskconfGetAll() ([]Maskconf, error)

func MaskconfGets

func MaskconfGets(nodeId int64) ([]Maskconf, error)

func (*Maskconf) AddEndpoints

func (mc *Maskconf) AddEndpoints(endpoints []string) error

func (*Maskconf) AddNids

func (mc *Maskconf) AddNids(nidPaths map[string]string) error

func (*Maskconf) FillEndpoints

func (mc *Maskconf) FillEndpoints() error

func (*Maskconf) FillNids

func (mc *Maskconf) FillNids() error

func (*Maskconf) UpdateEndpoints

func (mc *Maskconf) UpdateEndpoints(endpoints []string, cols ...string) error

func (*Maskconf) UpdateNids

func (mc *Maskconf) UpdateNids(nidPaths map[string]string, cols ...string) error

type MaskconfEndpoints

type MaskconfEndpoints struct {
	Id       int64  `json:"id"`
	MaskId   int64  `json:"mask_id"`
	Endpoint string `json:"endpoint"`
}

type MaskconfNids

type MaskconfNids struct {
	Id     int64  `json:"id"`
	MaskId int64  `json:"mask_id"`
	Nid    string `json:"nid"`
	Path   string `json:"path"`
}

type Metric

type Metric struct {
	Name           string                     `yaml:"name"`
	Oid            string                     `yaml:"oid"`
	Type           string                     `yaml:"type"`
	Help           string                     `yaml:"help"`
	Indexes        []*Index                   `yaml:"indexes,omitempty"`
	Lookups        []*Lookup                  `yaml:"lookups,omitempty"`
	RegexpExtracts map[string][]RegexpExtract `yaml:"regex_extracts,omitempty"`
	EnumValues     map[int]string             `yaml:"enum_values,omitempty"`
}

type Mib

type Mib struct {
	Id         int64  `json:"id"`
	Module     string `json:"module"`
	Metric     string `json:"metric"`
	Oid        string `json:"oid"`
	Mtype      string `json:"mtype"` //gauge,counter
	EnumValues string `json:"enum_values"`
	Indexes    string `json:"indexes"`
	Note       string `json:"note"`
}

func MibGet

func MibGet(where string, args ...interface{}) (*Mib, error)

func MibGets

func MibGets(where string, args ...interface{}) ([]Mib, error)

func MibGetsByQuery

func MibGetsByQuery(query string, limit, offset int) ([]Mib, error)

func MibGetsGroupBy

func MibGetsGroupBy(group string, where string, args ...interface{}) ([]Mib, error)

func NewMib

func NewMib(module string, m *Metric) *Mib

func (*Mib) Save

func (m *Mib) Save() error

type Module

type Module struct {
	// A list of OIDs.
	Walk       []string   `yaml:"walk,omitempty"`
	Get        []string   `yaml:"get,omitempty"`
	Metrics    []*Metric  `yaml:"metrics"`
	WalkParams WalkParams `yaml:",inline"`
}

type MySQLConf

type MySQLConf struct {
	Addr  string `yaml:"addr"`
	Max   int    `yaml:"max"`
	Idle  int    `yaml:"idle"`
	Debug bool   `yaml:"debug"`
}

type NetworkHardware

type NetworkHardware struct {
	Id          int64  `json:"id"`
	SN          string `json:"sn" xorm:"sn"`
	IP          string `json:"ip" xorm:"ip"`
	Name        string `json:"name"`
	Note        string `json:"note"`
	Cate        string `json:"cate"`
	SnmpVersion string `json:"snmp_version"`
	Auth        string `json:"auth"`
	Region      string `json:"region"`
	Info        string `json:"info"`
	Tenant      string `json:"tenant"`
	Uptime      int64  `json:"uptime"`
}

func GetHardwareInfoBy

func GetHardwareInfoBy(ips []string) []*NetworkHardware

func MakeNetworkHardware

func MakeNetworkHardware(ip, cate, version, auth, region, note string) *NetworkHardware

func NetworkHardwareGet

func NetworkHardwareGet(where string, args ...interface{}) (*NetworkHardware, error)

func NetworkHardwareList

func NetworkHardwareList(query string, limit, offset int) ([]NetworkHardware, error)

func NwGetsForAdmin

func NwGetsForAdmin(tenant, query, batch, field string, limit, offset int) ([]NetworkHardware, error)

func NwSearch

func NwSearch(batch, field string) ([]NetworkHardware, error)

NwSearch 普通用户查询

func (*NetworkHardware) Del

func (n *NetworkHardware) Del() error

func (*NetworkHardware) Update

func (n *NetworkHardware) Update(cols ...string) error

type NetworkHardwareRpcResp

type NetworkHardwareRpcResp struct {
	Data []*NetworkHardware
	Msg  string
}

type Node

type Node struct {
	Id          int64     `json:"id"`
	Pid         int64     `json:"pid"`
	Ident       string    `json:"ident"`
	Name        string    `json:"name"`
	Note        string    `json:"note"`
	Path        string    `json:"path"`
	Leaf        int       `json:"leaf"`
	Cate        string    `json:"cate"`
	IconColor   string    `json:"icon_color"`
	IconChar    string    `json:"icon_char"`
	Proxy       int       `json:"proxy"`
	Creator     string    `json:"creator"`
	LastUpdated time.Time `json:"last_updated" xorm:"<-"`
	Admins      []User    `json:"admins" xorm:"-"`
	LeafNids    []int64   `json:"leafNids" xorm:"-"`
}

func NodeByIds

func NodeByIds(ids []int64) ([]Node, error)

func NodeByPaths

func NodeByPaths(paths []string) ([]Node, error)

func NodeGet

func NodeGet(where string, args ...interface{}) (*Node, error)

func NodeGetById

func NodeGetById(id int64) (*Node, error)

func NodeGets

func NodeGets(where string, args ...interface{}) (nodes []Node, err error)

NodeGets 在所有节点范围查询,比如管理员看服务树,就需要load所有数据

func PermNodes

func PermNodes(myNodes []Node) ([]Node, error)

func TenantsGetByUserId

func TenantsGetByUserId(id int64, withAdmins ...bool) (tenants []Node, err error)

TenantsGetByUserId 使用方:工单

func TreeUntilProjectsGetByNid

func TreeUntilProjectsGetByNid(nid int64) ([]Node, error)

func TreeUntilProjectsGetByUser

func TreeUntilProjectsGetByUser(user *User) ([]Node, error)

暂时保留,不知道外部其他组件是否有调用

func TreeUntilTypGetByUser

func TreeUntilTypGetByUser(user *User, typ string) ([]Node, error)

func UserPermNodes

func UserPermNodes(me *User) ([]Node, error)

func (*Node) Bind

func (n *Node) Bind(resIds []int64) error

Bind 把资源挂载到某个树节点

func (*Node) CreateChild

func (n *Node) CreateChild(ident, name, note, cate, creator string, leaf, proxy int, adminIds []int64) (*Node, error)

CreateChild 返回创建的子节点

func (*Node) Del

func (n *Node) Del() error

func (*Node) FillAdmins

func (n *Node) FillAdmins() error

func (*Node) FilterMyChildren

func (n *Node) FilterMyChildren(nodes []Node) []Node

func (*Node) LeafIds

func (n *Node) LeafIds() ([]int64, error)

LeafIds 叶子节点的id

func (*Node) Modify

func (n *Node) Modify(name, cate, note string, adminIds []int64) error

func (*Node) Move added in v4.0.2

func (n *Node) Move(tnode *Node) error

func (*Node) RelatedNodes

func (n *Node) RelatedNodes() ([]Node, error)

todo 是否需要待确认

func (*Node) RoleList

func (n *Node) RoleList(username string, limit, offset int) ([]NodeRole, error)

func (*Node) RoleTotal

func (n *Node) RoleTotal(username string) (int64, error)

func (*Node) Tenant

func (n *Node) Tenant() string

func (*Node) Unbind

func (n *Node) Unbind(resIds []int64) error

Unbind 从某个服务树节点解挂机器

type NodeAdmin

type NodeAdmin struct {
	NodeId int64
	UserId int64
}

type NodeCate

type NodeCate struct {
	Id        int64  `json:"id"`
	Ident     string `json:"ident"`
	Name      string `json:"name"`
	IconColor string `json:"icon_color"`
	Protected int    `json:"protected"`
}

func NodeCateGet

func NodeCateGet(where string, args ...interface{}) (*NodeCate, error)

func NodeCateGets

func NodeCateGets() ([]NodeCate, error)

NodeCateGets 条数非常少,全部返回

func (*NodeCate) Del

func (nc *NodeCate) Del() error

Del 删除NodeCate的时候无需去管node表,某些node的cate已经被删除了,也没什么大不了

func (*NodeCate) Update

func (nc *NodeCate) Update(cols ...string) error

type NodeCateField

type NodeCateField struct {
	Id            int64     `json:"id"`
	Cate          string    `json:"cate"`
	FieldIdent    string    `json:"field_ident"`
	FieldName     string    `json:"field_name"`
	FieldType     string    `json:"field_type"`
	FieldRequired int       `json:"field_required"`
	FieldExtra    string    `json:"field_extra"`
	LastUpdated   time.Time `json:"last_updated" xorm:"<-"`
}

func NodeCateFieldGet

func NodeCateFieldGet(where string, args ...interface{}) (*NodeCateField, error)

func NodeCateFieldGets

func NodeCateFieldGets(where string, args ...interface{}) ([]NodeCateField, error)

NodeCateFieldGets 条数非常少,全部返回

func (*NodeCateField) Del

func (ncf *NodeCateField) Del() error

func (*NodeCateField) Update

func (ncf *NodeCateField) Update(cols ...string) error

func (*NodeCateField) Validate

func (ncf *NodeCateField) Validate() error

type NodeFieldValue

type NodeFieldValue struct {
	Id         int64  `json:"id"`
	NodeId     int64  `json:"node_id"`
	FieldIdent string `json:"field_ident"`
	FieldValue string `json:"field_value"`
}

func NodeFieldValueGets

func NodeFieldValueGets(nodeId int64) ([]NodeFieldValue, error)

NodeFieldValueGets 条数非常少,全部返回

func (*NodeFieldValue) Validate

func (nfv *NodeFieldValue) Validate() error

type NodeResource

type NodeResource struct {
	NodeId int64
	ResId  int64
}

func NodeResourceGetAll added in v4.0.4

func NodeResourceGetAll() ([]*NodeResource, error)

type NodeRole

type NodeRole struct {
	Id       int64  `json:"id"`
	NodeId   int64  `json:"node_id"`
	Username string `json:"username"`
	RoleId   int64  `json:"role_id"`
	NodePath string `xorm:"<- 'node_path'" json:"node_path"`
	RoleTxt  string `xorm:"-" json:"role_txt"`
	Dispname string `xorm:"-" json:"dispname"`
}

func (*NodeRole) Save

func (nr *NodeRole) Save() error

type NodeTrash

type NodeTrash struct {
	Id          int64     `json:"id"`
	Pid         int64     `json:"pid"`
	Ident       string    `json:"ident"`
	Name        string    `json:"name"`
	Note        string    `json:"note"`
	Path        string    `json:"path"`
	Leaf        int       `json:"leaf"`
	Cate        string    `json:"cate"`
	IconColor   string    `json:"icon_color"`
	IconChar    string    `json:"icon_char"`
	Proxy       int       `json:"proxy"`
	Creator     string    `json:"creator"`
	LastUpdated time.Time `json:"last_updated" xorm:"<-"`
}

func NodeTrashGetByIds

func NodeTrashGetByIds(ids []int64) ([]NodeTrash, error)

func NodeTrashGets

func NodeTrashGets(query string, limit, offset int) ([]NodeTrash, error)

type OperationLog

type OperationLog struct {
	Id       int64  `json:"id"`
	Username string `json:"username"`
	Clock    int64  `json:"clock"`
	ResCl    string `json:"res_cl"`
	ResId    string `json:"res_id"`
	Detail   string `json:"detail"`
}

func OperationLogGetsByRes

func OperationLogGetsByRes(rescl, resid string, btime, etime int64, limit, offset int) ([]OperationLog, error)

func OperationLogQuery

func OperationLogQuery(query string, btime, etime int64, limit, offset int) ([]OperationLog, error)

func (*OperationLog) New

func (ol *OperationLog) New() error

type PluginCollect

type PluginCollect struct {
	Id          int64     `json:"id"`
	Nid         int64     `json:"nid"`
	CollectType string    `json:"collect_type"`
	Name        string    `json:"name"`
	Step        int       `json:"step"`
	FilePath    string    `json:"file_path"`
	Params      string    `json:"params"`
	Stdin       string    `json:"stdin"`
	Env         string    `json:"env"`
	Comment     string    `json:"comment"`
	Creator     string    `json:"creator"`
	Created     time.Time `xorm:"updated" json:"created"`
	LastUpdator string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated time.Time `xorm:"updated" json:"last_updated"`
}

func GetPluginCollects

func GetPluginCollects() ([]*PluginCollect, error)

func (*PluginCollect) Update

func (p *PluginCollect) Update() error

type PortCollect

type PortCollect struct {
	Id          int64     `json:"id"`
	Nid         int64     `json:"nid"`
	CollectType string    `json:"collect_type"`
	Name        string    `json:"name"`
	Tags        string    `json:"tags"`
	Step        int       `json:"step"`
	Comment     string    `json:"comment"`
	Creator     string    `json:"creator"`
	Created     time.Time `xorm:"updated" json:"created"`
	LastUpdator string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated time.Time `xorm:"updated" json:"last_updated"`

	Port    int `json:"port"`
	Timeout int `json:"timeout"`
}

func GetPortCollects

func GetPortCollects() ([]*PortCollect, error)

func (*PortCollect) Update

func (p *PortCollect) Update() error

type ProcCollect

type ProcCollect struct {
	Id          int64     `json:"id"`
	Nid         int64     `json:"nid"`
	CollectType string    `json:"collect_type"`
	Name        string    `json:"name"`
	Tags        string    `json:"tags"`
	Step        int       `json:"step"`
	Comment     string    `json:"comment"`
	Creator     string    `json:"creator"`
	Created     time.Time `xorm:"updated" json:"created"`
	LastUpdator string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated time.Time `xorm:"updated" json:"last_updated"`

	Target        string `json:"target"`
	CollectMethod string `json:"collect_method"`

	ProcJiffy map[int]uint64 `xorm:"-" json:"-"`
	Jiffy     uint64         `xorm:"-" json:"-"`
	RBytes    map[int]uint64 `xorm:"-" json:"-"`
	WBytes    map[int]uint64 `xorm:"-" json:"-"`
}

func GetProcCollects

func GetProcCollects() ([]*ProcCollect, error)

func (*ProcCollect) Update

func (p *ProcCollect) Update() error

type Regexp

type Regexp struct {
	*regexp.Regexp
}

Regexp encapsulates a regexp.Regexp and makes it YAML marshalable.

type RegexpExtract

type RegexpExtract struct {
	Value string `yaml:"value"`
	Regex Regexp `yaml:"regex"`
}

type Resource

type Resource struct {
	Id          int64     `json:"id"`
	UUID        string    `json:"uuid" xorm:"'uuid'"`
	Ident       string    `json:"ident"`
	Name        string    `json:"name"`
	Labels      string    `json:"labels"`
	Note        string    `json:"note"`
	Extend      string    `json:"extend"`
	Cate        string    `json:"cate"`
	Tenant      string    `json:"tenant"`
	LastUpdated time.Time `json:"last_updated" xorm:"<-"`
}

func ResourceGet

func ResourceGet(where string, args ...interface{}) (*Resource, error)

func ResourceGets

func ResourceGets(where string, args ...interface{}) ([]Resource, error)

func ResourceOrphanList

func ResourceOrphanList(tenant, query, batch, field string, limit, offset int) ([]Resource, error)

func ResourceSearch

func ResourceSearch(batch, field string) ([]Resource, error)

func ResourceUnderNodeGets

func ResourceUnderNodeGets(leafIds []int64, query, batch, field string, limit, offset int) ([]Resource, error)

func ResourcesByIdents

func ResourcesByIdents(idents []string) ([]Resource, error)

func (*Resource) Save

func (r *Resource) Save() error

func (*Resource) Update

func (r *Resource) Update(cols ...string) error

type ResourceBinding

type ResourceBinding struct {
	Id    int64  `json:"id"`
	UUID  string `json:"uuid"`
	Ident string `json:"ident"`
	Name  string `json:"name"`
	Nodes []Node `json:"nodes"`
}

func ResourceBindings

func ResourceBindings(resIds []int64) ([]ResourceBinding, error)

ResourceBindings 资源与节点的绑定关系,一个资源对应多个节点

type ResourceRegisterItem

type ResourceRegisterItem struct {
	UUID   string `json:"uuid"`
	Ident  string `json:"ident"`
	Name   string `json:"name"`
	Labels string `json:"labels"`
	Extend string `json:"extend"`
	Cate   string `json:"cate"`
	NID    int64  `json:"nid"`
}

func (ResourceRegisterItem) Validate

func (i ResourceRegisterItem) Validate() error

type Role

type Role struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
	Note string `json:"note"`
	Cate string `json:"cate"`
}

func GlobalRolesGetByUserId

func GlobalRolesGetByUserId(id int64) (roles []Role, err error)

GlobalRolesGetByUserId 使用方:工单

func RoleFind

func RoleFind(cate string) ([]Role, error)

func RoleGet

func RoleGet(where string, args ...interface{}) (*Role, error)

func RoleGetByIds

func RoleGetByIds(ids []int64) (roles []Role, err error)

func (*Role) BindUsers

func (r *Role) BindUsers(userIds []int64) error

func (*Role) CheckFields

func (r *Role) CheckFields() error

func (*Role) Del

func (r *Role) Del() error

func (*Role) GlobalUserIds

func (r *Role) GlobalUserIds() ([]int64, error)

func (*Role) Modify

func (r *Role) Modify(name, note, cate string, ops []string) error

func (*Role) Save

func (r *Role) Save(ops []string) error

func (*Role) UnbindUsers

func (r *Role) UnbindUsers(ids []int64) error

type RoleGlobalUser

type RoleGlobalUser struct {
	RoleId int64 `json:"role_id" xorm:"'role_id'"`
	UserId int64 `json:"user_id" xorm:"'user_id'"`
}

func RoleGlobalUserAll

func RoleGlobalUserAll() ([]RoleGlobalUser, error)

type RoleOperation

type RoleOperation struct {
	Id        int64  `json:"id"`
	RoleId    int64  `json:"role_id"`
	Operation string `json:"operation"`
}

func RoleOperationAll

func RoleOperationAll() ([]RoleOperation, error)

type Screen

type Screen struct {
	Id          int64     `json:"id"`
	NodeId      int64     `json:"node_id"`
	Name        string    `json:"name"`
	LastUpdator string    `json:"last_updator"`
	LastUpdated time.Time `xorm:"<-" json:"last_updated"`

	NodePath string `json:"node_path" xorm:"-"`
}

func ScreenGet

func ScreenGet(col string, val interface{}) (*Screen, error)

func ScreenGets

func ScreenGets(nodeId int64) ([]Screen, error)

func (*Screen) Add

func (s *Screen) Add() error

func (*Screen) Del

func (s *Screen) Del() error

func (*Screen) Update

func (s *Screen) Update(cols ...string) error

type ScreenSubclass

type ScreenSubclass struct {
	Id       int64  `json:"id"`
	ScreenId int64  `json:"screen_id"`
	Name     string `json:"name"`
	Weight   int    `json:"weight"`
}

func ScreenSubclassGet

func ScreenSubclassGet(col string, val interface{}) (*ScreenSubclass, error)

func ScreenSubclassGets

func ScreenSubclassGets(screenId int64) ([]ScreenSubclass, error)

func (*ScreenSubclass) Add

func (s *ScreenSubclass) Add() error

func (*ScreenSubclass) Del

func (s *ScreenSubclass) Del() error

func (*ScreenSubclass) Update

func (s *ScreenSubclass) Update(cols ...string) error

type Secret

type Secret string

Secret is a string that must not be revealed on marshaling.

type Session

type Session struct {
	Sid         string `json:"sid"`
	AccessToken string `json:"-"`
	Username    string `json:"username"`
	RemoteAddr  string `json:"remote_addr"`
	CreatedAt   int64  `json:"created_at"`
	UpdatedAt   int64  `json:"updated_at"`
}

func SessionAndTotalGets

func SessionAndTotalGets(query string, limit, offset int) ([]Session, int64, error)

func SessionGet

func SessionGet(sid string) (*Session, error)

func SessionGetByToken

func SessionGetByToken(token string) (*Session, error)

func SessionGetWithCache

func SessionGetWithCache(sid string) (*Session, error)

SessionGetWithCache will update session.UpdatedAt && token.LastAt

func SessionGets

func SessionGets(limit, offset int, where string, args ...interface{}) ([]Session, error)

func TokenGetWithCache

func TokenGetWithCache(accessToken string) (*Session, error)

TokenGetWithCache will update token.LastAt

func (*Session) Save

func (s *Session) Save() error

func (*Session) Update

func (s *Session) Update(cols ...string) error

type SnmpCollect

type SnmpCollect struct {
	Id          int64     `json:"id"`
	Nid         int64     `json:"nid"`
	CollectType string    `json:"collect_type"`
	OidType     int       `json:"oid_type"` //1 通用指标 2 私有指标 3 自定义指标
	Module      string    `json:"module"`
	Metric      string    `json:"metric"`
	MetricType  string    `json:"metric_type"`
	Oid         string    `json:"oid"`
	Step        int       `json:"step"`
	Timeout     int       `json:"timeout"`
	Port        int       `json:"port"`
	IndexesStr  string    `xorm:"indexes" json:"-"`
	Comment     string    `json:"comment"`
	Creator     string    `json:"creator"`
	Created     time.Time `xorm:"updated" json:"created"`
	LastUpdator string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated time.Time `xorm:"updated" json:"last_updated"`

	Indexes []*Index `xorm:"-" json:"indexes"`
	Region  string   `xorm:"-" json:"region"`
	Version string   `xorm:"-" json:"version"`
	Auth    string   `xorm:"-" json:"auth"`
}

func GetSnmpCollects

func GetSnmpCollects(nid int64) ([]*SnmpCollect, error)

func (*SnmpCollect) Decode

func (s *SnmpCollect) Decode() error

func (*SnmpCollect) Encode

func (s *SnmpCollect) Encode() error

func (*SnmpCollect) GetByOidAndModule

func (s *SnmpCollect) GetByOidAndModule() (*SnmpCollect, error)

func (*SnmpCollect) Update

func (s *SnmpCollect) Update() error

type Stats

type Stats struct {
	Name  string `json:"name"`
	Value int64  `json:"value"`
}

func MustNewStats

func MustNewStats(name string) *Stats

func NewStats

func NewStats(name string) (*Stats, error)

func (*Stats) Del

func (p *Stats) Del() error

func (*Stats) Get

func (p *Stats) Get() int64

func (*Stats) Inc

func (p *Stats) Inc(i int) error

for COUNTER

func (*Stats) Save

func (p *Stats) Save() error

func (*Stats) Update

func (p *Stats) Update(i int64) error

for GAUAGE

type Stra

type Stra struct {
	Id                  int64     `json:"id"`
	Name                string    `json:"name"`
	Category            int       `json:"category"` //机器,非机器
	Nid                 int64     `json:"nid"`
	ExclNidStr          string    `xorm:"excl_nid" json:"-"`            //排除的叶子节点
	AlertDur            int       `json:"alert_dur"`                    //单位秒,持续异常10分钟则产生异常event
	RecoveryDur         int       `json:"recovery_dur"`                 //单位秒,持续正常2分钟则产生恢复event,0表示立即产生恢复event
	RecoveryNotify      int       `json:"recovery_notify"`              //1 发送恢复通知 0不发送恢复通知
	ExprsStr            string    `xorm:"exprs" json:"-"`               //多个条件的监控实例需要相同,并且同时满足才产生event
	TagsStr             string    `xorm:"tags" json:"-"`                //tag过滤条件
	EnableStime         string    `json:"enable_stime"`                 //策略生效开始时间
	EnableEtime         string    `json:"enable_etime"`                 //策略生效终止时间 支持23:00-02:00
	EnableDaysOfWeekStr string    `xorm:"enable_days_of_week" json:"-"` //策略生效日期
	ConvergeStr         string    `xorm:"converge" json:"-"`            //告警通知收敛,第1个值表示收敛周期,单位秒,第2个值表示周期内允许发送告警次数
	Priority            int       `json:"priority"`
	Callback            string    `json:"callback"`
	NotifyGroupStr      string    `xorm:"notify_group" json:"-"`
	NotifyUserStr       string    `xorm:"notify_user" json:"-"`
	Creator             string    `json:"creator"`
	Created             time.Time `xorm:"created" json:"created"`
	LastUpdator         string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated         time.Time `xorm:"<-" json:"last_updated"`
	NeedUpgrade         int       `xorm:"need_upgrade" json:"need_upgrade"`
	AlertUpgradeStr     string    `xorm:"alert_upgrade" json:"-"`
	WorkGroupsStr       string    `xorm:"work_groups" json:"-"`
	Runbook             string    `xorm:"runbook" json:"runbook"`

	ExclNid           []int64      `xorm:"-" json:"excl_nid"`
	Nids              []string     `xorm:"-" json:"nids"`
	Exprs             []Exp        `xorm:"-" json:"exprs"`
	Tags              []Tag        `xorm:"-" json:"tags"`
	EnableDaysOfWeek  []int        `xorm:"-" json:"enable_days_of_week"`
	Converge          []int        `xorm:"-" json:"converge"`
	NotifyGroup       []int64      `xorm:"-" json:"notify_group"`
	NotifyGroupDetail []Team       `xorm:"-" json:"notify_group_detail"`
	NotifyUser        []int64      `xorm:"-" json:"notify_user"`
	NotifyUserDetail  []User       `xorm:"-" json:"notify_user_detail"`
	LeafNids          []int64      `xorm:"-" json:"leaf_nids"` //叶子节点id
	Endpoints         []string     `xorm:"-" json:"endpoints"`
	AlertUpgrade      AlertUpgrade `xorm:"-" json:"alert_upgrade"`
	JudgeInstance     string       `xorm:"-" json:"judge_instance"`
	WorkGroups        []int        `xorm:"-" json:"work_groups"`
}

func EffectiveStrasList

func EffectiveStrasList() ([]*Stra, error)

func StraFindOne

func StraFindOne(where string, args ...interface{}) (*Stra, error)

func StraGet

func StraGet(col string, val interface{}) (*Stra, error)

func StrasAll

func StrasAll() ([]*Stra, error)

func StrasList

func StrasList(name string, priority int, nid int64) ([]*Stra, error)

func (*Stra) Decode

func (s *Stra) Decode() error

func (*Stra) Encode

func (s *Stra) Encode() error

func (*Stra) GetMetric

func (s *Stra) GetMetric() string

func (*Stra) HasPermssion

func (s *Stra) HasPermssion() error

func (*Stra) Save

func (s *Stra) Save() error

func (*Stra) Update

func (s *Stra) Update() error

type StraLog

type StraLog struct {
	Id      int64     `json:"id"`
	Sid     int64     `json:"sid"`
	Action  string    `json:"action"` // update|delete
	Body    string    `json:"body"`
	Creator string    `json:"creator"`
	Created time.Time `json:"created" xorm:"created"`
}

type Tag

type Tag struct {
	Tkey string   `json:"tkey"`
	Topt string   `json:"topt"`
	Tval []string `json:"tval"` //修改为数组
}

type TaskAction

type TaskAction struct {
	Id     int64
	Action string
	Clock  int64
}

func TaskActionGet

func TaskActionGet(where string, args ...interface{}) (*TaskAction, error)

func (*TaskAction) Update

func (a *TaskAction) Update(action string) error

type TaskHost

type TaskHost struct {
	Id     int64  `json:"id"`
	Host   string `json:"host"`
	Status string `json:"status"`
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
}

func TaskHostGet

func TaskHostGet(id int64, host string) (*TaskHost, error)

func TaskHostGets

func TaskHostGets(id int64) ([]TaskHost, error)

func TaskHostStatus

func TaskHostStatus(id int64) ([]TaskHost, error)

func WaitingHostList

func WaitingHostList(id int64, limit ...int) ([]TaskHost, error)

type TaskHostDoing

type TaskHostDoing struct {
	Id     int64
	Host   string
	Clock  int64
	Action string
}

func DoingHostList

func DoingHostList(where string, args ...interface{}) ([]TaskHostDoing, error)

func GetDoingCache

func GetDoingCache(k string) []TaskHostDoing

type TaskMeta

type TaskMeta struct {
	Id        int64     `json:"id"`
	Title     string    `json:"title"`
	Account   string    `json:"account"`
	Batch     int       `json:"batch"`
	Tolerance int       `json:"tolerance"`
	Timeout   int       `json:"timeout"`
	Pause     string    `json:"pause"`
	Script    string    `json:"script"`
	Args      string    `json:"args"`
	Creator   string    `json:"creator"`
	Created   time.Time `xorm:"created" json:"created"`
	Done      bool      `xorm:"-" json:"done"`
}

func TaskMetaGet

func TaskMetaGet(where string, args ...interface{}) (*TaskMeta, error)

func TaskMetaGetByID

func TaskMetaGetByID(id interface{}) (*TaskMeta, error)

TaskMetaGet 根据ID获取任务元信息,会用到内存缓存

func TaskMetaGets

func TaskMetaGets(creator, query string, before time.Time, limit, offset int) ([]TaskMeta, error)

func (*TaskMeta) Action

func (m *TaskMeta) Action() (*TaskAction, error)

func (*TaskMeta) CleanFields

func (m *TaskMeta) CleanFields() error

func (*TaskMeta) HandleFH

func (m *TaskMeta) HandleFH(fh string)

func (*TaskMeta) HostStrs

func (m *TaskMeta) HostStrs() ([]string, error)

func (*TaskMeta) Hosts

func (m *TaskMeta) Hosts() ([]TaskHost, error)

func (*TaskMeta) IgnoreHost

func (m *TaskMeta) IgnoreHost(host string) error

func (*TaskMeta) KillHost

func (m *TaskMeta) KillHost(host string) error

func (*TaskMeta) RedoHost

func (m *TaskMeta) RedoHost(host string) error

func (*TaskMeta) Save

func (m *TaskMeta) Save(hosts []string, action string) error

func (*TaskMeta) Stderrs

func (m *TaskMeta) Stderrs() ([]TaskHost, error)

func (*TaskMeta) Stdouts

func (m *TaskMeta) Stdouts() ([]TaskHost, error)

type TaskScheduler

type TaskScheduler struct {
	Id        int64
	Scheduler string
}

type TaskSchedulerHealth

type TaskSchedulerHealth struct {
	Scheduler string
	Clock     time.Time
}

type TaskTpl

type TaskTpl struct {
	Id          int64     `json:"id"`
	NodeId      int64     `json:"node_id"`
	Title       string    `json:"title"`
	Batch       int       `json:"batch"`
	Tolerance   int       `json:"tolerance"`
	Timeout     int       `json:"timeout"`
	Pause       string    `json:"pause"`
	Script      string    `json:"script"`
	Args        string    `json:"args"`
	Tags        string    `json:"tags"`
	Account     string    `json:"account"`
	Creator     string    `json:"creator"`
	LastUpdated time.Time `xorm:"<-" json:"last_updated"`
}

func TaskTplGet

func TaskTplGet(where string, args ...interface{}) (*TaskTpl, error)

func TaskTplGets

func TaskTplGets(nodeId int64, query string, limit, offset int) ([]TaskTpl, error)

func (*TaskTpl) BindTags

func (t *TaskTpl) BindTags(tags []string) error

func (*TaskTpl) CleanFields

func (t *TaskTpl) CleanFields() error

func (*TaskTpl) Del

func (t *TaskTpl) Del() error

func (*TaskTpl) Hosts

func (t *TaskTpl) Hosts() ([]string, error)

func (*TaskTpl) Save

func (t *TaskTpl) Save(hosts []string) error

func (*TaskTpl) UnbindTags

func (t *TaskTpl) UnbindTags(tags []string) error

func (*TaskTpl) Update

func (t *TaskTpl) Update(hosts []string) error

func (*TaskTpl) UpdateGroup

func (t *TaskTpl) UpdateGroup(nodeId int64) error

type Team

type Team struct {
	Id          int64     `json:"id"`
	Ident       string    `json:"ident"`
	Name        string    `json:"name"`
	Note        string    `json:"note"`
	Mgmt        int       `json:"mgmt"`
	Creator     int64     `json:"creator"`
	LastUpdated time.Time `json:"last_updated" xorm:"<-"`
}

func AllTeams added in v4.0.2

func AllTeams() ([]Team, error)

func TeamGet

func TeamGet(where string, args ...interface{}) (*Team, error)

func TeamGetByIds

func TeamGetByIds(ids []int64) ([]Team, error)

func TeamGets

func TeamGets(query string, limit, offset int) ([]Team, error)

func TeamGetsInIds

func TeamGetsInIds(ids []int64, query string, limit, offset int) ([]Team, error)

func (*Team) BindUser

func (t *Team) BindUser(ids []int64, isadmin int) error

func (*Team) CheckFields

func (t *Team) CheckFields() error

func (*Team) Del

func (t *Team) Del() error

func (*Team) Modify

func (t *Team) Modify(name, note string, mgmt int) error

func (*Team) UnbindUser

func (t *Team) UnbindUser(ids []int64) error

func (*Team) Update

func (t *Team) Update(cols ...string) error

func (*Team) UsersGet

func (t *Team) UsersGet(query string, limit, offset int) ([]TeamMember, error)

UsersGet limit和offset没有用orm来拼接,是因为获取的list会莫名其妙变多

func (*Team) UsersTotal

func (t *Team) UsersTotal(query string) (int64, error)

type TeamMember

type TeamMember struct {
	Id       int64  `json:"id"`
	Username string `json:"username"`
	Dispname string `json:"dispname"`
	Phone    string `json:"phone"`
	Email    string `json:"email"`
	Im       string `json:"im"`
	IsRoot   int    `json:"is_root"`
	TeamId   int64  `json:"team_id"`
	IsAdmin  int    `json:"is_admin"`
}

type TeamUser

type TeamUser struct {
	TeamId  int64 `json:"team_id" xorm:"'team_id'"`
	UserId  int64 `json:"user_id" xorm:"'user_id'"`
	IsAdmin int   `json:"is_admin" xorm:"'is_admin'"`
}

func TeamUsers added in v4.0.2

func TeamUsers() ([]TeamUser, error)

type TmpChart

type TmpChart struct {
	Id      int64  `json:"id"`
	Configs string `json:"configs"`
	Creator string `json:"creator"`
}

func TmpChartGet

func TmpChartGet(col string, val interface{}) (*TmpChart, error)

func (*TmpChart) Add

func (t *TmpChart) Add() error

type Token

type Token struct {
	Id           int64  `json:"id,omitempty"`
	Name         string `json:"name,omitempty" description:"access token name"`
	AccessToken  string `json:"accessToken,omitempty"`
	RefreshToken string `json:"refreshToken,omitempty"`
	ClientId     string `json:"clientId,omitempty"`
	Authorize    string `json:"authorize,omitempty"`
	Previous     string `json:"previous,omitempty"`
	ExpiresIn    int64  `json:"expiresIn,omitempty" description:"max 3 year, default:0, max time"`
	Scope        string `json:"scope,omitempty" description:"scope split by ' '"`
	RedirectUri  string `json:"redirectUri,omitempty"`
	UserName     string `json:"userName,omitempty"`
	CreatedAt    int64  `json:"createdAt,omitempty" out:",date"`
	LastAt       int64  `json:"lastAt,omitempty" out:",date"`
}

func TokenGet

func TokenGet(token string) (*Token, error)

func TokenGets

func TokenGets(where string, args ...interface{}) (tokens []Token, err error)

func (*Token) Session

func (p *Token) Session() *Session

func (*Token) Update

func (p *Token) Update(cols ...string) error

type User

type User struct {
	Id           int64     `json:"id"`
	UUID         string    `json:"uuid" xorm:"'uuid'"`
	Username     string    `json:"username"`
	Password     string    `json:"-"`
	Passwords    string    `json:"-"`
	Dispname     string    `json:"dispname"`
	Phone        string    `json:"phone"`
	Email        string    `json:"email"`
	Im           string    `json:"im"`
	Portrait     string    `json:"portrait"`
	Intro        string    `json:"intro"`
	Organization string    `json:"organization"`
	Type         int       `json:"type" xorm:"'typ'" description:"0: long-term account; 1: temporary account"`
	Status       int       `json:"status" description:"0: active, 1: inactive, 2: locked, 3: frozen, 4: writen-off"`
	IsRoot       int       `json:"is_root"`
	LeaderId     int64     `json:"leader_id"`
	LeaderName   string    `json:"leader_name"`
	LoginErrNum  int       `json:"login_err_num"`
	ActiveBegin  int64     `json:"active_begin" description:"for temporary account"`
	ActiveEnd    int64     `json:"active_end" description:"for temporary account"`
	LockedAt     int64     `json:"locked_at" description:"locked time"`
	UpdatedAt    int64     `json:"updated_at" description:"user info change time"`
	PwdUpdatedAt int64     `json:"pwd_updated_at" description:"password change time"`
	PwdExpiresAt int64     `xorm:"-" json:"pwd_expires_at" description:"password expires time"`
	LoggedAt     int64     `json:"logged_at" description:"last logged time"`
	CreateAt     time.Time `json:"create_at" xorm:"<-"`
}

func AllUsers added in v4.0.2

func AllUsers() ([]User, error)

func EmailCodeLogin

func EmailCodeLogin(email, code string) (*User, error)

func LdapLogin

func LdapLogin(username, pass string) (*User, error)

func PassLogin

func PassLogin(username, pass string) (*User, error)

func SessionGetUserWithCache

func SessionGetUserWithCache(sid string) (*User, error)

func SmsCodeLogin

func SmsCodeLogin(phone, code string) (*User, error)

func TeamMembers

func TeamMembers(tid int64, isAdmin int) ([]User, error)

func UserAndTotalGets

func UserAndTotalGets(query, org string, conditions string, limit, offset int, ids []int64) ([]User, int64, error)

func UserGet

func UserGet(where string, args ...interface{}) (*User, error)

func UserGetByIds

func UserGetByIds(ids []int64) ([]User, error)

func UserGetByNames

func UserGetByNames(names []string) ([]User, error)

func UserGetByUUIDs

func UserGetByUUIDs(uuids []string) ([]User, error)

func UserGets

func UserGets(ids []int64, limit, offset int, where string, args ...interface{}) ([]User, error)

func UserGetsByIds

func UserGetsByIds(ids []int64) ([]User, error)

func UserMustGet

func UserMustGet(where string, args ...interface{}) (*User, error)

func UserSearchListInIds

func UserSearchListInIds(ids []int64, query string, limit, offset int) ([]User, error)

func UsersGet

func UsersGet(where string, args ...interface{}) ([]User, error)

func UsersGetByGlobalRoleIds

func UsersGetByGlobalRoleIds(ids []int64) (users []User, err error)

UsersGetByGlobalRoleIds 使用方:工单

func (*User) CanModifyTeam

func (u *User) CanModifyTeam(t *Team) (bool, error)

func (*User) CheckPermByNode

func (u *User) CheckPermByNode(node *Node, operation string)

func (*User) CheckPermGlobal

func (u *User) CheckPermGlobal(operation string)

func (*User) CopyLdapAttr

func (u *User) CopyLdapAttr(sr *ldap.SearchResult)

func (*User) Del

func (u *User) Del() error

func (*User) HasPermByNode

func (u *User) HasPermByNode(node *Node, operation string) (bool, error)

func (*User) HasPermGlobal

func (u *User) HasPermGlobal(operation string) (bool, error)

func (*User) IsRooter

func (u *User) IsRooter() bool

func (*User) NopriResIdents

func (u *User) NopriResIdents(resIds []int64, op string) ([]string, error)

NopriResIdents 我没有权限的资源ident列表

func (*User) PermByNode

func (u *User) PermByNode(node *Node, localOpsList []string) ([]string, error)

func (*User) PermResIds

func (u *User) PermResIds(operation string) ([]int64, error)

PermResIds 我在某些节点是管理员,或者我在某些节点有此权限点,获取下面的叶子节点挂载的资源列表

func (*User) Save

func (u *User) Save() error

func (*User) Update

func (u *User) Update(cols ...string) error

func (*User) Validate

func (u *User) Validate() error

type UserToken

type UserToken struct {
	UserId   int64  `json:"user_id"`
	Username string `json:"username"`
	Token    string `json:"token"`
}

func UserTokenGet

func UserTokenGet(where string, args ...interface{}) (*UserToken, error)

func UserTokenGets

func UserTokenGets(where string, args ...interface{}) ([]UserToken, error)

func UserTokenNew

func UserTokenNew(userId int64, username string) (*UserToken, error)

func UserTokenReset

func UserTokenReset(userId int64, token string) (*UserToken, error)

type WalkParams

type WalkParams struct {
	Version        int           `yaml:"version,omitempty"`
	MaxRepetitions uint8         `yaml:"max_repetitions,omitempty"`
	Retries        int           `yaml:"retries,omitempty"`
	Timeout        time.Duration `yaml:"timeout,omitempty"`
	Auth           Auth          `yaml:"auth,omitempty"`
}

type WhiteList

type WhiteList struct {
	Id         int64  `json:"id"`
	StartIp    string `json:"startIp"`
	StartIpInt int64  `json:"-"`
	EndIp      string `json:"endIp"`
	EndIpInt   int64  `json:"-"`
	StartTime  int64  `json:"startTime"`
	EndTime    int64  `json:"endTime"`
	CreatedAt  int64  `json:"createdAt"`
	UpdatedAt  int64  `json:"updateAt"`
	Creator    string `json:"creator"`
	Updater    string `json:"updater"`
}

func WhiteListGet

func WhiteListGet(where string, args ...interface{}) (*WhiteList, error)

func WhiteListGets

func WhiteListGets(query string, limit, offset int) ([]WhiteList, error)

func (*WhiteList) Del

func (p *WhiteList) Del() error

func (*WhiteList) Save

func (p *WhiteList) Save() error

func (*WhiteList) Update

func (p *WhiteList) Update(cols ...string) error

func (*WhiteList) Validate

func (p *WhiteList) Validate() error

Jump to

Keyboard shortcuts

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