본문 바로가기

Web

Centos6 darkstat 설치



위와 같이 웹에서 실시간으로 트래픽 현황을 확인하기 좋은 툴입니다.


소스 설치와 yum을 통한 설치가 있는데요


소스 설치시 영어의 문구를 한글로 변경 할 수 있다는 장점이 있습니다.


yum을 통한 설치시엔 위와 같은 모습을 확인 할 수 있습니다.


또한 host나 process별 트래픽을 확인 할 수 있습니다.


아래는 설치 방법입니다.


* 소스설치

먼저 소스 설치 시 libpcap-devel 모듈이 필요한데 해당 모듈이 있는지 검사부터 하도록 하겠습니다.

[root@server ]# rpm -qa | grep libpcap-devel

libpcap-devel-1.4.0-4.20130826git2dbcaa1.el6.x86_64


네 정상적으로 있다고 나오네요 :-)


만일 해당 모듈이 없을 경우 yum을 통하여 설치가 가능합니다.


[root@server ]# yum install -y libpcap-devel

Loaded plugins: fastestmirror, security

Setting up Install Process

Loading mirror speeds from cached hostfile

 * base: centos.tt.co.kr

 * extras: centos.tt.co.kr

 * rpmforge: ftp.neowiz.com

 * updates: centos.tt.co.kr

No package libpcap-dev available.

Error: Nothing to do

[root@kua-web1 darkstat-3.0.719rc1]# yum install libpcap-devel

Loaded plugins: fastestmirror, security

Setting up Install Process

Loading mirror speeds from cached hostfile

 * base: centos.tt.co.kr

 * extras: centos.tt.co.kr

 * rpmforge: ftp.neowiz.com

 * updates: centos.tt.co.kr

Resolving Dependencies

--> Running transaction check

---> Package libpcap-devel.x86_64 14:1.4.0-4.20130826git2dbcaa1.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


====================================================================================================================================

 Package                       Arch                   Version                                            Repository            Size

====================================================================================================================================

Installing:

 libpcap-devel                 x86_64                 14:1.4.0-4.20130826git2dbcaa1.el6                  base                 114 k


Transaction Summary

====================================================================================================================================

Install       1 Package(s)


Total download size: 114 k

Installed size: 161 k

Is this ok [y/N]: y

Downloading Packages:

libpcap-devel-1.4.0-4.20130826git2dbcaa1.el6.x86_64.rpm                                                      | 114 kB     00:00     

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : 14:libpcap-devel-1.4.0-4.20130826git2dbcaa1.el6.x86_64                                                           1/1 

  Verifying  : 14:libpcap-devel-1.4.0-4.20130826git2dbcaa1.el6.x86_64                                                           1/1 


Installed:

  libpcap-devel.x86_64 14:1.4.0-4.20130826git2dbcaa1.el6                                                                            


Complete!


wget 으로 darkstat의 소스 파일을 다운 받고 압축을 풀어 설치를 시작하겠습니다.


[root@server ]# wget https://unix4lyfe.org/darkstat/darkstat-3.0.719.tar.bz2

[root@server ]# tar xvf darkstat-3.0.719rc1.tar.bz2

[root@server ]# cd darkstat-3.0.719rc1

[root@server darkstat-3.0.719rc1]# ./configure

checking for a BSD-compatible install... /usr/bin/install -c

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables... 

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking for C/C++ restrict keyword... __restrict

checking if we want debug code... sure

checking if your C compiler wants a hit off the pipe... sure does

checking if your C compiler has a link-time optimizer... no

checking for deflate in -lz... yes

checking for library containing gethostbyname... none required

checking for library containing socket... none required

checking for library containing hstrerror... none required

checking how to run the C preprocessor... gcc -E

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking sys/filio.h usability... no

checking sys/filio.h presence... no

checking for sys/filio.h... no

checking for library containing getifaddrs... none required

checking ifaddrs.h usability... yes

checking ifaddrs.h presence... yes

checking for ifaddrs.h... yes

checking sys/sockio.h usability... no

checking sys/sockio.h presence... no

checking for sys/sockio.h... no

checking for pcap_loop in -lpcap... yes

checking pcap.h usability... yes

checking pcap.h presence... yes

checking for pcap.h... yes

checking for library containing setproctitle... no

checking for library containing strlcpy... no

checking for library containing strlcat... no

checking bsd/string.h usability... no

checking bsd/string.h presence... no

checking for bsd/string.h... no

checking bsd/unistd.h usability... no

checking bsd/unistd.h presence... no

checking for bsd/unistd.h... no

checking for library containing clock_gettime... -lrt

configure: creating ./config.status

config.status: creating Makefile

config.status: creating darkstat.8

config.status: creating config.h

[root@server darkstat-3.0.719rc1]# make
  CC     acct.o
  CC     addr.o
  CC     bsd.o
  CC     cap.o
  CC     conv.o
  CC     darkstat.o
  CC     daylog.o
  CC     db.o
  CC     decode.o
  CC     dns.o
  CC     err.o
  CC     graph_db.o
  CC     hosts_db.o
  CC     hosts_sort.o
  CC     html.o
  HOSTCC c-ify
  C-IFY  stylecss.h
  C-IFY  graphjs.h
  CC     http.o
  CC     localip.o
  CC     ncache.o
  CC     now.o
  CC     pidfile.o
  CC     str.o
  LINK   darkstat


여기까지 하셨으면 설치가 완료 되었습니다!!


ll 명령을 통해 추가된 darkstat를 확인해봅시다 :-)


[root@server darkstat-3.0.719rc1]# ll | grep darkstat

-rwxr-xr-x. 1 root root 316686 Sep  9 11:10 darkstat

-rw-r--r--. 1 root root  12360 Sep  9 11:03 darkstat.8

-rw-r--r--. 1 1000 1000  12339 Dec 27  2014 darkstat.8.in

-rw-r--r--. 1 1000 1000  14515 Dec 27  2014 darkstat.c

-rw-r--r--. 1 root root  41840 Sep  9 11:10 darkstat.o


잘 추가 되었군요?!


그렇다면 아래 명령을 통해 실행 할 수 있습니다.


-i는 네트워크 인터페이스 명칭이며, -p의 경우는 접속 포트 명칭 입니다.


[root@server darkstat-3.0.719rc1]# darkstat -i eth0 -p 9999




* yum을 통한 설치


앞서 해보았던 소스설치보다는 무척 간단합니다.


[root@server ]# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

[root@server ]# yum --enablerepo=rpmforge install -y darkstat


따란~! 설치가 종료 되었습니다.


실행은 아래와 같이 하시면 됩니다.


[root@server ]# /usr/sbin/darkstat -i eth0 -p 8080



darkstat에서 제공하는 help는 아래와 같습니다.


darkstat 3.0.717 (using libpcap version 1.4.0)


usage: darkstat [ -i interface ]

                [ -f filter ]

                [ -r capfile ]

                [ -p port ]

                [ -b bindaddr ]

                [ -l network/netmask ]

                [ --local-only ]

                [ --snaplen bytes ]

                [ --pppoe ]

                [ --syslog ]

                [ --verbose ]

                [ --no-daemon ]

                [ --no-promisc ]

                [ --no-dns ]

                [ --no-macs ]

                [ --no-lastseen ]

                [ --chroot dir ]

                [ --user username ]

                [ --daylog filename ]

                [ --import filename ]

                [ --export filename ]

                [ --pidfile filename ]

                [ --hosts-max count ]

                [ --hosts-keep count ]

                [ --ports-max count ]

                [ --ports-keep count ]

                [ --highest-port port ]

                [ --wait secs ]

                [ --hexdump ]

                [ --version ]

                [ --help ]


darkstat를 종료 할 때 방법을 몰라 제 나름의 방법으로 사용합니다.. 굿 아이디어 있으시면 댓글 좀..

[root@server ]# netstat -anp | grep 8080

tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      24298/./darkstat    

tcp        0      0 :::8080                     :::*                        LISTEN      24298/./darkstat

[root@server ]# kill -9 24298



아래의 스크린샷은 일부 한글화 했을때의 모습(?) 입니다.


:-)




'Web' 카테고리의 다른 글

Jquery 정규식  (0) 2016.09.07
apache .htaccess config  (0) 2016.03.29
Centos rsync 동기화  (0) 2015.09.08
[2015.09.03] openstack with CentOS7 설치하기  (0) 2015.09.03
pear 오류  (0) 2015.02.28