monitor.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. package monitor
  2. const (
  3. // RedisPrefix 参数:business。参数1:bid;参数2:监控ID
  4. RedisPrefix = "monitor_stats_%d"
  5. // RedisDelArcInfo 稿件删除监控key
  6. RedisDelArcInfo = "monitor_stats_del_arc"
  7. // BusVideo 视频业务
  8. BusVideo = 1
  9. // BusArc 稿件业务
  10. BusArc = 2
  11. // NotifyTypeEmail 邮件通知
  12. NotifyTypeEmail = 1
  13. // NotityTypeSms 短信通知
  14. NotityTypeSms = 2
  15. // 稿件业务常量
  16. // ArchiveBitPGC 稿件PGC属性位
  17. ArchiveBitPGC = 9
  18. // ArchiveStateDel 稿件删除状态
  19. ArchiveStateDel = -100
  20. // ArchiveOriginal 自制稿件
  21. ArchiveOriginal = 1
  22. // RuleHighUpDelArc 高能联盟UP主大量删除稿件监控
  23. RuleHighUpDelArc = 1
  24. // RuleFamUpDelArc 大UP主大量删除稿件监控
  25. RuleFamUpDelArc = 17
  26. // CompGT 大于
  27. CompGT = ">"
  28. // CompLT 小于
  29. CompLT = "<"
  30. // CompGET 大于等于
  31. CompGET = ">="
  32. // CompLET 小于等于
  33. CompLET = "<="
  34. // CompNE 不等于
  35. CompNE = "!="
  36. // CompE 等于
  37. CompE = "="
  38. )
  39. var (
  40. // SpecialTypeIDs 特殊分区(变更非常不频繁)
  41. SpecialTypeIDs = map[int64]int8{
  42. 15: 1, 34: 1, 32: 1, 82: 1, 33: 1, 83: 1, 145: 1, 146: 1,
  43. 147: 1, 153: 1, 185: 1, 186: 1, 187: 1, 37: 1, 178: 1, 179: 1,
  44. 180: 1, 128: 1, 85: 1, 86: 1, 183: 1,
  45. }
  46. )
  47. // BinlogArchive 稿件 binlog 结构
  48. type BinlogArchive struct {
  49. ID int64 `json:"id"`
  50. State int64 `json:"state"`
  51. Round int64 `json:"round"`
  52. MID int64 `json:"mid"`
  53. Attr int64 `json:"attribute"`
  54. TypeID int64 `json:"typeid"`
  55. IsSpecTID int8 `json:"is_special_tid"`
  56. HumanRank int `json:"humanrank"`
  57. Duration int `json:"duration"`
  58. Desc string `json:"desc"`
  59. Title string `json:"title"`
  60. Cover string `json:"cover"`
  61. Content string `json:"content"`
  62. Tag string `json:"tag"`
  63. Copyright int8 `json:"copyright"`
  64. AreaLimit int8 `json:"arealimit"`
  65. Author string `json:"author"`
  66. Access int `json:"access"`
  67. Forward int `json:"forward"`
  68. PubTime string `json:"pubtime"`
  69. Reason string `json:"reject_reason"`
  70. CTime string `json:"ctime"`
  71. MTime string `json:"mtime"`
  72. PTime string `json:"ptime"`
  73. Addit *ArchiveAddit `json:"_"`
  74. }
  75. // BinlogVideo 视频binlog结构
  76. type BinlogVideo struct {
  77. ID int64 `json:"id"`
  78. Filename string `json:"filename"`
  79. Cid int64 `json:"cid"`
  80. Aid int64 `json:"aid"`
  81. Title string `json:"eptitle"`
  82. Desc string `json:"description"`
  83. SrcType string `json:"src_type"`
  84. Duration int64 `json:"duration"`
  85. Filesize int64 `json:"filesize"`
  86. Resolutions string `json:"resolutions"`
  87. Playurl string `json:"playurl"`
  88. FailCode int8 `json:"failinfo"`
  89. Index int `json:"index_order"`
  90. Attribute int32 `json:"attribute"`
  91. XcodeState int8 `json:"xcode_state"`
  92. State int8 `json:"state"`
  93. Status int16 `json:"status"`
  94. CTime string `json:"ctime"`
  95. MTime string `json:"mtime"`
  96. }
  97. // ArchiveAddit 稿件附加属性
  98. type ArchiveAddit struct {
  99. Aid int64 `json:"aid"`
  100. MissionID int64 `json:"mission_id"`
  101. UpFrom int8 `json:"up_from"`
  102. FromIP int64 `json:"from_ip"`
  103. IPv6 []byte `json:"ipv6"`
  104. Source string `json:"source"`
  105. OrderID int64 `json:"order_id"`
  106. RecheckReason string `json:"recheck_reason"`
  107. RedirectURL string `json:"redirect_url"`
  108. FlowID int64 `json:"flow_id"`
  109. Advertiser string `json:"advertiser"`
  110. FlowRemark string `json:"flow_remark"`
  111. DescFormatID int64 `json:"desc_format_id"`
  112. Desc string `json:"desc"`
  113. Dynamic string `json:"dynamic"`
  114. }
  115. // RuleResultRes 监控结果
  116. type RuleResultRes struct {
  117. Code int `json:"code"`
  118. Data []*RuleResultData `json:"data"`
  119. }
  120. // RuleResultData 监控结果
  121. type RuleResultData struct {
  122. Rule *Rule `json:"rule"`
  123. Stats *Stats `json:"stats"`
  124. }
  125. // Rule 监控规则信息
  126. type Rule struct {
  127. ID int64 `json:"id"`
  128. Type int8 `json:"type"`
  129. BID int8 `json:"bid"`
  130. Name string `json:"name"`
  131. State int8 `json:"state"`
  132. STime string `json:"stime"`
  133. ETime string `json:"etime"`
  134. CTime string `json:"ctime"`
  135. MTime string `json:"mtime"`
  136. UID int64 `json:"uid"`
  137. RuleConf *RuleConf `json:"rule"`
  138. }
  139. // RuleConf 监控方案配置结构体
  140. type RuleConf struct {
  141. Name string `json:"name"`
  142. MoniCdt map[string]struct { //监控方案的监控条件
  143. Comp string `json:"comparison"`
  144. } `json:"moni_cdt"`
  145. NotifyCdt map[string]struct { //达到发送通知的条件
  146. Comp string `json:"comparison"`
  147. Value int64 `json:"value"`
  148. } `json:"notify_cdt"`
  149. Notify struct { //通知类型配置
  150. Way int8 `json:"way"`
  151. Member []string `json:"member"`
  152. } `json:"notify"`
  153. }
  154. // Stats 监控统计
  155. type Stats struct {
  156. TotalCount int `json:"total_count"`
  157. MoniCount int `json:"moni_count"`
  158. MaxTime int `json:"max_time"`
  159. }
  160. // FieldsConf 监控字段配置
  161. type FieldsConf struct {
  162. Comparison string
  163. }
  164. // DelArcInfo UP主删稿信息
  165. type DelArcInfo struct {
  166. AID int64 `json:"aid"`
  167. MID int64 `json:"mid"`
  168. Time string `json:"time"`
  169. Title string `json:"title"`
  170. }