alarm_msg.go 747 B

1234567891011121314151617181920212223242526272829
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "eta/eta_data_analysis/utils"
  5. "github.com/rdlucklib/rdluck_tools/http"
  6. )
  7. var (
  8. AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
  9. )
  10. // projectName-项目名称
  11. // runMode-运行模式
  12. // msgBody-消息内容
  13. // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
  14. func SendAlarmMsg(msgBody string, level int) {
  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(AlarmMsgUrl, string(param))
  26. }