Cacti配置Threshold(Thold)并e-mail報(bào)警
Cacti配置Threshold(Thold)并e-mail報(bào)警操作起來(lái)是比較簡(jiǎn)單的!
Cacti的安裝各位google一下,這里就不詳細(xì)介紹了.
我的 cacti文件放在/web/c/cacti/
#打cacti-plugin-arch補(bǔ)丁
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';
#---
設(shè)置數(shù)據(jù)庫(kù)信息以及插件.
mysql -ucacti -pcactipw cacti < /web/c/cacti/plugins/thold/thold.sql
完成!
安裝Threshold插件,只需將解壓出來(lái)的Thold目錄拷貝到cacti/plugins/目錄下,并修改cacti配置文件(cacti目錄下的include/config.php).在配置中查找$plugins = array();行,在此行下面加入:
$plugins[] = ‘thold’;
再導(dǎo)入數(shù)據(jù)庫(kù).
刷新cacti首頁(yè),你將看到多出來(lái)一個(gè)Threshld選項(xiàng)卡.如下所示

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

測(cè)試:點(diǎn)擊Send a Test Email,測(cè)試成功如下所示:
收到的測(cè)試郵件范例:
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.
下面我以進(jìn)程報(bào)警為例,來(lái)設(shè)置具體的報(bào)警信息(CPU,DISK,服務(wù),網(wǎng)絡(luò)等等)
在console選項(xiàng)卡下左側(cè)菜單中點(diǎn)擊Threshold Templates .

如果沒(méi)有出現(xiàn)Threshold Templates選項(xiàng),那么有可能你還沒(méi)有導(dǎo)入插件的數(shù)據(jù)庫(kù)文件.
在如下圖所示中點(diǎn)擊Add按鈕來(lái)添加一個(gè)Threshold模板

添加進(jìn)程監(jiān)控的模板,無(wú)論是linux還是windows都是使用的Host MIB - Processes

可以選擇proc

我設(shè)置的300個(gè)***進(jìn)程

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

看第1條,Processes [proc] 300 ,超過(guò)300個(gè)進(jìn)程數(shù),出現(xiàn)紅色警告了,那我們?nèi)タ此袥](méi)有發(fā)信呢?

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