monitor.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package monitor
  2. const (
  3. // RedisPrefix 参数:business。
  4. RedisPrefix = "monitor_stats_%d_"
  5. // SuffixVideo 视频停留统计。参数:state
  6. SuffixVideo = "%d"
  7. // SuffixArc 稿件停留统计。参数:round。参数:state。
  8. SuffixArc = "%d_%d"
  9. BusVideo = 1
  10. BusArc = 2
  11. NotifyTypeEmail = 1
  12. NotityTypeSms = 2
  13. RuleStateOK = 1
  14. RuleStateDisable = 0
  15. )
  16. type RuleResultRes struct {
  17. Code int `json:"code"`
  18. Data []*RuleResultData `json:"data"`
  19. }
  20. type RuleResultData struct {
  21. Rule *Rule `json:"rule"`
  22. Stats *Stats `json:"stats"`
  23. }
  24. // Rule 监控规则信息
  25. type Rule struct {
  26. ID int64 `json:"id"`
  27. Type int8 `json:"type"`
  28. Business int8 `json:"business"`
  29. Name string `json:"name"`
  30. State int8 `json:"state"`
  31. STime string `json:"s_time"`
  32. ETime string `json:"e_time"`
  33. RuleConf *RuleConf `json:"rule_conf"`
  34. }
  35. // RuleConf 监控方案配置结构体
  36. type RuleConf struct {
  37. Name string `json:"name"`
  38. MoniCdt map[string]struct { //监控方案的监控条件
  39. Comp string `json:"comparison"`
  40. Value int64 `json:"value"`
  41. } `json:"moni_cdt"`
  42. NotifyCdt map[string]struct { //达到发送通知的条件
  43. Comp string `json:"comparison"`
  44. Value int64 `json:"value"`
  45. } `json:"notify_cdt"`
  46. Notify struct { //通知类型配置
  47. Way int8 `json:"way"`
  48. Member []string `json:"member"`
  49. } `json:"notify"`
  50. }
  51. type Stats struct {
  52. TotalCount int `json:"total_count"`
  53. MoniCount int `json:"moni_count"`
  54. MaxTime int `json:"max_time"`
  55. }