3. MRTG Script 사용법
앞에서도 밝혔듯이 필자가 mrtg를 약간 수정을 했다고 했다. 그 수정한 script를 사용
하는 법을 이 section 에서 다루고자 한다.
mrtg script 는 4가지의 option을 가지고 있다. 아래의 help를 보도록 하자.
Hanterm
[root@bbuwoo mydir]$ mrtg help
Usage: /usr/sbin/mrtg {conf|index|log}
conf - create mrtg config file
index - create index file of mrtg
log - logging mrtg log
[root@bbuwoo mydir]$
mrtg script 에는 위에서와 같이 3가지의 옵션을 보여준다. 위에서 4 가지라고 한것은
rpm 으로 설치를 할때 mrtg.cfg 를 생성시켜 주기 위한 것으로 알 필요는 없다. 일단
각각의 옵션들에 대해 설명을 해 보도록 하겠다.
mrtg log 명령은 mrtg.cfg file의 설정을 이용하여 WorkDir 에 mrtg log와 html file
그리고 gif image(mrtg graph)를 생성을 한다.
mrtg index 는 index.html 을 생성해 준다.
mrtg conf 는 mrtg.cfg 를 생성을 해 주는데.. 여기서는 router 의 전송량을 mrtg.cfg
로 만들어 주게 되어 있다. 그러므로 mrtg conf 명령은 별로 사용할일이 없을 것이다.
아니 router의 사용량을 보고 싶다면 mrtg conf명령을 실행하되.. 주의 할것은 기본적
인 mrtg.cfg 를 덮어씌우게 되므로 백업을 한 뒤에 생성을 하고 생성된 파일에서 mrtg
router 설정 부분만 원 cfg file의 가장 뒤에 붙여서 사용을 하기 바란다.
그럼 다시 본론으로 들어가서 앞에서 까지의 과정 즉, mrtg.cfg 의 수정을 완료를 했
다면 일단 처음 mrtg.cfg를 수정한 사람의 경우에는 WorkDir 로 지정되어 있는 디렉토
리에 있는 파일들을 모두 삭제를 한다. 이유는 아직 mrtg.cfg를 설정하지 않았는데 앞
에서 cron 으로 mrtg 를 작동하게 해 놓았기 때문에 잘못된 데이타 들이 들어가 있는
log file들이 존재 하기 때문이다. 그러므로 일단 이 파일들을 삭제한 뒤에 아래와 같
이 명령을 실행 하도록 한다.
다시 당부하지만 WorkDir 즉 /home/httpd/html/MRTG-data 에 있는 파일들을 삭제할 경
우는 mrtg.cfg 를 처음 설정한 경우에만 해당한다.
Hanterm
[root@bbuwoo etc]$ rm -rf /home/httpd/html/MRTG-data/*.*
삭제를 할때 *으로 삭제를 하면 기본적인 icon까지 삭제가 되므로
꼭 *.* 으로 삭제를 하기 바란다.
[root@bbuwoo etc]$ mrtg log
Rateup WARNING: rateup could not read the primary log file for router_1
Rateup WARNING: rateup The backup log file for router_1 was invalid as well
Rateup WARNING: rateup Can't remove router_1.old updating log file
Rateup WARNING: rateup Can't rename router_1.log to router_1.old updating log file
Rateup WARNING: rateup could not read the primary log file for router_2
Rateup WARNING: rateup The backup log file for router_2 was invalid as well
Rateup WARNING: rateup Can't remove router_2.old updating log file
Rateup WARNING: rateup Can't rename router_2.log to router_2.old updating log file
Rateup WARNING: rateup could not read the primary log file for work
Rateup WARNING: rateup The backup log file for work was invalid as well
Rateup WARNING: rateup Can't remove work.old updating log file
Rateup WARNING: rateup Can't rename work.log to work.old updating log file
Rateup WARNING: rateup could not read the primary log file for work_eth0
Rateup WARNING: rateup The backup log file for work_eth0 was invalid as well
Rateup WARNING: rateup Can't remove work_eth0.old updating log file
Rateup WARNING: rateup Can't rename work_eth0.log to work_eth0.old updating log file
Rateup WARNING: rateup could not read the primary log file for work_load
Rateup WARNING: rateup The backup log file for work_load was invalid as well
Rateup WARNING: rateup Can't remove work_load.old updating log file
Rateup WARNING: rateup Can't rename work_load.log to work_load.old updating log file
Rateup WARNING: rateup could not read the primary log file for work_httpd
Rateup WARNING: rateup The backup log file for work_httpd was invalid as well
Rateup WARNING: rateup Can't remove work_httpd.old updating log file
Rateup WARNING: rateup Can't rename work_httpd.log to work_httpd.old updating log file
Rateup WARNING: rateup could not read the primary log file for work_disk
Rateup WARNING: rateup The backup log file for work_disk was invalid as well
Rateup WARNING: rateup Can't remove work_disk.old updating log file
Rateup WARNING: rateup Can't rename work_disk.log to work_disk.old updating log file
Rateup WARNING: rateup could not read the primary log file for work_mem
Rateup WARNING: rateup The backup log file for work_mem was invalid as well
Rateup WARNING: rateup Can't remove work_mem.old updating log file
Rateup WARNING: rateup Can't rename work_mem.log to work_mem.old updating log file
Rateup WARNING: rateup could not read the primary log file for work_swap
Rateup WARNING: rateup The backup log file for work_swap was invalid as well
Rateup WARNING: rateup Can't remove work_swap.old updating log file
Rateup WARNING: rateup Can't rename work_swap.log to work_swap.old updating log file
mrtg log 명령을 처음 실행하면 위와 같이 현란한 에러 메세지들이 출력이 될것이다.
하지만 당황하지 말자. 그냥 나오는 메세지 들이다. 3 번째 명령 부터는 에러가 없어
질 것이다. 단순히 log file의 backup file이 존재하지 않기 때문에 발생하는 에러일
뿐이다.
[root@bbuwoo etc]$ mrtg index
mrtg index 명령은 mrtg log 명령으로 log file 들과 결과물들을 생성한 후에 index
page를 생성을 한다
[root@bbuwoo etc]$
위의 process 를 마친 후면 web browser로 http://domain.com/MRTG-data/ 로 들어가서
확인을 할수가 있다. 이까지의 작업을 마쳤으면 다음 부터는 아무것도 할 필요가 없이
그냥 나두면 cron daemon 이 알아서 계속 측정을 하게 된다.
3. MRTG Script 사용법
앞에서도 밝혔듯이 필자가 mrtg를 약간 수정을 했다고 했다. 그 수정한 script를 사용 하는 법을 이 section 에서 다루고자 한다. mrtg script 는 4가지의 option을 가지고 있다. 아래의 help를 보도록 하자.
Hanterm |
[root@bbuwoo mydir]$ mrtg help Usage: /usr/sbin/mrtg {conf|index|log} conf - create mrtg config file index - create index file of mrtg log - logging mrtg log [root@bbuwoo mydir]$ |
mrtg script 에는 위에서와 같이 3가지의 옵션을 보여준다. 위에서 4 가지라고 한것은 rpm 으로 설치를 할때 mrtg.cfg 를 생성시켜 주기 위한 것으로 알 필요는 없다. 일단 각각의 옵션들에 대해 설명을 해 보도록 하겠다. mrtg log 명령은 mrtg.cfg file의 설정을 이용하여 WorkDir 에 mrtg log와 html file 그리고 gif image(mrtg graph)를 생성을 한다. mrtg index 는 index.html 을 생성해 준다. mrtg conf 는 mrtg.cfg 를 생성을 해 주는데.. 여기서는 router 의 전송량을 mrtg.cfg 로 만들어 주게 되어 있다. 그러므로 mrtg conf 명령은 별로 사용할일이 없을 것이다. 아니 router의 사용량을 보고 싶다면 mrtg conf명령을 실행하되.. 주의 할것은 기본적 인 mrtg.cfg 를 덮어씌우게 되므로 백업을 한 뒤에 생성을 하고 생성된 파일에서 mrtg router 설정 부분만 원 cfg file의 가장 뒤에 붙여서 사용을 하기 바란다. 그럼 다시 본론으로 들어가서 앞에서 까지의 과정 즉, mrtg.cfg 의 수정을 완료를 했 다면 일단 처음 mrtg.cfg를 수정한 사람의 경우에는 WorkDir 로 지정되어 있는 디렉토 리에 있는 파일들을 모두 삭제를 한다. 이유는 아직 mrtg.cfg를 설정하지 않았는데 앞 에서 cron 으로 mrtg 를 작동하게 해 놓았기 때문에 잘못된 데이타 들이 들어가 있는 log file들이 존재 하기 때문이다. 그러므로 일단 이 파일들을 삭제한 뒤에 아래와 같 이 명령을 실행 하도록 한다. 다시 당부하지만 WorkDir 즉 /home/httpd/html/MRTG-data 에 있는 파일들을 삭제할 경 우는 mrtg.cfg 를 처음 설정한 경우에만 해당한다. |
Hanterm |
[root@bbuwoo etc]$ rm -rf /home/httpd/html/MRTG-data/*.* 삭제를 할때 *으로 삭제를 하면 기본적인 icon까지 삭제가 되므로 꼭 *.* 으로 삭제를 하기 바란다. [root@bbuwoo etc]$ mrtg log Rateup WARNING: rateup could not read the primary log file for router_1 Rateup WARNING: rateup The backup log file for router_1 was invalid as well Rateup WARNING: rateup Can't remove router_1.old updating log file Rateup WARNING: rateup Can't rename router_1.log to router_1.old updating log file Rateup WARNING: rateup could not read the primary log file for router_2 Rateup WARNING: rateup The backup log file for router_2 was invalid as well Rateup WARNING: rateup Can't remove router_2.old updating log file Rateup WARNING: rateup Can't rename router_2.log to router_2.old updating log file Rateup WARNING: rateup could not read the primary log file for work Rateup WARNING: rateup The backup log file for work was invalid as well Rateup WARNING: rateup Can't remove work.old updating log file Rateup WARNING: rateup Can't rename work.log to work.old updating log file Rateup WARNING: rateup could not read the primary log file for work_eth0 Rateup WARNING: rateup The backup log file for work_eth0 was invalid as well Rateup WARNING: rateup Can't remove work_eth0.old updating log file Rateup WARNING: rateup Can't rename work_eth0.log to work_eth0.old updating log file Rateup WARNING: rateup could not read the primary log file for work_load Rateup WARNING: rateup The backup log file for work_load was invalid as well Rateup WARNING: rateup Can't remove work_load.old updating log file Rateup WARNING: rateup Can't rename work_load.log to work_load.old updating log file Rateup WARNING: rateup could not read the primary log file for work_httpd Rateup WARNING: rateup The backup log file for work_httpd was invalid as well Rateup WARNING: rateup Can't remove work_httpd.old updating log file Rateup WARNING: rateup Can't rename work_httpd.log to work_httpd.old updating log file Rateup WARNING: rateup could not read the primary log file for work_disk Rateup WARNING: rateup The backup log file for work_disk was invalid as well Rateup WARNING: rateup Can't remove work_disk.old updating log file Rateup WARNING: rateup Can't rename work_disk.log to work_disk.old updating log file Rateup WARNING: rateup could not read the primary log file for work_mem Rateup WARNING: rateup The backup log file for work_mem was invalid as well Rateup WARNING: rateup Can't remove work_mem.old updating log file Rateup WARNING: rateup Can't rename work_mem.log to work_mem.old updating log file Rateup WARNING: rateup could not read the primary log file for work_swap Rateup WARNING: rateup The backup log file for work_swap was invalid as well Rateup WARNING: rateup Can't remove work_swap.old updating log file Rateup WARNING: rateup Can't rename work_swap.log to work_swap.old updating log file mrtg log 명령을 처음 실행하면 위와 같이 현란한 에러 메세지들이 출력이 될것이다. 하지만 당황하지 말자. 그냥 나오는 메세지 들이다. 3 번째 명령 부터는 에러가 없어 질 것이다. 단순히 log file의 backup file이 존재하지 않기 때문에 발생하는 에러일 뿐이다. [root@bbuwoo etc]$ mrtg index mrtg index 명령은 mrtg log 명령으로 log file 들과 결과물들을 생성한 후에 index page를 생성을 한다 [root@bbuwoo etc]$ |
위의 process 를 마친 후면 web browser로 http://domain.com/MRTG-data/ 로 들어가서 확인을 할수가 있다. 이까지의 작업을 마쳤으면 다음 부터는 아무것도 할 필요가 없이 그냥 나두면 cron daemon 이 알아서 계속 측정을 하게 된다. |