Documentation
¶
Index ¶
- Variables
- type HttpResult
- type IMonitorManager
- type IMonitorResult
- type IMonitorTarget
- type MethodType
- type MonitorManager
- func (mm *MonitorManager) Add(new IMonitorTarget)
- func (mm *MonitorManager) CollectResult() []IMonitorResult
- func (mm *MonitorManager) CorrectCronTaskNumber() bool
- func (mm *MonitorManager) Delete(new IMonitorTarget)
- func (mm *MonitorManager) DisplayCronTask() string
- func (mm *MonitorManager) StartCron()
- func (mm *MonitorManager) StopCron()
- func (mm *MonitorManager) Update(news []IMonitorTarget)
- type MonitorTargetHttpGet
- func (mmht *MonitorTargetHttpGet) DisplayName() string
- func (mmht *MonitorTargetHttpGet) DisplayType() string
- func (mmht *MonitorTargetHttpGet) Execute() IMonitorResult
- func (mmht *MonitorTargetHttpGet) FromByteSlice(b []byte)
- func (mmht *MonitorTargetHttpGet) GetInterval() int64
- func (mmht *MonitorTargetHttpGet) GetSignature() string
- func (mmht *MonitorTargetHttpGet) GetTimeout() time.Duration
- func (mmht *MonitorTargetHttpGet) OnlyOneTarget() bool
- func (mmht *MonitorTargetHttpGet) String() string
- func (mmht *MonitorTargetHttpGet) ToByteSlice() []byte
- type ResultType
- type TargetEntry
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalMethodTypeMap = make(map[MethodType]interface{})
Functions ¶
This section is empty.
Types ¶
type HttpResult ¶
type HttpResult struct { Name string `json:"name"` Type ResultType `json:"type"` Host string `json:host` Succ bool `json:"succ"` Elapsed time.Duration `json:elapsed` Error string `json:error` StatusCode int `json:status_code` Created int64 `json:created` }
func (*HttpResult) DisplayName ¶
func (hr *HttpResult) DisplayName() string
func (*HttpResult) DisplayType ¶
func (hr *HttpResult) DisplayType() ResultType
func (*HttpResult) FromByteSlice ¶
func (hr *HttpResult) FromByteSlice(b []byte)
func (*HttpResult) String ¶
func (hr *HttpResult) String() string
func (*HttpResult) ToByteSlice ¶
func (hr *HttpResult) ToByteSlice() []byte
type IMonitorManager ¶
type IMonitorManager interface { //GetMonitorTagetByType(typeString string,b []byte) IMonitorTarget //加入map 并且加入map,并且加入定时任务 Add(new IMonitorTarget) Delete(new IMonitorTarget) Update(news []IMonitorTarget) //判断定时任务与实际中的是否相等 CorrectCronTaskNumber() bool DisplayCronTask() string //启动定时任务 StartCron() StopCron() CollectResult() []IMonitorResult }
type IMonitorResult ¶
type IMonitorResult interface { String() string ToByteSlice() []byte FromByteSlice(b []byte) DisplayType() ResultType DisplayName() string }
type IMonitorTarget ¶
type IMonitorTarget interface { DisplayType() string DisplayName() string Execute() IMonitorResult String() string ToByteSlice() []byte FromByteSlice(b []byte) GetSignature() string OnlyOneTarget() bool GetTimeout() time.Duration GetInterval() int64 }
func GetMonitorTagetByType ¶
func GetMonitorTagetByType(typeString string, b []byte) (IMonitorTarget, error)
type MethodType ¶
type MethodType string
//// http get target
const ( MethodHttpGet MethodType = "http-get" MethodHttpPost MethodType = "http-post" MethodTcp MethodType = "tcp" MethodUdp MethodType = "udp" MethodPing MethodType = "ping" MethodShortlink MethodType = "shortlink" )
加完这变还需要增加func.go GetMonitorTagetByType
type MonitorManager ¶
type MonitorManager struct { CronLock *sync.Mutex MapLock *sync.Mutex Crontab *cron.Cron TargetMap map[string]*TargetEntry ResultChan chan IMonitorResult ErrorChan chan error }
func NewMonitorManager ¶
func NewMonitorManager() *MonitorManager
func (*MonitorManager) Add ¶
func (mm *MonitorManager) Add(new IMonitorTarget)
func (*MonitorManager) CollectResult ¶
func (mm *MonitorManager) CollectResult() []IMonitorResult
func (*MonitorManager) CorrectCronTaskNumber ¶
func (mm *MonitorManager) CorrectCronTaskNumber() bool
func (*MonitorManager) Delete ¶
func (mm *MonitorManager) Delete(new IMonitorTarget)
func (*MonitorManager) DisplayCronTask ¶
func (mm *MonitorManager) DisplayCronTask() string
func (*MonitorManager) StartCron ¶
func (mm *MonitorManager) StartCron()
func (*MonitorManager) StopCron ¶
func (mm *MonitorManager) StopCron()
func (*MonitorManager) Update ¶
func (mm *MonitorManager) Update(news []IMonitorTarget)
type MonitorTargetHttpGet ¶
type MonitorTargetHttpGet struct { Name string `json:"name"` Type MethodType `json:"type"` Urls []string `json:"urls"` Headers map[string]interface{} `json:"headers"` Params map[string]interface{} `json:"params"` Timeout time.Duration `json:"timeout"` IntervalSecond int64 `json:"interval_second"` Created time.Time `json:"created"` }
func NewMonitorTargetHttpGet ¶
func (*MonitorTargetHttpGet) DisplayName ¶
func (mmht *MonitorTargetHttpGet) DisplayName() string
func (*MonitorTargetHttpGet) DisplayType ¶
func (mmht *MonitorTargetHttpGet) DisplayType() string
func (*MonitorTargetHttpGet) Execute ¶
func (mmht *MonitorTargetHttpGet) Execute() IMonitorResult
func (*MonitorTargetHttpGet) FromByteSlice ¶
func (mmht *MonitorTargetHttpGet) FromByteSlice(b []byte)
func (*MonitorTargetHttpGet) GetInterval ¶
func (mmht *MonitorTargetHttpGet) GetInterval() int64
func (*MonitorTargetHttpGet) GetSignature ¶
func (mmht *MonitorTargetHttpGet) GetSignature() string
func (*MonitorTargetHttpGet) GetTimeout ¶
func (mmht *MonitorTargetHttpGet) GetTimeout() time.Duration
func (*MonitorTargetHttpGet) OnlyOneTarget ¶
func (mmht *MonitorTargetHttpGet) OnlyOneTarget() bool
func (*MonitorTargetHttpGet) String ¶
func (mmht *MonitorTargetHttpGet) String() string
func (*MonitorTargetHttpGet) ToByteSlice ¶
func (mmht *MonitorTargetHttpGet) ToByteSlice() []byte
type ResultType ¶
type ResultType string
///http get result
const ( ResultHttpGet ResultType = "http-get" ResultHttpPost ResultType = "http-post" ResultTcp ResultType = "tcp" ResultUdp ResultType = "udp" ResultPing ResultType = "ping" ResultShortlink ResultType = "shortlink" )
type TargetEntry ¶
type TargetEntry struct { //Name string `json:"name"` //Md5 string `json:"md5"` Target IMonitorTarget `json:"target"` Running bool `json:"running"` CronTaskId cron.EntryID `json:"cron_task_id"` }
func NewTargetEntry ¶
func NewTargetEntry(target IMonitorTarget, running bool, cronTaskId cron.EntryID) *TargetEntry
Click to show internal directories.
Click to hide internal directories.