本文是在windows系統(tǒng)用bat方式實(shí)現(xiàn)微信告警,Linux系統(tǒng)用shell方式實(shí)現(xiàn)微信告警請(qǐng)點(diǎn)擊此處查看
1.首先下載curl工具,并配置環(huán)境變量
https://www.wgstart.com/help/docs8.html
2.首先下載微信發(fā)送消息工具wgcloud-weixin-release.exe案疲,下載后和server放到同一個(gè)主機(jī)上枫匾,運(yùn)行即可管钳,不要關(guān)閉,因?yàn)閎at會(huì)調(diào)用這個(gè)服務(wù)
3.首先我們要去注冊(cè)企業(yè)微信了婉烟,然后創(chuàng)建一個(gè)應(yīng)用鼻弧,記得以下圖片中的標(biāo)紅信息设江,企業(yè)ID锦茁,應(yīng)用ID攘轩,應(yīng)用Secret
4.新建一個(gè)sendMsg_weixin.bat文件,此處目錄和文件名稱是為測(cè)試方便码俩,自己可以根據(jù)實(shí)際場(chǎng)景自定義度帮,內(nèi)容如下
@echo off
echo warn content is : %1
set content="WGCLOUD告警:%1"
set content=%content:"=%
echo %content% > d:/sendMsg.txt
native2ascii d:/sendMsg.txt d:/sendMsg_unicode.txt
set /p content_unicode=<d:/sendMsg_unicode.txt
echo %content_unicode%
set cropID="微信企業(yè)ID"
set secret="微信企業(yè)應(yīng)用Secret"
set appID=1000002
set userID="部門成員id,微信接收者稿存,多個(gè)接收者用逗號(hào),隔開"
set ding_url="http://localhost:10000/wx"
curl -H "Content-Type: application/json" -d "{\"content\":\"%content_unicode%\",\"cropID\":\"%cropID%\",\"secret\":\"%secret%\",\"appID\":%appID%,\"userID\":\"%userID%\"}" -s %ding_url%
部門成員ID查看方式如下圖笨篷,鼠標(biāo)放在成員名字上即可看到賬號(hào),即是成員ID
5.cli 測(cè)試
6.測(cè)試完成瓣履,修改/server/config/application.yml率翅,告警腳本文件,可以為空袖迎,參考:/server/template/sendMsg.sh
warnScript: d:\sendMsg_weixin.bat
7.好了冕臭,重啟server,這樣就可以在微信收到告警消息了