Performance Tuning and Monitoring, Part 1

SNMP and MRTG

MRTG (Multi Router Traffic Grapher) can be a very handy tool for monitoring network traffic passing through each and every interface of your server. So when you finish monitoring your network traffic, you can configure your network as per your performance needs—which we will be discussing later.

Configuring MRTG is fairly simple. As MRTG polls SNMP (Simple Network Management Protocol) agents, we should first configure SNMP. Remember that MRTG works with Apache, so make sure you install that as well. Here is an MRTG configuration for reference. I am configuring my FTP server that we had used for MRTG. I am using it intentionally so that we have some real network traffic.

First, install SNMP, MRTG and Apache on the system using your package manager. Now, allow the SNMP through tcp-wrapper. Edit /etc/hosts.allow and write snmpd: ALL to allow SNMP.

Use the snmpconf tool to create at least one SNMP community. In the first step, choose /etc/snmp/snmpd.conf. Make sure you are inside the /etc/snmp/ directory before running snmpconf:

The following installed configuration files were found:

    1:  /root/.snmp/snmp.conf

Would you like me to read them in?  Their content will be merged with the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all): 1

In the next step, select snmpd.conf. Then select Access Control Setup.

The configuration information which can be put into snmpd.conf is divided
into sections.  Select a configuration section for snmpd.conf
that you wish to create:

    1:  Access Control Setup
    2:  Extending the Agent
    3:  Monitor Various Aspects of the Running Host
    4:  Agent Operating Mode
    5:  Trap Destinations
    6:  System Information Setup

Other options: finished

Select section: 1

In the next option, select “SNMPv1/SNMPv2c read-only access community name”. When prompted for the name, give the community name as ‘networknuts’ (or anything you like).

Select from:

    1:  a SNMPv3 read-write user
    2:  a SNMPv3 read-only user
    3:  a SNMPv1/SNMPv2c read-only access community name
    4:  a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Configuring: rocommunity
Description:
    a SNMPv1/SNMPv2c read-only access community name
    arguments:  community [default|hostname|network/bits] [oid]

The community name to add read-only access for: networknuts

Enter 0.0.0.0/0 to specify that all networks are allowed to use this community. Though you can also specify your own specific IP range, as per your configurations. When prompted for the OID, just press ENTER and then type Finished. And then in the end, type quit.

Select section: finished

I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

    1:  snmpd.conf
    2:  snmptrapd.conf
    3:  snmp.conf

Other options: quit

We had just finished configuring SNMP on our system. Now our job is to point MRTG to this community and display the graphical network statistics.

We have already installed the MRTG and Apache. So what’s left is to configure MRTG to use the ‘networknuts’ community.

Step 1: Edit /etc/httpd/conf/mrtg.conf to allow access from our network.

Allow      .example.com

Step 2: Create a configuration file to monitor network traffic on SNMP agents:

cfgmaker --ifref=name --global "workdir: /var/www/mrtg" [email protected] > /etc/mrtg/mrtg.cfg

Step 3: Update MRTG to run after every four minutes by editing /etc/cron.d/mrtg as follows:

*/4 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok

Step 4: Before closing the above file just copy everything after “root” (that is, starting with LANG=C) using the mouse. We will be using cron to populate our RRD file.

Step 5: Now execute the command given below:

# for x in $(seq 1 3); do LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok; done

If you get any errors, don’t worry and just repeat the same command again.

Step 6: Now run indexmaker to create the /var/www/mrtg/index.html file:

# indexmaker /etc/mrtg/mrtg.cfg  >  /var/www/mrtg/index.html

Figure 8 shows the output of both the above commands.

Figure 8: Terminal output for mrtg configuration commands

Figure 8: Terminal output for mrtg configuration commands

Congrats, you have just configured SNMP and MRTG successfully. Time to restart your snmp and httpd services. Now open the browser and view the MRTG output, by pointing your browser to http://server1.example.com/mrtg. You should see something similar to Figure 9.

Figure 9: MRTG index page

Figure 9: MRTG index page

Well, that’s it for this session. Next time, we’ll look at how to tune the HDD I/O using elevators. We’ll also learn about the queuing theory and how to configure a performance RAID.

  • Krishna

    Where is the Tuning part.This is only monitoring part.

  • senthil

    Where is the tuning part – please tell us how to tune following item

    1. Disk I/O Writes
    2. Tuning Network waittime/connection/max_number_of_connection
    3. CPU Tuning per process/maximum/minimum
    4. Tuning swap for process and etc

  • Dhammanand

    Topic Name Should be change to Monitoring , there no single of tunning related in this topic

  • http://www.fromdev.com Priya

    I agree with @Dhammanand, these are more statistics and monitoring but I guess are very important to start on tuning.

  • senthil

    yes Its very important please priya start writing the article abt tuning

All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherwise noted.
Open Source For You is powered by WordPress, which gladly sits on top of a CentOS-based LEMP stack.

Creative Commons License.