monitor.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package http
  2. import (
  3. "go-common/app/admin/main/aegis/model/monitor"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "strconv"
  8. )
  9. func monitorRuleResult(c *bm.Context) {
  10. var (
  11. err error
  12. bidStr string
  13. bid int64
  14. res []*monitor.RuleResultData
  15. )
  16. bidStr = c.Request.Form.Get("bid")
  17. if bid, err = strconv.ParseInt(bidStr, 10, 64); err != nil {
  18. c.JSON(nil, ecode.RequestErr)
  19. return
  20. }
  21. if bid == 0 {
  22. c.JSON(nil, ecode.RequestErr)
  23. return
  24. }
  25. if res, err = srv.MonitorBuzResult(c, bid); err != nil {
  26. log.Error("srv.MonitorResult(%d) error(%v)", bid, err)
  27. c.JSON(nil, ecode.RequestErr)
  28. return
  29. }
  30. c.JSON(res, nil)
  31. }
  32. func monitorResultOids(c *bm.Context) {
  33. var (
  34. err error
  35. idStr string
  36. id int64
  37. res []struct {
  38. OID int64 `json:"oid"`
  39. Time int `json:"time"`
  40. }
  41. oidMap map[int64]int
  42. )
  43. idStr = c.Request.Form.Get("id")
  44. if id, err = strconv.ParseInt(idStr, 10, 64); err != nil {
  45. c.JSON(nil, ecode.RequestErr)
  46. return
  47. }
  48. if id == 0 {
  49. c.JSON(nil, ecode.RequestErr)
  50. return
  51. }
  52. if oidMap, err = srv.MonitorResultOids(c, id); err != nil {
  53. log.Error("srv.MonitorResultOids(%d) error(%v)", id, err)
  54. c.JSON(nil, ecode.RequestErr)
  55. return
  56. }
  57. for k, v := range oidMap {
  58. res = append(res, struct {
  59. OID int64 `json:"oid"`
  60. Time int `json:"time"`
  61. }{OID: k, Time: v})
  62. }
  63. c.JSON(res, nil)
  64. }
  65. func monitorRuleUpdate(c *bm.Context) {
  66. }