1.請安裝好Go的環境,參考上一篇open-falcon的安裝博文
2.安裝 mail-provider
https://github.com/open-falcon/mail-provider
安裝方法
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
3.安裝 sender
https://github.com/open-falcon-archive/sender
編譯和安裝
# 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"
4.在open-falcon的portal的expression中配置報警表達式,如下圖
記住配置報警接受人的組,這決定了誰的郵箱將會收到報警
5.模擬報警環境,然后將會收到郵件,同時在alarm-dashboard中也能看到報警