monitor.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package monitor
  2. const (
  3. // RedisPrefix 参数:business。参数1:bid;参数2:监控ID
  4. RedisPrefix = "monitor_stats_%d"
  5. // CompGT 大于
  6. CompGT = ">"
  7. // CompLT 小于
  8. CompLT = "<"
  9. )
  10. // RuleResultData 返回的结果数据
  11. type RuleResultData struct {
  12. Rule *Rule `json:"rule"`
  13. User *User `json:"user"`
  14. Stats *Stats `json:"stats"`
  15. }
  16. // Rule 监控规则信息
  17. type Rule struct {
  18. ID int64 `json:"id"`
  19. Type int8 `json:"type"`
  20. BID int8 `json:"bid"`
  21. Name string `json:"name"`
  22. State int8 `json:"state"`
  23. STime string `json:"stime"`
  24. ETime string `json:"etime"`
  25. CTime string `json:"ctime"`
  26. MTime string `json:"mtime"`
  27. UID int64 `json:"uid"`
  28. RuleConf *RuleConf `json:"rule"`
  29. }
  30. // RuleConf 监控方案配置结构体
  31. type RuleConf struct {
  32. Name string `json:"name"`
  33. MoniCdt map[string]struct { //监控方案的监控条件
  34. Comp string `json:"comparison"`
  35. Value int64 `json:"value"`
  36. } `json:"moni_cdt"`
  37. NotifyCdt map[string]struct { //达到发送通知的条件
  38. Comp string `json:"comparison"`
  39. Value int64 `json:"value"`
  40. } `json:"notify_cdt"`
  41. Notify struct { //通知类型配置
  42. Way int8 `json:"way"`
  43. Member []string `json:"member"`
  44. } `json:"notify"`
  45. }
  46. // Stats 监控统计
  47. type Stats struct {
  48. TotalCount int `json:"total_count"`
  49. MoniCount int `json:"moni_count"`
  50. MaxTime int `json:"max_time"`
  51. }
  52. // User manager user struct
  53. type User struct {
  54. ID int64 `json:"id"`
  55. UserName string `json:"username"`
  56. NickName string `json:"nickname"`
  57. }