好吧,我認可官網的郵件配置教程我又沒看懂,這裏記錄下個人配置方法php
[root@HE3]# vi /usr/local/lepus/test_send_mail.pypython
#!/usr/bin/envpython # -*- coding: utf8-*- from datetime import* import sys path='./include' sys.path.insert(0,path) import functions asfunc #mail_to_list = func.get_option('mail_to_list') send_mail_to_list =func.get_option('send_mail_to_list') mailto_list=send_mail_to_list.split(';') result =func.send_mail(mailto_list," I hope you can learn","BeautifulDay") print result if result: send_mail_status = "success" else: send_mail_status = "fail" print"send_mail_status:"+send_mail_status
註釋掉原有的mail_to_list,添加一行send_mail_to_list =func.get_option('send_mail_to_list')mysql
原有的mailto_list=mail_to_list.split(';')改成mailto_list=send_mail_to_list.split(';')web
去申請一個新的126郵箱,選擇設置-POP3/SMTP/IMAP-客戶端受權密碼sql
1處填寫你剛剛申請的126郵箱帳號bash
2處填寫你剛剛開啓的客戶端受權密碼ide
3處填寫你的126郵箱地址測試
[root@HE3]# python test_send_mail.py True send_mail_status:success
編譯經過spa
OK,turn on your lepus alert button!~ 適當調低報警閾值,不出10s,你的收件箱應該就收到告警郵件了~blog
------------------------------慢查詢推送配置-------------------------
[root@HE3 lepus]# yum install links [root@HE3 lepus]# links http://mysqlmtop1.ikongjian.com/index.php/task/send_mysql_slowquery_mail
執行上述命令進行測試,這裏的web的頁面是你本身的監控頁面地址請勿直接複製
而後將該命令加入執行計劃便可
00 08 * * * links http://mysqlmtop1.ikongjian.com/index.php/task/send_mysql_slowquery_mail > /dev/null 2>&1