본문 바로가기

리눅스

CentOS 7에서 VNSTAT을 설치하는 방법(트래픽 모니터링 툴)

반응형

CentOS 7에서 VNSTAT 설치하는 방법(트래픽 모니터링 툴)

VNSTAT 공식사이트

1. 개발 도구 설치

sudo yum groupinstall "Development Tools"

2. 의존성 패키지 설치

sudo yum install sqlite-devel

3. VNSTAT 소스 다운로드 및 압축 해제

cd /usr/local/src
wget https://humdi.net/vnstat/vnstat-2.11.tar.gz --no-check-certificate
tar -xzvf vnstat-2.11.tar.gz
cd vnstat-2.11
./configure
$ ./configure
...
configure:
configure:  ==============================================
configure:
configure:          host: x86_64-unknown-linux-gnu
configure:         build: x86_64-unknown-linux-gnu
configure:
configure:        prefix: /usr/local
configure:   exec_prefix: ${prefix}
configure:        bindir: ${exec_prefix}/bin
configure:       sbindir: ${exec_prefix}/sbin
configure:    sysconfdir: ${prefix}/etc
configure:
configure:    Install paths
configure:
configure:     vnstat: /usr/local/bin/vnstat
configure:    vnstatd: /usr/local/sbin/vnstatd
configure:     config: /usr/local/etc/vnstat.conf
configure:
configure:           Tests: unavailable
configure:    Image output: disabled
configure:
configure:  ==============================================
configure:

4. 컴파일 및 설치

make
sudo make install
$ make install
...
============================================================================
  Note: No service file has been installed for starting the daemon
        automatically. Such setup will need to be created manually
        depending on the used environment. See the included documentation.
============================================================================

make[3]: Leaving directory `/usr/local/src/vnstat-2.11'
make[2]: Leaving directory `/usr/local/src/vnstat-2.11'
make[1]: Leaving directory `/usr/local/src/vnstat-2.11'

5. VNSTAT 초기화 및 활성화

sudo vnstat --create -i [인터페이스 이름]

여기에서 [인터페이스 이름]은 모니터링하려는 네트워크 인터페이스의 이름입니다.

예를 들어

sudo vnstat --create -i eth0
$ which vnstat
/usr/bin/vnstat

3. CRONTAB 등록

[root@lamp01 vnstat-1.11]$ crontab -e
*/5 * * * *         /usr/bin/vnstat -u

VNSTAT 그래프형식으로 보기

1. 공식사이트

[root@lamp01 src]$ wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz

2. 설치

[root@lamp01 src]$ tar xvfz vnstat_php_frontend-1.5.1.tar.gz

3. 웹 서버 설정

[root@lamp01 src]$ cd vnstat_php_frontend-1.5.1
[root@lamp01 vnstat_php_frontend-1.5.1]9$ mv * /home/vnstat/public_html/.

4. http://vnstat.sangchul.kr

 

5. 환경설정

5-1. 홈디렉토리의 config.php 수정

  • $iface_list = array('eth0', 'eth1');
  • $iface_title['eth0'] = 'Internal0';
  • $iface_title['eth1'] = 'Internal1';
  • $vnstat_bin = '/usr/bin/vnstat';
  • $data_dir = './dumps';
  • $graph_format='png';
[root@lamp01 public_html]# cat config.php
<?php
    //
    // vnStat PHP frontend (c)2006-2010 Bjorge Dijkstra (bjd@jooz.net)
    //
    // This program is free software; you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation; either version 2 of the License, or
    // (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // You should have received a copy of the GNU General Public License
    // along with this program; if not, write to the Free Software
    // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    //
    //
    // see file COPYING or at http://www.gnu.org/licenses/gpl.html
    // for more information.
    //
    error_reporting(E_ALL | E_NOTICE);
 
    //
    // configuration parameters
    //
    // edit these to reflect your particular situation
    //
    $locale = 'en_US.UTF-8';
    $language = 'nl';
 
    // list of network interfaces monitored by vnStat
    $iface_list = array('eth0', 'eth1');
 
    //
    // optional names for interfaces
    // if there's no name set for an interface then the interface identifier
    // will be displayed instead
    //   
    $iface_title['eth0'] = 'Internal0';
    $iface_title['eth1'] = 'Internal1';
 
    //
    // There are two possible sources for vnstat data. If the $vnstat_bin
    // variable is set then vnstat is called directly from the PHP script
    // to get the interface data.
    //
    // The other option is to periodically dump the vnstat interface data to
    // a file (e.g. by a cronjob). In that case the $vnstat_bin variable
    // must be cleared and set $data_dir to the location where the dumps
    // are stored. Dumps must be named 'vnstat_dump_$iface'.
    //
    // You can generate vnstat dumps with the command:
    //   vnstat --dumpdb -i $iface > /path/to/data_dir/vnstat_dump_$iface
    //
    $vnstat_bin = '/usr/bin/vnstat';
    $data_dir = './dumps';
 
    // graphics format to use: svg or png
    $graph_format='png';
   
    // Font to use for PNG graphs
    define('GRAPH_FONT',dirname(__FILE__).'/VeraBd.ttf');
 
    // Font to use for SVG graphs
    define('SVG_FONT', 'Verdana');
 
    // Default theme
    define('DEFAULT_COLORSCHEME', 'light');
 
?>

 

728x90
반응형