前情提要:郵件伺服器Part-2:MailScanner+ClamAV+SpamAssassin
系統使用CentOS 5.1
郵件伺服器全系列:Postfix+Dovecot+SASL+Procmail+Postgrey+Mailscanner+Spamassassin+ClamAV+Mailscanner-mrtg+MailWatch+Openwebmail+MySPAM
郵件伺服器全系列:Postfix+Dovecot+SASL+Procmail+Postgrey+Mailscanner+Spamassassin+ClamAV+Mailscanner-mrtg+MailWatch+Openwebmail+MySPAM
Mailscanner-mrtg可偵測伺服器各項資源、效能並產生紀錄網頁
1.安裝SNMP
yum -y install net-snmp net-snmp-utils
2.SNMP的設定
vim /etc/snmp/snmpd.conf
com2sec local localhost public
com2sec mynetwork 192.168.0.0/24 public
group MyRWGroup v1 local
group MyROGroup v1 mynetwork
group MyRWGroup v2c local
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80
access MyROGroup "" any noauth prefix all none none
access MyRWGroup "" any noauth prefix all all all
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
com2sec mynetwork 192.168.0.0/24 public
group MyRWGroup v1 local
group MyROGroup v1 mynetwork
group MyRWGroup v2c local
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80
access MyROGroup "" any noauth prefix all none none
access MyRWGroup "" any noauth prefix all all all
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
3.啟動SNMP
/etc/rc.d/init.d/snmpd start
chkconfig snmpd on
chkconfig --list snmpd
chkconfig snmpd on
chkconfig --list snmpd
4.安裝MRTG
yum -y install mrtg
5.安裝Mailscanner-MRTG
下載http://sourceforge.net/project/showfiles.php?group_id=68848
rpm -ivh mailscanner-mrtg-0.10.00-1.noarch.rpm
6.修改Mailscanner-MRTG設定
vim /etc/MailScanner/mailscanner-mrtg.conf
修改下列參數:
MTA = postfix (設定使用的MTA)
Incoming Queue Dir = /var/spool/postfix/hold (收信佇列目錄)
Outgoing Queue Dir = /var/spool/postfix/incoming (寄信佇列目錄)
MailScanner Work Directory = /var/spool/MailScanner/incoming (MailScanner目錄)
Spool Directory = /var/spool/mailscanner-mrtg (MailScanner-mrtg目錄)
# MailScanner Work Directory及Spool Directory是使用df指令來取得磁碟空間,如果沒有獨立的分割區,可以直接改成/var
Use SNMP = yes (使用SNMP)
SNMP Community = public (SNMP設定)
#CPU負載、記憶體用量、網路流量需要使用SNMP
Incoming Queue Dir = /var/spool/postfix/hold (收信佇列目錄)
Outgoing Queue Dir = /var/spool/postfix/incoming (寄信佇列目錄)
MailScanner Work Directory = /var/spool/MailScanner/incoming (MailScanner目錄)
Spool Directory = /var/spool/mailscanner-mrtg (MailScanner-mrtg目錄)
# MailScanner Work Directory及Spool Directory是使用df指令來取得磁碟空間,如果沒有獨立的分割區,可以直接改成/var
Use SNMP = yes (使用SNMP)
SNMP Community = public (SNMP設定)
#CPU負載、記憶體用量、網路流量需要使用SNMP
vim /etc/mrtg/mailscanner-mrtg.cfg
Workdir: /var/www/html/mailscanner-mrtg (Mailscanner-MRTG網頁目錄)
IconDir: /mrtg/
WriteExpires: Yes
Interval: 5
Refresh: 300
Language: big5 (設定網頁使用的語系)
IconDir: /mrtg/
WriteExpires: Yes
Interval: 5
Refresh: 300
Language: big5 (設定網頁使用的語系)
7.產生index.html網頁
indexmaker --output=/var/www/html/mailscanner-mrtg/index.html /etc/mrtg/mailscanner-mrtg.cfg
8.測試參數檔
mrtg /etc/mrtg/mailscanner-mrtg.cfg
需重覆執行到沒有錯誤,如超過三次請檢查設定檔
9.完成後可以在以下看到流量:
備註:
◎如MRTG的圖示無法顯示,請修改httpd設定
vim /etc/httpd/conf.d/mrtg.conf
Allow from localhost改成Allow from all
◎如要記錄MailScanner處理速度(Processing Speed),需修改MailScanner設定
vim /etc/MailScanner/MailScanner.conf
Log Speed = yes
下集預告:郵件伺服器 Part-4:MailWatch
7 意見:
你好:
如果我有兩段網段同時使用,例如:
192.168.1.0/24
192.168.2.0/24
那麼snmpd.conf中的network要如何設定呢?謝謝.
com2sec mynetwork 192.168.0.0/24 public
改成
com2sec mynetwork 192.168.0.0/16 public
就可以了
將 c class 改成 b class
會不會造成廣播封包大增呢?謝謝。
那你可以改成
com2sec mynetwork 192.168.0.0/22 public
縮小成4段 C Class的範圍
如果是
192.168.0.0/24、
192.168.1.0/24的話
可以用
com2sec mynetwork 192.168.0.0/23 public
縮小成剛好兩段 C Class
如果區段為
192.168.200.0/24
192.168.201.0/24
也可以改成 192.168.0.0/23 嗎? 謝謝。
要設定為
192.168.200.0/23
了解,謝謝你的指導。
張貼留言