添加设备监控,第一次上线邮件提醒
This commit is contained in:
parent
d618cf0332
commit
369264e695
|
|
@ -75,6 +75,13 @@ func SetDeviceStatusV2(c *gin.Context) {
|
||||||
for _, v := range devices {
|
for _, v := range devices {
|
||||||
if v == req.ID {
|
if v == req.ID {
|
||||||
// 继续处理请求
|
// 继续处理请求
|
||||||
|
//是否是暂停之后第一次上线,如果是则发送邮件通知
|
||||||
|
if worker.IsContainKey("monitor_"+req.ID) == false {
|
||||||
|
//发送邮件通知
|
||||||
|
title := "设备上线"
|
||||||
|
content := "设备上线\n设备:" + req.ID + "\t状态:" + req.Status + "\t时间:" + time.Now().String()
|
||||||
|
go SendMail(title, content)
|
||||||
|
}
|
||||||
worker.SetRedisWithExpire("monitor_"+req.ID, "1", time.Second*300)
|
worker.SetRedisWithExpire("monitor_"+req.ID, "1", time.Second*300)
|
||||||
c.JSON(200, gin.H{"code": 0, "message": "success"})
|
c.JSON(200, gin.H{"code": 0, "message": "success"})
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue