Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up Multi Router Traffic Grapher

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to set up Multi Router Traffic Grapher, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Multi Router Traffic Grapher-MRTG is a tool software for monitoring the network link traffic load. It obtains the device traffic information through the snmp protocol, and displays the traffic load to the user in the form of a graphical HTML document containing PNG format, showing the traffic load in a very intuitive form.

I. preliminary preparation

(1) MRTG needs to be based on SNMP service, so make sure that this service is enabled on your system and modify the configuration of SNMP:

# vi / etc/snmp/snmpd.conf

Put line 62:

Access notConfigGroup "" any noauth exact systemview none none

Change to

Access notConfigGroup "" any noauth exact mib2 none none

Remove the comment symbol # before line 89 and change it to

View mib2 included .iso.org.dod.internet.mgmt.mib-2 fc

(2) linux Mrtg monitors host traffic to start http service and snmp service:

First check whether the two services are enabled when the system starts

# chkconfig-- list | grep nginx

If there is no startup, you need to modify which startup mode you want to start on your own:

# chkconfig-- level 35 nginx on

Use the same settings for the snmpd service, now start it manually

# service nginx start

# service snmpd start

After startup, it is best to configure the service with setup to start it automatically at random.

Check the opening status of the port to confirm whether it has been started.

# netstat-tunlp | grep snmp

Tcp 0 0 0.0.0. 0 199 0.0.0. 0. 0. 0.

Udp 0 0 0.0.0. 0 161 0.0.0. 0. 0. 0. 0. 0.

(3) the generation of MRTG for browsing images needs the support of http service, as well as the support of gd, libpng and zlib software packages, and the normal operation of gd also needs several other software. (the system comes with it by default, and if it doesn't come with it, we need to install it manually)

1. Install zlib-1.2.3

# tar zxvf zlib-1.2.3.tar.gz

# cd zlib-1.2.3

#. / configure-prefix=/usr/local/zlib

# make

# make install

two。 Install httpd-2.2.4

# tar zxvf httpd-2.2.4.tar.gz

# cd httpd-2.2.4

#. / configure-prefix=/usr/local/apache-sysconfdir=/etc/httpd-enable-so-enable-track-vars-enable-rewrite-with-z-dir=/usr/local/zlib

# make

# make install

Start httpd

/ usr/local/apache/bin/apachectl-k start

3. Install libpng-1.2.14

# tar zxvf libpng-1.2.14.tar.gz

# cd libpng-1.2.14

# cp scripts/makefile.linux makefile

# make (if you are prompted that the zlib library file or header file cannot be found, the default path of zlib in the makefile file is probably incorrect. You can edit the makefile file, locate the zlib entry and reassign the path to / usr/local/zlib/lib and / usr/local/zlib/include).

# make install

4. Install freetype-2.1.10

# tar-zvxf freetype-2.1.10.tar.gz

# cd freetype-2.1.10

# mkdir-p / usr/local/freetype

#. / configure-prefix=/usr/local/freetype

# make;make install

5. Install jpegsrc.v6b

Jpeg does not build a directory by default, so you need to create a directory manually:

# mkdir-pv / usr/local/jpeg6/ {, bin,lib,include,man/ {, man1}, man1}

Installation

# tar zxvf jpegsrc.v6b.tar.gz

#. / configure-prefix=/usr/local/jpeg6/-enable-shared-enable-static

# make

# make install

# make install-lib

6. Install libxml2-2.6.19

# tar-zxf libxml2-2.6.19.tar.gz

# cd libxml2-2.6.19

# mkdir-p / usr/local/libxml2

#. / configure-prefix=/usr/local/libxml2

# make; make install

# cp xml2-config / usr/bin

7. Install the GD-2.0.33 library

# tar-zvxf gd-2.0.33.tar.gz

# mkdir-p / usr/local/gd2

# cd gd-2.0.33

#. / configure-prefix=/usr/local/gd2-with-jpeg=/usr/local/jpeg6/-with-png=/usr/local/lib/-with-zlib=/usr/local/zlib/-with-freetype=/usr/local/freetype/

# make

# make install

(4) modify the system language configuration

# vi / etc/profile

Add the following two lines

LC_ALL=C

LANGUAGE=on

2. Start installation

(1) start installing mrtg

# cd / usr/local/src

# wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.14.5.tar.gz

# tar zvxf mrtg-2.14.5.tar.gz

# cd mrtg-2.14.5

#. / configure-- prefix=/usr/local/mrtg Note: "--prefix=/usr/local/mrtg" is the specified installation path

# make

# make install

(2) configure MRTG

First create a directory under the web directory for the home page of mrtg, if the web directory is: / home/wwwroot/

Create new directories mrtg and sh under this directory, namely:

# cd / home/wwwroot/

# mkdir mrtg

# cd mrtg

# mkdir sh

If the path is too long and inconvenient, you can establish a soft connection:

# cd /

# ln-s / home/wwwroot/mrtg _ mrtg

# ln-s / usr/local/mrtg/bin _ mrtgbin

Copy some pictures over

# cd / usr/local/src/mrtg-2.14.5 / / enter the mrtg installation directory

# cp. / images/*.* / _ mrtg/

Then you need to create a profile:

# / _ mrtgbin/cfgmaker public@ is changed to native IP-- output=/_mrtg/lxy.cfg

Modify the configuration file:

# vi / _ mrtg/lxy.cfg

Uncomment # WorkDir:/home/http/mrtg and change it to WorkDir:/home/ wwwroot/mrtg (here is the WEB directory of MRTG)

Remove the # in front of # Options [_]: growright, bits and align it to the left

Add Language: big5 at the end, and then save

(3) Test the configuration file (test it several times if something goes wrong)

LANG=C / _ mrtgbin/mrtg / _ mrtg/lxy.cfg

=

(4) create sh and pl files according to the instructions below, and then modify .sh files to make them executable (.sh files are below)

# cd / _ mrtg/sh

# chmod 0755 *

(5) generate the home page file of MRTG website: already in the root directory

# / _ mrtgbin/indexmaker-- output=/_mrtg/index.html-- title= "Lidalin's MRTG" / _ mrtg/lxy.cfg

(6) next run the program

# / _ mrtgbin/mrtg / _ mrtg/lxy.cfg some people start # env LANG=C / _ mrtgbin/mrtg / mrtg/lxy.cfg in this way

If there is a warning or error, run it a few more times and OK when the warning or error no longer occurs

(7) the web page generated by MRTG is static. In order to refresh it constantly, you need to add the above command to crontab.

# crontab-e

Add the following line

* / 1 * / _ mrtgbin/mrtg / _ mrtg/lxy.cfg

Save, and then reboot

Open the browser, enter http:// to change to the local machine IP/mrtg, you should be able to see the curve of network usage, it is more accurate to see it in a minute!

Note: if you set up an intermediate firewall and do not enable port 80 access, you need to edit / etc/sysconfig/iptables to allow others to access port 80

Third, the meaning of the parameters in mrtg.cfg

Target: is the script to be executed

Xsize: horizontal width of the generated chart (up to 600)

Ysize: the vertical height of the generated chart (max. 200)

Title: title

Kmg: Change the default multiplier prefixes

Ytics: divided vertically into several blocks (grid)

MaxBytes: the maximum upper limit of the vertical value of the chart

PageTop: tips on the page

Kilo: usually write 1024, if necessary, 1000 units in the computer.

LegendI: the first of the data returned from SHELL

LegendO: the second of the data returned from SHELL

Options: growright, indicating that the chart extends to the right

Fourth, configure other examples

Note: if you modify the configuration, be sure to reset step (3) (4) (5) (6) in the second step.

Other parts of the configuration are put under this folder

# cd / _ mrtg/sh

(1) Monitoring memory usage

Create a script file

# vi mem.sh

Add (step 5) script:

Give it execution permission after saving it.

# chmod 0755 / _ mrtg/sh/*

(2) Edit / mrtg/lxy.cfg and add (step 5) content:

5. Each SHELL (after modifying the configuration, regenerate the home page, and then restart)

(1) MEMORY:mem.sh

#! / bin/bash

# This script to monitor the mem usage.

Totalmem= `/ usr/bin/free | grep Mem | awk'{print $2}'`

Usedmem= `/ usr/bin/free | grep Mem | awk'{print $3}'`

Echo "$totalmem"

Echo "$usedmem"

Edit the configuration file of MRTG: the value of MaxBytes is modified according to the actual situation

# Mem

Target [memory]: `/ _ mrtg/sh/ Mem.sh`

Unscaled [memory]: dwym

MaxBytes [memory]: 2048000

Title [memory]: Memory

ShortLegend [memory]: &

Kmg [memory]: kB,MB

Kilo [memory]: 1024

YLegend [memory]: Memory Usage:

Legend1 [memory]: Total Memory:

Legend2 [memory]: Used Memory:

LegendI [memory]: Total Memory:

LegendO [memory]: Used Memory:

Options [memory]: growright,gauge,nopercent

PageTop [memory]: Memory

(2) SWAP:swap.sh

#! / bin/bash

# This script to monitor the swap usage.

Totalswap= `/ usr/bin/free | grep Swap | awk'{print $2}'`

Usedswap= `/ usr/bin/free | grep Swap | awk'{print $3}'`

Echo "$totalswap"

Echo "$usedswap"

Edit the configuration file of MRTG: MaxBytes modifies according to the actual situation

# Swap

Target [swap]: `/ _ mrtg/sh/ swap.sh`

Unscaled [swap]: dwym

MaxBytes [swap]: 3048000

Title [swap]: SWAP

ShortLegend [swap]: &

Kmg [swap]: kB,MB

Kilo [swap]: 1024

YLegend [swap]: Swap Usage

Legend1 [swap]: Total Swap

Legend2 [swap]: Used Swap

LegendI [swap]: Total Swap

LegendO [swap]: Used Swap

Options [swap]: growright,gauge,nopercent

PageTop [swap]: Swap

(3) CPU:cpu.sh

#! / bin/bash

# run this script to check the mem usage.

Totalmem= `/ usr/bin/free | grep Mem | awk'{print $2}'`

Usedmem= `/ usr/bin/free | grep Mem | awk'{print $3}'`

UPtime= `/ usr/bin/uptime | awk'{print $3 "" $4 "" $5}'`

Echo $totalmem

Echo $usedmem

Echo $UPtime

Hostname

Edit the configuration file of MRTG: MaxBytes modifies according to the actual situation

# Cpu

Target [cpu]: `/ _ mrtg/sh/ cpu.sh`

MaxBytes [cpu]: 100

Title [cpu]: CPU

Options [cpu]: gauge,nopercent,growright

YLegend [cpu]: CPU loading (%)

ShortLegend [cpu]:%

LegendO [cpu]: & CPU USER

LegendI [cpu]: & CPU SYSTEM

PageTop [cpu]: CPU

(4) disk occupancy: df.pl

#! / usr/bin/perl

# output (df-kl) looks like this:

# Filesystem 1k-blocks Used Available Use% Mounted on

# / dev/md0 95645100 30401312 64272080 33% /

# / dev/hde1 14119 1159 12231 9% / boot

#

# In which case, this script returns:

# 95659219

# 30402503

# when run.

Foreach $filesystem (`df-kl | grep-v "Filesystem" `) {

@ df = split (/\ accounting accounting filesystem)

$total + = $df [1]

$usage + = $df [2]

}

Print "$total\ n"

Print "$usage\ n"

Hostname

Edit the configuration file of MRTG: MaxBytes modifies according to the actual situation

# Disk used

Target [disk]: `/ _ mrtg/sh/ df.pl`

Title [disk]: Disk Space

Unscaled [disk]: dwym

MaxBytes [disk]: 115247550

Kmg [disk]: KB,MB,GB

LegendI [disk]: Total Disk Space

LegendO [disk]: Used Disk Space

Legend1 [disk]: Total Disk Space

Legend2 [disk]: Used Disk Space

YLegend [disk]: Megabytes

ShortLegend [disk]: &

Options [disk]: growright,gauge,nopercent

PageTop [disk]: Disk Space

(5) disk I/O:io.sh

#! / bin/bash

# This script will monitor the KBread/sec & KBwriten/sec of Disk.

# Creater: CCC IT loren ext:2288 2005-8-3

# As sda, sdb,sdc,sdd,hda.

# disk=sda

Hd=sda

Disk=/dev/$hd

KBread_sec= `iostat-x $disk | grep $hd | awk'{print $8}'`

KBwrite_sec= `iostat-x $disk | grep $hd | awk'{print $9}'`

Echo "$KBread_sec"

Echo "$KBwrite_sec"

Hostname

Edit MRTG configuration file: modify io.sh if more partitions need to be detected

# Disk I/O

Target [diskIO]: `/ _ mrtg/sh/ io.sh`

Title [diskIO]: Disk HDA I/O

Unscaled [diskIO]: dwym

MaxBytes [diskIO]: 100

Kmg [diskIO]: KB,MB,GB

LegendI [diskIO]: Disk I/O KBread/sec

LegendO [diskIO]: Disk I/O KBwrite/sec

Legend1 [diskIO]: Disk I/O KBread/sec

Legend2 [diskIO]: Disk I/O KBwrite/sec

YLegend [diskIO]: Megabytes

ShortLegend [diskIO]: &

Options [diskIO]: growright,gauge,nopercent

PageTop [diskIO]: Disk I/O

This is the answer to the question on how to set up Multi Router Traffic Grapher. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report