alarm_msg.go 819 B

12345678910111213141516171819202122232425262728293031
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "eta/eta_email_analysis/global"
  5. "eta/eta_email_analysis/utils"
  6. "github.com/rdlucklib/rdluck_tools/http"
  7. )
  8. var (
  9. AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
  10. )
  11. // SendAlarmMsg
  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"] = 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. _, _ = http.Post(AlarmMsgUrl, string(param))
  28. }