Cacti配置Threshold(Thold)并e-mail報警
Cacti配置Threshold(Thold)并e-mail報警操作起來是比較簡單的!
Cacti的安裝各位google一下,這里就不詳細介紹了.
我的 cacti文件放在/web/c/cacti/
#打cacti-plugin-arch補丁
cd /root/install/cacti
wget http://cactiusers.org/downloads/cacti-plugin-arch.tar.gz
tar -xzvf cacti-plugin-arch.tar.gz
cp cacti-plugin-arch/cacti-plugin-0.8.7b-PA-v2.1.diff /web/c/cacti/
mysql -ucacti -pcactipw cacti < cacti-plugin-arch/pa.sql
cd /web/c/cacti/
patch -p1 -N < cacti-plugin-0.8.7b-PA-v2.1.diff
完成!
安裝settings插件
cd /root/install/cacti
wget http://mirror.cactiusers.org/downloads/plugins/settings-0.5.tar.gz
tar -xzvf settings-0.5.tar.gz
mv settings /web/c/cacti/plugins/
vi /web/c/cacti/include/global.php //添加插件信息$plugins[] = 'settings';
完成!
安裝Threshold插件
V0.3.9下載地址:http://mirror.cactiusers.org/downloads/plugins/thold-0.3.9.tar.gz
cd /root/install/cacti
wget http://mirror.cactiusers.org/downloads/plugins/thold-0.3.9.tar.gz
tar -xzvf thold-0.3.9.tar.gz
mv thold /web/c/cacti/plugins/
vi web/c/cacti/include/global.php
#---
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipw";
$database_port = "3306";
/* Default session name - Session name must contain alpha characters */
$cacti_session_name = "Cacti";
$plugins = array();
$plugins[] = 'settings';
$plugins[] = 'thold';
#---
設置數據庫信息以及插件.
mysql -ucacti -pcactipw cacti < /web/c/cacti/plugins/thold/thold.sql
完成!
安裝Threshold插件,只需將解壓出來的Thold目錄拷貝到cacti/plugins/目錄下,并修改cacti配置文件(cacti目錄下的include/config.php).在配置中查找$plugins = array();行,在此行下面加入:
$plugins[] = ‘thold’;
再導入數據庫.
刷新cacti首頁,你將看到多出來一個Threshld選項卡.如下所示

#p#
配置過程:
1.設置Threshold插件:選中console選項卡,在左側菜單中點擊Settings,然后點擊Alerting/Thold選項卡
2.設置發送警報通知:在Default Alerting Options中選擇Send notifications
3.設置出現down機的情況時(即Monitor出現如圖所示 )發送警報通知:選擇Dead Hosts notifications
報警郵件范例如下:
Host Error : 192.168.1.206 (192.168.1.206) is DOWN
Message : Host did not respond to SNMP (down機報警)
Host Notice : 192.168.1.207 (192.168.1.207) returned from DOWN state (恢復)
4.設置警報發送純文本的電子郵件沒有圖(默認是HTML電子郵件與圖表嵌入在電子郵件):選擇Send alerts as text
5.設置周末不執行報警檢查:選擇Weekend exemptions
6.設置報警的門檻:Default Trigger Count
7.設置Emailing Options
Mail Services:SMTP.(可以選擇PHP mail,sendmail,SMTP三種方式)
From Email Address:按實際設置
From Name:按需要設置(該處顯示的name就是email的發件人姓名)
8.進入Mail / DNS 標簽
設置Sendmail Options(Mail Services設置為sendmail需設置此項)
Sendmail Path:/usr/sbin/sendmail(路徑是服務器上Sendmail的,僅用于郵件服務選定為Sendmail)
9.設置SMTP Options(Mail Services設置SMTP需設置此項)
SMTP Hostname:SMTP服務器如:mail.test.com
SMTP Port:25
SMTP Username: 通過SMTP發送郵件用來驗證的用戶名,如果你不要求身份驗證留空
SMTP Password:通過SMTP發送郵件用來驗證的密碼,如果你不要求身份驗證留空

測試:點擊Send a Test Email,測試成功如下所示:
收到的測試郵件范例:
This is a test message generated from Cacti. This message was sent to test the configuration of your Mail Settings.
Your email settings are currently set as follows
Method: SMTP
Host: mail.xok.la
Port: 25
Authenication: true
Username: xok.la
Password: (Not Shown for Security Reasons)
配置完成后別忘記save.
下面我以進程報警為例,來設置具體的報警信息(CPU,DISK,服務,網絡等等)
在console選項卡下左側菜單中點擊Threshold Templates .

如果沒有出現Threshold Templates選項,那么有可能你還沒有導入插件的數據庫文件.
在如下圖所示中點擊Add按鈕來添加一個Threshold模板

添加進程監控的模板,無論是linux還是windows都是使用的Host MIB - Processes

可以選擇proc

我設置的300個***進程

Alert E-Mail 寫上通知的郵件地址即可.然后保存.
#p#
應用剛才創建的Threshold模板
在console選項卡下點擊Management ->Devices,選擇要應用此模板的Host,點擊最上面的Create Graphs for this Host鏈接,然后點擊Auto-create thresholds鏈接來應用剛創建的Threshold模板.
需要做的是,監控的主機要設置監控磁盤,如Associated Graph Templates ———- Host MIB - Processes 要選上,不然thold取不到數據的.
設置完成后在console選項卡下左側菜單中點擊Thresholds,在此可以管理已創建的警報,如下:

看第1條,Processes [proc] 300 ,超過300個進程數,出現紅色警告了,那我們去看他有沒有發信呢?

果然收到信件了…到此配置完成!
通過上面一步一步的安裝和配置,想必大家都學會了Cacti配置Threshold(Thold)并e-mail報警!
【編輯推薦】