Openfalcon實現郵件報警
阿新 • • 發佈:2018-12-18
cd $GOPATH/src
mkdir github.com/open-falcon/ -p
cd github.com/open-falcon/
git clone https://github.com/open-falcon/mail-provider.git
cd mail-provider
go get ./...
./control build
編譯成功之後,修改cfg.json檔案相關資訊,使用
./control start
在cfg.json裡面使用的163郵箱的smtp服務,需要開啟客戶端授權碼,如果提示:傳送數量超過配額,請過24小時再請求手機驗證碼
使用curl命令,驗證是否能發郵件,返回success的話就是成功了
curl http://127.0.0.1:4000/sender/mail -d “tos=你的郵箱&subject=報警測試&content=這是一封測試郵件”
success
# set $GOPATH and $GOROOT mkdir -p $GOPATH/src/github.com/open-falcon cd $GOPATH/src/github.com/open-falcon git clone https://github.com/open-falcon/sender.git cd sender go get ./... ./control build # vi cfg.json modify configuration ./control start
將cfg.json中的配置改成 “mail”: “http://127.0.0.1:4000/sender/mail” 在open-falcon的portal的expression中配置報警表示式 each(metric= endpoint=) 記住配置報警接受人的組,這決定了誰的郵箱將會收到報警 模擬報警環境,然後將會收到郵件,同時在alarm-dashboard中也能看到報警 3.安裝mailsender https://github.com/niean/mailsender
cd /data/open-falcon-0.21/open-falcon/ wget https://github.com/niean/mailsender/releases/download/v0.0.1/tycs-mailsender-0.0.1.tar.gz tar -zxf tycs-mailsender.tar.gz mv cfg.example.json cfg.jsonvim cfg.json vim ./control start
vim /data/open-falcon-0.21/open-falcon/alarm/config/cfg.json “mail”:“http://ip:1986/mail/sender”