Documentation ¶
Index ¶
- Constants
- Variables
- func AppendResources(rsByte []byte, rs ...Resource) ([]byte, error)
- func DeleteResource(rsByte []byte, IDs ...string) ([]byte, error)
- func GenCollectName(res Resource) string
- func GetResNameFromMeasurements(measurements []string) ([]string, bool)
- func UpdateCollectName(collects ...Resource) error
- func UpdateResByID(rsByte []byte, ID string, updateMap map[string]string) ([]byte, error)
- type AlarmResource
- func (a *AlarmResource) DisableSelf()
- func (a *AlarmResource) EnableSelf()
- func (a *AlarmResource) SetAlert(level, groups, alert, message string) error
- func (a *AlarmResource) SetBlock(data Resource)
- func (a *AlarmResource) SetID(id string)
- func (a *AlarmResource) SetMD5AndVersion() error
- func (a *AlarmResource) SetQuery(...) error
- type Dashboard
- type DashboardData
- type HandleFunc
- type Panel
- type Report
- type ResAction
- type Resource
- func (r *Resource) ID() (string, bool)
- func (r *Resource) InitID() string
- func (r *Resource) Marshal() ([]byte, error)
- func (r *Resource) NewID() string
- func (r *Resource) ReadProperty(key string) (string, bool)
- func (r *Resource) SetProperty(k, v string)
- func (r *Resource) Size() int
- func (r *Resource) Unmarshal(raw []byte) error
- type ResourceList
- func (rl *ResourceList) AppendResource(r ...Resource)
- func (rl *ResourceList) AppendResourceByte(resByte []byte) error
- func (rl *ResourceList) AppendResources(res ResourceList)
- func (rl *ResourceList) Get(propertyK string, ValueList ...string) ([]Resource, error)
- func (rl *ResourceList) Marshal() ([]byte, error)
- func (rl *ResourceList) Size() int
- func (rl *ResourceList) Unmarshal(raw []byte) error
- func (rl *ResourceList) WalkRsByte(rsByte []byte, handler walkResourceFunc) ([]byte, error)
- type ResourceSearch
- type Row
- type Target
Constants ¶
const ( IdKey = "_id" Prefix int = iota Surffix )
Variables ¶
var ( ProcCollect = "PROC" PluginCollect = "PLUGIN" PortCollect = "PORT" ApiCollect = "API" RunPrefix = "RUN" RunType = []string{ApiCollect} )
var ( HostnameProp = "hostname" HostStatusProp = "status" IpProp = "ip" Online = "online" Offline = "offline" Dead = "dead" )
var ( ErrResMarshal error = errors.New("marshal resources fail") ErrResFormat error = errors.New("invalid resource format") ErrInvalidParam error = errors.New("invalid param") ErrInvalidUUID error = errors.New("invalid uuid") )
var ( Machine = "machine" Collect = "collect" Alarm = "alarm" Deploy = "deploy" Templates []string = []string{ Machine, Alarm, Collect, } PkProperty = map[string]string{ Machine: "hostname", Collect: "name", Alarm: "name", Deploy: "name", } TemplatePrefix string = "_template_" TemplateCollectNum int = len(collectTemplate) )
var LogBackend *log.FileBackend
log file backend
var (
RootTemplate map[string]ResourceList
)
Functions ¶
func AppendResources ¶
ResourcesAppendByte append the resource to resources.
func DeleteResource ¶
Delete resource by resourceID..
func GenCollectName ¶
func GetResNameFromMeasurements ¶
GetNameFromMeasurements get the resource names of the measurements. PROC.bin.cpu.idle -> PROC.bin PLUGIN.name.cpu.idle -> PLUGIN.name PORT.service.xx -> PORT.service.xx RUN.API.Ping.xx -> Run.API.Ping.xx
func UpdateCollectName ¶
Types ¶
type AlarmResource ¶
func NewAlarm ¶
func NewAlarm(ns, name string) *AlarmResource
func NewAlarmByRes ¶
func NewAlarmByRes(ns string, data Resource, ID string) (*AlarmResource, error)
func (*AlarmResource) DisableSelf ¶
func (a *AlarmResource) DisableSelf()
func (*AlarmResource) EnableSelf ¶
func (a *AlarmResource) EnableSelf()
func (*AlarmResource) SetAlert ¶
func (a *AlarmResource) SetAlert(level, groups, alert, message string) error
func (*AlarmResource) SetBlock ¶
func (a *AlarmResource) SetBlock(data Resource)
func (*AlarmResource) SetID ¶
func (a *AlarmResource) SetID(id string)
func (*AlarmResource) SetMD5AndVersion ¶
func (a *AlarmResource) SetMD5AndVersion() error
func (*AlarmResource) SetQuery ¶
func (a *AlarmResource) SetQuery(function, rp, measurement, period, where, expression, every, groupby, trigger, shift, value, stime, etime string) error
type DashboardData ¶
type DashboardData []Dashboard
type HandleFunc ¶
type HandleFunc func(raw []byte) (ResourceList, error)
type Resource ¶
func GetAlarmFromCollect ¶
func NewAlarmResourceByMap ¶
func NewResource ¶
func TransAlarmToResource ¶
func TransAlarmToResource(alarm AlarmResource) (Resource, error)
func (*Resource) Marshal ¶
Marshal will create UUID if the resource have no ID. Return the resource []byte/ID.
func (*Resource) ReadProperty ¶
ReadProperty return property value value of key.
func (*Resource) SetProperty ¶
SetProperty set the k-v to resource.
type ResourceList ¶
type ResourceList []Resource
func NewResourceList ¶
func NewResourceList(resMaps []map[string]string) (*ResourceList, error)
func (*ResourceList) AppendResource ¶
func (rl *ResourceList) AppendResource(r ...Resource)
func (*ResourceList) AppendResourceByte ¶
func (rl *ResourceList) AppendResourceByte(resByte []byte) error
func (*ResourceList) AppendResources ¶
func (rl *ResourceList) AppendResources(res ResourceList)
func (*ResourceList) Get ¶
func (rl *ResourceList) Get(propertyK string, ValueList ...string) ([]Resource, error)
Get multi resource from rl by reousrce property. And Get resource by resource ID, if k is IdKey.
func (*ResourceList) Marshal ¶
func (rl *ResourceList) Marshal() ([]byte, error)
Marshal returns the byte format data of Resources.
func (*ResourceList) Unmarshal ¶
func (rl *ResourceList) Unmarshal(raw []byte) error
Unmarshal the byte to the method caller rs.
func (*ResourceList) WalkRsByte ¶
func (rl *ResourceList) WalkRsByte(rsByte []byte, handler walkResourceFunc) ([]byte, error)
walk the resources byte, process every resource by handler.
type ResourceSearch ¶
type ResourceSearch struct { Id string // key of resource property Key string // search string Value []string // match prefix or Surffix Fuzzy bool Process HandleFunc }
func (*ResourceSearch) IdSearch ¶
func (s *ResourceSearch) IdSearch(raw []byte) (ResourceList, error)
func (*ResourceSearch) Init ¶
func (s *ResourceSearch) Init() error
func (*ResourceSearch) ValueSearch ¶
func (s *ResourceSearch) ValueSearch(raw []byte) (ResourceList, error)