레이블이 mrtg인 게시물을 표시합니다. 모든 게시물 표시
레이블이 mrtg인 게시물을 표시합니다. 모든 게시물 표시

2012-09-16

Network] mrtg nt installation guide - 원문


NAME

mrtg-nt-guide - The Windows Guide to MRTG 2.12.2

SYNOPSIS

Installing MRTG on a Windows box is not quite as ``click and point'' as some might want it to be. But then again, it is not all that difficult if you follow the instructions below.

PREREQUISITS

To get MRTG to work on Windows you need the following:

INSTALLATION

I suggest you do the following from the machine that will be running MRTG, which, in this case, is also a web server. All examples are for doing things to a LOCAL machine.
First
Unzip MRTG to C:\mrtg-2.12.2 on the Windowsmachine of your choice.
Next
Install Perl on the same Windows machine. You might want to make sure that the Perl binary directory is listed in your system path.
           C:\Perl\bin;%SystemRoot%\system32;%SystemRoot%;...
          
You can manually check this by going to [Control Panel]->[System]->[Environment]
To see if everything is installed properly you can open a Command Shell and go into c:\mrtg-2.12.2\bin. Type:
           perl mrtg
          
This should give you a friendly error message complaining about the missing mrtg configuration file. Now, you have successfully installed mrtg and perl.

CONFIGURING MRTG

Now it is time to create a configuration for mrtg. But before we begin you need to know a few things. Take an opportunity to gather the following information:
  • The IP address or hostname and the snmp port number, (if non standard), of the device you want to monitor.
  • If you want to monitor something other than bytes in and out, you must also know the SNMPOID of what you want to monitor.
  • Finally you need to know the read-only SNMP community string for your device. If you don't know it, try public, that is the default.
For the rest of this document we will be using device 10.10.10.1 ( a CISCO Catalyst 5000) with Community string public. We are interested in monitoring traffic, and the CPU load. Let's begin.
The first thing we do in setting up mrtg is making a default config file. Get to a cmd prompt and change to the c:\mrtg-2.12.2\bin directory. Type the following command:
           perl cfgmaker public@10.10.10.1 --global "WorkDir: c:\www\mrtg" --output mrtg.cfg
          
This creates an initial MRTG config file for you. Note that in this file all interfaces of your router will be stored by number. Unfortunately, these numbers are likely to change whenever you reconfigure your router. In order to work around this you can get cfgmaker to produce a configuration which is based on Ip numbers, or even Interface Descriptions. Check the cfgmaker manpage
If you get an error message complaining about no such name or no response, your community name is probably wrong.
Now, let's take a look at the mrtg.cfg file that was created.
In Perl, a # is a comment, synonymous with REM in DOS.
Add the following to the top of the mrtg.cfg file:
           WorkDir: D:\InetPub\wwwroot\MRTG
          
This is where the web pages are created, usually a web root.
           ######################################################################

           # Description: LCP SUWGB

           # Contact: Administrator

           # System Name: LC-Bridge

           # Location: Here

           #.....................................................................
          
TargetDevice's IP Address:Interface Number:Community:IP Address
           Target[10.10.10.1.1]: 1:public@10.10.10.1
          
This is the interface speed (Default is 10 megabits; for 100Mbit devices use 12500000 and so on...)
           MaxBytes[10.10.10.1.1]: 1250000
          
           Title[10.10.10.1.1]: LC-Bridge (sample.device): ether0
          
This section determines how the web page headers will look
           PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0</H1>

            <TABLE>

            <TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>

            <TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>

            <TR><TD>Interface:</TD><TD>ether0(1)</TD></TR>

            <TR><TD>IP:</TD><TD>sample.device(10.10.10.1)</TD></TR>

            <TR><TD>Max Speed:</TD>

            <TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>

            </TABLE>
          
            Target[10.10.10.1.2]: 2:public@10.10.10.1

            MaxBytes[10.10.10.1.2]: 1250000

            Title[10.10.10.1.2]: LC-Bridge (): ulink0

            PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0</H1>

             <TABLE>

             <TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>

             <TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>

             <TR><TD>Interface:</TD><TD>ulink0(2)</TD></TR>

             <TR><TD>IP:</TD><TD>()</TD></TR>

             <TR><TD>Max Speed:</TD>

             <TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>

             </TABLE>
          
            #---------------------------------------------------------------
          
And that's a very basic mrtg config file. You can run this and see your results by going into the c:\mrtg-2.12.2\bindirectory and typing:
           perl mrtg mrtg.cfg
          
It is normal to get errors for the first two times you run this command. The errors will alert you about the fact that there have not been any log files in existence before.
If you take a look at those web pages they are not very exciting (yet). You need to have the mrtg files run every five minutes to produce the desired results. Just run it again after a few minutes. You should now be able to see the first lines in your graphs.

MAKE MRTG RUN ALL THE TIME

Starting mrtg by hand every time you want to run it is not going to make you happy I guess.
There is a special option you can set in the mrtg configuration file so so that mrtg will not terminate after it was started. Instead it will wait for 5 minutes and then run again.
Add the option
           RunAsDaemon: yes
          
to your mrtg.cfg file and start it with:
           start /Dc:\mrtg-2.12.2\bin wperl mrtg --logging=eventlog mrtg.cfg
          
If you use wperl instead of perl, no console window will show. MRTG is now running in the background. If it runs into problems it will tell you so over the EventLog. To stop MRTG, open the Task Manager and terminate the wperl.exeprocess. If mrtg has anything to tell you these messages can be found in the event log.
If you put a shortcut with
           Target:    wperl mrtg --logging=eventlog mrtg.cfg

           Start in:  c:\mrtg-2.12.2\bin
          
into your startup folder, mrtg will now start whever you login to your NT box.
If you do not want to log into your box just to start mrtg. Have a look at http://www.firedaemon.com/mrtg-howto.htmlwhich describes a free tool to start any program as a Service. The pages gives specific instructions for mrtg users.

HOW TO SETUP MRTG AS A WINDOWS SERVICE

Additional Prerequisites

Preparation

Please complete the following steps before starting the installation:
  • Copy srvany.exe and instsrv.exe to c:\mrtg\bin\ (your MRTG bin directory).
  • Create a file called mrtg.reg anywhere on your system and paste the following content into it:
               Windows Registry Editor Version 5.00
              
               [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRTG\Parameters]
    
               "Application"="c:\\perl\\bin\\wperl.exe"
    
               "AppParameters"="c:\\mrtg\\bin\\mrtg --logging=eventlog c:\\mrtg\\bin\\mrtg.cfg"
    
               "AppDirectory"="c:\\mrtg\\bin\\"
              

Installation

Once again, assuming that MRTG is already fully installed and configured on the target system under c:\mrtg\ the following steps are necessary to setup MRTG as a service.
Using the command prompt go into the temporary directory where you unzipped the package. When there type the following command to create a service named ``MRTG'' in the Windows Services management console:
           instsrv MRTG c:\mrtg\bin\srvany.exe
          
Now you need to create the App* entries required for the new service. You can do this by either right-clicking on the mrtg.reg file and selecting 'merge' or by running the following command:
           regedit /s mrtg.reg
          
After setting up the registry entry it is time to point it to your MRTG installation. If you have installed MRTG underc:\mrtg\, you can skip this step. Open your registry editor (Start -> Run -> regedt32), and locate the[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRTG] key. Make sure that theImagePath variable is correctly pointing to srvany.exe located in your MRTG bin directory (for example c:\mrtg\bin\srvany.exe). Next you have to expand the MRTG tree, and go to the[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRTG\Parameters] key. Under Parameters make sure that all the Application variables are setup propperly.
At this point you are ready to run the service. The only thing left to do is to start the MRTG service in the Services management console. After you do this, you should see two new processes running on your system: srvany.exe and wperl.exe. Make sure to stop any previously running MRTG processes to avoid confict.
Note that it is imperative to set the RunAsDaemon: yes option or the service will stop after just one single run!

EXAMPLE

Now lets look at a config file to monitor what we wanted to on our mythical Cisco Cat 5000 -- utilization on ports 3, 5, 10, and 24, and the CPU Load, which will show us nonstandard mrtg configurations as well as more options..
           WorkDir: D:\InetPub\wwwroot\MRTG

           RunAsDaemon: yes
          
           ######################################################################

           # Description: LCP SUWGB

           # Contact: Administrator

           # System Name: LC-Bridge

           # Location: Here

           #.....................................................................
          
           Target[10.10.10.1.1]: 3:public@10.10.10.1

           MaxBytes[10.10.10.1.1]: 1250000

           Title[10.10.10.1.1]: LC-Bridge (sample-device): ether0

           PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0</H1>

            <TABLE>

           <TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>

           <TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>

           <TR><TD>Interface:</TD><TD>ether0(3)</TD></TR>

           <TR><TD>IP:</TD><TD>sample-device(10.10.10.1)</TD></TR>

           <TR><TD>Max Speed:</TD>

           <TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>

           </TABLE>
          
           #---------------------------------------------------------------
          
           Target[10.10.10.1.2]: 5:public@10.10.10.1

           MaxBytes[10.10.10.1.2]: 1250000

           Title[10.10.10.1.2]: LC-Bridge (): ulink0

           PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0</H1>

            <TABLE>

            <TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>

            <TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>

            <TR><TD>Interface:</TD><TD>ulink0(5)</TD></TR>

            <TR><TD>IP:</TD><TD>()</TD></TR>

            <TR><TD>Max Speed:</TD>

            <TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>

            </TABLE>
          
           #---------------------------------------------------------------
          
           Target[10.10.10.1.1]: 10:public@10.10.10.1

           MaxBytes[10.10.10.1.1]: 1250000

           Title[10.10.10.1.1]: LC-Bridge (sample-device): ether0

           PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0</H1>

            <TABLE>

            <TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>

            <TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>

            <TR><TD>Interface:</TD><TD>ether0(10)</TD></TR>

            <TR><TD>IP:</TD><TD>sample-device(10.10.10.1)</TD></TR>

            <TR><TD>Max Speed:</TD>

            <TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>

            </TABLE>
          
           #---------------------------------------------------------------
          
           Target[10.10.10.1.2]: 24:public@10.10.10.1

           MaxBytes[10.10.10.1.2]: 1250000

           Title[10.10.10.1.2]: LC-Bridge (): ulink0

           PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0</H1>

            <TABLE>

            <TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>

            <TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>

            <TR><TD>Interface:</TD><TD>ulink0(24)</TD></TR>

            <TR><TD>IP:</TD><TD>()</TD></TR>

            <TR><TD>Max Speed:</TD>

            <TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>

            </TABLE>
          
           #---------------------------------------------------------------
          
           # Router CPU load %

           Target[cpu.1]:1.3.6.1.4.1.9.2.1.58.0&1.3.6.1.4.1.9.2.1.58.0:public@10.10.10.1

           RouterUptime[cpu.1]: public@10.10.10.1

           MaxBytes[cpu.1]: 100

           Title[cpu.1]: CPU LOAD

           PageTop[cpu.1]: <H1>CPU Load %</H1>

           Unscaled[cpu.1]: ymwd

           ShortLegend[cpu.1]: %

           XSize[cpu.1]: 380

           YSize[cpu.1]: 100

           YLegend[cpu.1]: CPU Utilization

           Legend1[cpu.1]: CPU Utilization in % (Load)

           Legend2[cpu.1]: CPU Utilization in % (Load)

           Legend3[cpu.1]:

           Legend4[cpu.1]:

           LegendI[cpu.1]:

           LegendO[cpu.1]: &nbsp;Usage

           Options[cpu.1]: gauge
          
This is a nice example of how to monitor any SNMP device if you know what OID you want to use. Once again, For an explanation of the more advance features of mrtg, please see Tobias's documentation.

AUTHORS

Tobi Oetiker <oetiker@ee.ethz.ch>, David S. Divins <ddivins@moon.jic.com>, Steve Pierce <MRTG@HDL.com>, Artyom Adjemov <one.bofh@gmail.com>, Ilja Ivanov <ivanov@bseu.by> Karel Fajkus <karel@fajkus.cz>
출처 : http://people.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg-nt-guide.html

2012-09-15

Mail]MRTG를 사용하여 qmail 통계 그래프 생성하기


MRTG를 사용하여 qmail 통계 그래프 생성하기

Paul Hoadley mailto:paulh@logicsquad.net 저.
OpenBIRD, Inc. mailto:editors@openbird.com 역.

이 문서는 SMTP(역주: qmail을 뜻함), POP3의 수행작업들에 대한 별도의 로그를 만들고, Inter7(역주: 회사 이름)의 qmailmrtg7패키지와 MRTG를 사용해서 해당 로그의 통계 그래프를 생성하는 방법을 설명합니다. 본 문서에서 다루는 작업들은 FreeBSD 4.2 릴리즈와 4.3 릴즈즈에서 실험 되어졌습니다만, 다른 릴리즈의 시스템에서 작동 할 것입니다.

Table of Contents
1. 필요한 준비물
2. 먼저 설치되어야 할 소프트웨어
3. 로그 디렉토리의 생성
4. 설정화일 변경

1. 필요한 준비물

1.1. 필요한 프로그램들

아래의 프로그램들이 먼저 설치되어 있어야 합니다.
  • qmail-1.03 (포트에서 설치하세요: /usr/ports/mail/qmail)
  • mrtg-2.9.11 (포트에서 설치하세요: /usr/ports/net/mrtg)
본 문서에스는 qmail의 설치 방법은 다루지 않습니다. qmail의 설치에 대해서는 Installing qmail under FreeBSD를 참고하세요.

2. 먼저 설치되어야 할 소프트웨어

2.1. daemontools-0.70

패키지(qmailmrtg)에서 setuidgid와 multilog 유틸리티가 사용되기 때문에, 해당 유틸리티가 설치되어 있어야 합니다. 다음과 같이 설치하십시요.
          # cd /usr/ports/sysutils/daemontools
          # make install
          

2.2. qmailmrtg7-3.1

Inter7에서 구할 수 있습니다.
          # cd tmp
          # fetch http://inter7.com/qmailmrtg7/qmailmrtg7-3.1.tar.gz
          # gunzip qmailmrtg7-3.1.tar.gz
          # tar -xvf qmailmrtg7-3.1.tar
          # cd qmailmrtg7-3.1
          # make all
          # make install
          # rm /etc/qmail.mrtg.cfg
          
위의 설치 과정을 보면 마지막에 /etc/qmail.mrtg.cfg 파일을 삭제하는 것을 알 수 있습니다. qmailmrtg7는 설치 과정에서 설정 파일을 /etc 디렉토리에 복사하는데, 설정 파일은 /usr/local/etc/mrtg 디렉토리에 위치하거나, 기본 MRTG 설정 파일 /usr/local/etc/mrtg/mrtg.cfg에 통합되는 것이 이상적이기 때문에 삭제합니다. 다음 섹션에서 보다 자세히 다룹니다.

3. 로그 디렉토리의 생성

/var/log에 다음과 같이 데몬들을 위한 디렉토리를 만듭니다.
          # cd /var/log
          # mkdir qmail
          # mkdir pop3
          # mkdir smtp
          
보안적인 면을 고려한다면 이 디렉토리들의 퍼미션을 적절하게 수정 하십시요. (역주: 예 chmod 500)

4. 설정화일 변경

4.1. /etc/rc.conf

qmail이 Installing qmail under FreeBSD에 따라 정확히 설치 되었다면 /etc/rc.conf의 값들이 변경되어 있을것입니다. 만약 그렇지 않다면 /etc/rc.conf에 다음 항목을 추가하십시요.
          # qmail options
          qmail_smtp_enable="YES"
          qmail_pop_enable="YES"
          qmail_enable="YES"
          

4.2. /var/qmail/rc

/var/qmail/rc에서 구동되는 각각의 데몬 구동용 명령어들이 multilog의 장점을 취하기 위해서는 아래의 스크립트에서 HOST.DOMAIN을 메일서버의 FQDN(Fully Qualified Domain Name, 역주: 인터넷 도메인 주소라고 보시면 됩니다)으로 수정하여야 합니다.
          #!/bin/sh
          #
          # This script starts and stops the qmail mail functions.
          #
          # Suck in the configuration variables.
          if [ -r /etc/defaults/rc.conf ]; then
                  . /etc/defaults/rc.conf
                  source_rc_confs
          elif [ -r /etc/rc.conf ]; then
                  . /etc/rc.conf
          fi

          case "$1" in
          start)
                  case ${qmail_smtp_enable} in
                  [Yy][Ee][Ss])
                          # Start the qmail smtp daemon
                          env - PATH="/var/qmail/bin:/usr/local/bin" \
                          tcpserver -v -H -R  -x /etc/tcp.smtp.cdb \
                          -c200 -u82 -g81 0 25 fixcrio /var/qmail/bin/qmail-smtpd \
                          2>&1 | /usr/local/bin/setuidgid qmaill \
                          /usr/local/bin/multilog t n100 s1000000 /var/log/smtp &
                          echo -n " qmail-smtp"
                          ;;
                  esac

                  case ${qmail_pop_enable} in
                  [Yy][Ee][Ss])
                          # Start the qmail pop daemon
                          env - PATH="/var/qmail/bin:/usr/local/bin" \
                          tcpserver -v -H -R -c200 0 110 \
                          /var/qmail/bin/qmail-popup HOST.DOMAIN \
                          /usr/local/bin/checkpassword /var/qmail/bin/qmail-pop3d \
                          Maildir 2>&1 | /usr/local/bin/setuidgid qmaill \
                          /usr/local/bin/multilog t n100 s1000000 /var/log/pop3 &
                          echo -n " qmail-pop"
                          ;;
                  esac

                  case ${qmail_enable} in
                  [Yy][Ee][Ss])
                          # Start qmail
                          exec env - PATH="/var/qmail/bin:$PATH" \
                          qmail-start ./Maildir | /usr/local/bin/setuidgid qmaill \
                          /usr/local/bin/multilog t n100 s1000000 /var/log/qmail &
                          echo -n " qmail"
                          ;;
                  esac
                  ;;

          stop)
                  # Stop the smtp daemon
                  smtppid=`ps -axw | grep tcpserver | grep smtp | grep -v grep | awk '{ print $1 }'`
                  if [ "$smtppid" != "" ]; then
                          kill $smtppid
                          echo -n " qmail-smtp"
                  fi


                  # Stop the pop daemon
                  poppid=`ps -axw | grep tcpserver | grep popup | grep -v grep | awk '{ print $1 }'`
                  if [ "$poppid" != "" ]; then
                          kill $poppid
                          echo -n " qmail-pop"
                  fi

                  # Stop qmail
                  qmailpid=`ps -axw | grep qmail-send | grep -v grep | awk '{ print $1 }'`
                  if [ "$qmailpid" != "" ]; then
                          kill $qmailpid
                          echo -n " qmail"
                  fi
                  ;;
          *)

                  echo "Usage: `basename $0` {start|stop}" >&2
                  ;;
          esac

          exit 0
          
\ 문자로 종결되는 행은 원래 다음 행과의 하나의 긴 라인 입니다만, 여기에서는 \ 문자를 사용해 두개의 행으로 나누어 표현하고 있습니다.

4.3. /usr/local/etc/mrtg/mrtg.cfg

mrtg.cfg의 설정은 시스템에 어떻게 MRTG를 설정하는가에 매우 의존적입니다. 먼저 다음과 같이 qmail.mrtg.cfg 예제 설정 파일을 mrtg.cfg에 추가하여 기본 설정으로 구동해 본 후에 시스템에 맞추어 수정을 가하십시요. :
          # cd /usr/local/etc/mrtg
          # mv mrtg.cfg mrtg.cfg.bak
          # cat mrtg.cfg.bak /tmp/qmailmrtg7-3.1/qmail.mrtg.cfg > mrtg.cfg
          
위의 과정 후 생성된 파일 mrtg.cfg 에 문제가 없는지 꼭 점검 하십시요. 그리고, 사이트의 MRTG 인덱스 페이지에서 새롭게 생성된 HTML페이지들을 가리키는 링크를 추가하여야 합니다.