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.