server_check.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package data
  2. import (
  3. "context"
  4. "eta/eta_task/services/alarm_msg"
  5. "eta/eta_task/utils"
  6. "fmt"
  7. "github.com/rdlucklib/rdluck_tools/http"
  8. "strings"
  9. )
  10. //服务检测
  11. // CheckWindDataInterface 检测wind数据服务器
  12. func CheckWindDataInterface(cont context.Context) (err error) {
  13. if utils.WindServerUrl != "" {
  14. windServerUrlArr := strings.Split(utils.WindServerUrl, ",")
  15. for _, hzDataWindUrl := range windServerUrlArr {
  16. go func(urlStr string) {
  17. checkUrl := urlStr + `hz_server`
  18. body, err := http.Get(checkUrl)
  19. if err != nil {
  20. msg := fmt.Sprintf("检测:%s ;失败:CheckWindDataInterface ErrMsg:%s", checkUrl, err.Error())
  21. go alarm_msg.SendAlarmMsg(msg, 3)
  22. } else {
  23. result := string(body)
  24. if result != `1` {
  25. msg := fmt.Sprintf("检测%s ;失败:CheckWindDataInterface ErrMsg:%s", checkUrl, string(body))
  26. go alarm_msg.SendAlarmMsg(msg, 3)
  27. }
  28. }
  29. }(hzDataWindUrl)
  30. }
  31. }
  32. return
  33. }
  34. // CheckLtDataInterface 检测路透数据服务器
  35. func CheckLtDataInterface(cont context.Context) (err error) {
  36. if utils.LtServerUrl != "" {
  37. go func() {
  38. checkUrl := utils.LtServerUrl + `hz_server`
  39. body, err := http.Get(checkUrl)
  40. if err != nil {
  41. msg := "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:" + err.Error()
  42. go alarm_msg.SendAlarmMsg(msg, 3)
  43. } else {
  44. result := string(body)
  45. if result != `"ek true"` {
  46. msg := "检测路透数据服务器失败:CheckLtDataInterface ErrMsg:" + string(body)
  47. go alarm_msg.SendAlarmMsg(msg, 3)
  48. }
  49. }
  50. }()
  51. }
  52. return
  53. }
  54. func CheckPbDataInterface(cont context.Context) (err error) {
  55. if utils.PbServerUrl != "" {
  56. go func() {
  57. checkUrl := utils.PbServerUrl + `hz_server`
  58. body, err := http.Get(checkUrl)
  59. if err != nil {
  60. msg := "检测彭博数据服务器失败:CheckPbDataInterface ErrMsg:" + err.Error()
  61. go alarm_msg.SendAlarmMsg(msg, 3)
  62. } else {
  63. result := string(body)
  64. if result != "1" {
  65. msg := "检测彭博数据服务器失败:CheckPbDataInterface ErrMsg:" + string(body)
  66. go alarm_msg.SendAlarmMsg(msg, 3)
  67. }
  68. }
  69. }()
  70. }
  71. return
  72. }