-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jikun.zhang
committed
Mar 28, 2020
1 parent
d86ef6d
commit 7d69c72
Showing
21 changed files
with
442 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package controllers | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/astaxie/beego" | ||
"github.com/astaxie/beego/logs" | ||
) | ||
|
||
type ZabbixController struct { | ||
beego.Controller | ||
} | ||
|
||
type ZabbixMessage struct{ | ||
ZabbixTarget string `json:"zabbixtarget"` | ||
ZabbixMessage string `json:"zabbixmessage"` | ||
ZabbixType string `json:"zabbixtype"` | ||
} | ||
|
||
func (c *ZabbixController) ZabbixAlert() { | ||
alert:=ZabbixMessage{} | ||
logsign:="["+LogsSign()+"]" | ||
logs.Info(logsign,string(c.Ctx.Input.RequestBody)) | ||
json.Unmarshal(c.Ctx.Input.RequestBody, &alert) | ||
c.Data["json"]=SendMessageZabbix(alert,logsign) | ||
logs.Info(logsign,c.Data["json"]) | ||
c.ServeJSON() | ||
} | ||
func SendMessageZabbix(message ZabbixMessage,logsign string) (string){ | ||
ret:="" | ||
switch message.ZabbixType { | ||
case "wx": | ||
ret=PostToWeiXin(message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
case "dd": | ||
ret=PostToDingDing("Zabbix告警消息",message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
case "dx": | ||
ret=PostTXmessage(message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
ret=ret+PostHWmessage(message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
ret=ret+PostALYmessage(message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
case "dh": | ||
ret=PostTXphonecall(message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
ret=ret+PostALYphonecall(message.ZabbixMessage,message.ZabbixTarget,logsign) | ||
default: | ||
ret="参数错误" | ||
} | ||
return ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.