MRTG 快速安裝法 *
MRTG 主要是用來偵測主機上的資料流量,將流量繪製成漂亮的統計圖表。另外,我們也可以自行寫一些 SCRIPT,加掛於 MRTG 上,只要你提供給 MRTG 它兩個數值,它就可以做為流量的依據,幫我們產生統計圖表。
在偵測記憶體負載方面,本人已將緩衝區及快取所佔用的記憶體排除在外,這點可能有別於其它教學文章。因為 Linux 在執行上,並不會自動釋放這兩者所佔用的記憶體,如果併入計算,則在圖表上所看到的記憶體負載,將永遠居高不下。
以下的步驟是使用本人修改過的設定檔來啟用 mrtg,除了原來的網路流量,尚可偵測 CPU 負載、記憶體負載、網站線上人數、FTP 線上人數及 SSH 線上人數及 TELNET 線上人數,適用於 Redhat Linux 7.3。
安裝 ucd-snmp
apt-get remove ucd-snmp
cd /tmp wget http://www.vixual.net/download/source/mrtg/ucd-snmp-4.2.5.tar.gz tar -zxvf ucd-snmp-4.2.5.tar.gz
cd ucd-snmp-4.2.5 ./configure --prefix=/usr/local/snmp
執行過程…
. . . ************** Configuration Section ************** You are about to be prompted with a series of questions. Answer them carefully, as they determine how the snmp agent and related applications are to function. After the configure script finishes, you can browse the newly created config.h file for further - less important - parameters to modify. Be careful if you re-run configure though, since config.h will be overwritten. -Press return to continue-
按
disabling above prompt for future runs... yes checking System Contact Information... *** System Contact Information: Describes who should be contacted about the host the agent is running on. This information is available in the MIB-II tree. This can also be over-ridden using the "syscontact" syntax in the agent's configuration files. System Contact Information (root@):
輸入 “root@localhost“, 然後按
setting System Contact Information to... root@localhost checking System Location... *** System Location: Describes the location of the system. This information is available in the MIB-II tree. this can also be over-ridden using the "syslocation" syntax in the agent's configuration files. System Location (Unknown):
輸入 “RedHat 7.3“, 然後按
setting System Location to... RedHat 7.3 checking Location to write logfile... *** Logfile location: Enter the default location for the snmpd agent to dump information & errors to. If not defined (enter the keyword "none" at the prompt below) the agent will use stdout and stderr instead. (Note: This value can be over-ridden using command line options.) Location to write logfile (/var/log/snmpd.log):
按
setting Location to write logfile to... /var/log/snmpd.log checking Location to write persistent information... *** snmpd persistent storage location: Enter a directory for the snmp library to store persistent data in the form of a configuration file. Location to write persistent information (/var/ucd-snmp):
按
setting Location to write persistent information to... /var/ucd-snmp . . .
make make install
/usr/local/snmp/sbin/snmpd
/usr/local/snmp/sbin/snmpd
安裝 mrtg
cd /var/www/html wget http://www.vixual.net/download/source/mrtg/mrtg-2.9.17-tw.tgz tar -xzvf mrtg-2.9.17-tw.tgz
/usr/bin/mrtg /var/www/html/mrtg/net/mrtg.cfg.net /usr/bin/mrtg /var/www/html/mrtg/cpu/mrtg.cfg.cpu /usr/bin/mrtg /var/www/html/mrtg/ram/mrtg.cfg.ram /usr/bin/mrtg /var/www/html/mrtg/www/mrtg.cfg.www /usr/bin/mrtg /var/www/html/mrtg/ftp/mrtg.cfg.ftp /usr/bin/mrtg /var/www/html/mrtg/ssh/mrtg.cfg.ssh /usr/bin/mrtg /var/www/html/mrtg/telnet/mrtg.cfg.telnet
#mrtg */5 * * * * root /usr/bin/mrtg /var/www/html/mrtg/net/mrtg.cfg.net > /dev/null 2>&1 */3 * * * * root /usr/bin/mrtg /var/www/html/mrtg/cpu/mrtg.cfg.cpu > /dev/null 2>&1 */3 * * * * root /usr/bin/mrtg /var/www/html/mrtg/ram/mrtg.cfg.ram > /dev/null 2>&1 */5 * * * * root /usr/bin/mrtg /var/www/html/mrtg/www/mrtg.cfg.www > /dev/null 2>&1 */5 * * * * root /usr/bin/mrtg /var/www/html/mrtg/ftp/mrtg.cfg.ftp > /dev/null 2>&1 */5 * * * * root /usr/bin/mrtg /var/www/html/mrtg/ssh/mrtg.cfg.ssh > /dev/null 2>&1 */5 * * * * root /usr/bin/mrtg /var/www/html/mrtg/telnet/mrtg.cfg.telnet > /dev/null 2>&1
No comments yet.