本文是在windows系統用bat方式實現微信告警,Linux系統用shell方式實現微信告警請點擊此處
1.首先下載curl工具,並配置環境變量
https://www.wgstart.com/help/docs8.html
2.首先下載微信發送消息工具wgcloud-weixin-release.exe,下載后和server放到同一個主機上,運行即可,不要關閉,因為bat會調用這個服務
3.首先我們要去注冊企業微信了,然后創建一個應用,記得以下圖片中的標紅信息,企業ID,應用ID,應用Secret
4.新建一個sendMsg_weixin.bat文件,此處目錄和文件名稱是為測試方便,自己可以根據實際場景自定義,內容如下
@echo off echo warn content is : %1 set timeHour=%time:~0,2% set timeMin=%time:~3,2% set timeSec=%time:~6,2% set content="WGCLOUD: %timeHour%:%timeMin%:%timeSec%,%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="微信企業ID" set secret="微信企業應用Secret" set appID=1000002 set userID="部門成員id,微信接收者,多個接收者用逗號,隔開" 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%
appId為企業號中的應用id
部門成員ID查看方式如下圖,鼠標放在成員名字上即可看到賬號,即是成員ID
5.cli 測試
6.測試完成,修改/server/config/application.yml
#告警腳本文件,可以為空,參考:/server/template/sendMsg.sh warnScript: d:\sendMsg_weixin.bat
7.好了,重啟server,這樣就可以在微信收到告警消息了