alarm_msg.go 722 B

12345678910111213141516171819202122232425262728
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "eta/eta_pub/utils"
  5. "github.com/rdlucklib/rdluck_tools/http"
  6. )
  7. // projectName-项目名称
  8. // runMode-运行模式
  9. // msgBody-消息内容
  10. // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
  11. func SendAlarmMsg(msgBody string, level int) {
  12. if utils.AlarmMsgUrl == "" {
  13. return
  14. }
  15. params := make(map[string]interface{})
  16. params["ProjectName"] = utils.APPNAME
  17. params["RunMode"] = utils.RunMode
  18. params["MsgBody"] = msgBody
  19. params["Level"] = level
  20. param, err := json.Marshal(params)
  21. if err != nil {
  22. utils.FileLog.Info("SendAlarmMsg json.Marshal Err:" + err.Error())
  23. return
  24. }
  25. http.Post(utils.AlarmMsgUrl, string(param))
  26. }