alarm_msg.go 865 B

123456789101112131415161718192021222324252627282930313233
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongqi_watch/global"
  6. "hongze/hongqi_watch/utils"
  7. "github.com/rdlucklib/rdluck_tools/http"
  8. )
  9. var (
  10. AlarmMsgUrl = "http://47.102.213.75:8606/api/alarm/send"
  11. )
  12. // projectName-项目名称
  13. // runMode-运行模式
  14. // msgBody-消息内容
  15. // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
  16. func SendAlarmMsg(msgBody string, level int) {
  17. params := make(map[string]interface{})
  18. params["ProjectName"] = utils.APPNAME
  19. params["RunMode"] = "release" //global.CONFIG.Serve.RunMode
  20. params["MsgBody"] = msgBody
  21. params["Level"] = level
  22. param, err := json.Marshal(params)
  23. if err != nil {
  24. global.LOG.Critical("SendAlarmMsg json.Marshal Err:" + err.Error())
  25. return
  26. }
  27. r, e := http.Post(AlarmMsgUrl, string(param))
  28. fmt.Println("SendAlarmMsg", string(r), e)
  29. }