package alarm_msg import ( "encoding/json" "github.com/rdlucklib/rdluck_tools/http" "hongze/hongze_task/utils" ) var ( AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send" ) // projectName-项目名称 // runMode-运行模式 // msgBody-消息内容 // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息 func SendAlarmMsg(msgBody string, level int) { params := make(map[string]interface{}) params["ProjectName"] = utils.APPNAME params["RunMode"] = utils.RunMode params["MsgBody"] = msgBody params["Level"] = level param, err := json.Marshal(params) if err != nil { utils.FileLog.Info("SendAlarmMsg json.Marshal Err:" + err.Error()) return } http.Post(AlarmMsgUrl, string(param), "application/json") } // SendAlarmMsgWithEmail 指定邮箱通知 // projectName-项目名称 // runMode-运行模式 // msgBody-消息内容 // email-需要发送的邮箱 // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息 func SendAlarmMsgWithEmail(msgBody, email string, level int) { params := make(map[string]interface{}) params["ProjectName"] = utils.APPNAME params["RunMode"] = utils.RunMode params["MsgBody"] = msgBody params["Email"] = email params["Level"] = level param, err := json.Marshal(params) if err != nil { utils.FileLog.Info("SendAlarmMsg json.Marshal Err:" + err.Error()) return } http.Post(AlarmMsgUrl, string(param), "application/json") }