Turn: Powerful Drawing Engine of rrdtool

Source: Internet
Author: User
Tags rrd rrdtool snmp snmpget snmpwalk mrtg

Architecture Based on rrdtool + cacti Performance Monitoring System
Collect and organize the Linux inventory by ipaddr time:
   
 
 
 
 

From: Linux inventory
Contact: linuxmine # gmail.com
Category: [network monitoring]

Baidu


I. Overview
In Linux, the most used is MRTG performance monitoring. MRTG configuration is relatively simple, and mrtg is indeed very good, but I think it is already a very old set of software, the author has developed rrdtool to replace the software many years ago and is now very mature. Since there is a better choice, why should we use MRTG?
To put it simply, rrdtool is a powerful drawing engine, which can be called by many languages.
The architecture of the entire system is as follows:
Based on the SNMP protocol, the monitored end is a server or some network devices,
The network management workstation uses the Linux (or FreeBSD) Operating System, installs the net-snmp tool, uses rrdtool to collect data, store data, and uses cacti to call rrdtool for display.
Cacti is written in PHP and is based on the B/S structure.
II. Introduction
Advantages of MRTG: simple and easy to use. After installation, you only need to change the configuration file.
Disadvantages:
1. text-based databases cannot be reused;
2. data can only be viewed by day, week, month, or year;
3. Only two Ds (one line and one block) can be drawn );
4. drawing is required every time data is retrieved, which wastes system resources;
5. No management functions;

Advantages of rrdtool:
1. Data can be reused in RRD storage format. For example, I can add the data in an RRD file to the data in another RRD file.
2. You can define a graph for any time period, that is, you can draw a graph of data from the past six months or a graph of the past half an hour.
3. can draw any Ds.
4. cdef allows you to play with data at will.

Disadvantages:
1. rrdtool is only used to store data and draw images. It does not have the data collection function integrated in MRTG;
2. The use of command lines is very complex, with many parameters.
3. No management function.

In short, rrdtool is a powerful drawing engine.

Because of its complex commands and unfriendly user experience, I wanted to write a system in PHP. Fortunately, I found cacti (www.cacti.net) six months ago ). I only have one word for this tool: "Great !".
Cacti is actually a PHP program that uses snmpget to collect data and rrdtool to plot data. Its interface is very beautiful, so that you do not need to understand the rrdtool parameters to easily draw beautiful images. Even more valuable, it provides powerful data management and user management functions. A graph belongs to a host, and each host can be attached to a tree structure. In terms of user management, as an open-source software, it can actually specify a "Tree", host ", or even each graph that a user can view, you can also use LDAP for user verification! I can't help admiring the thoughtful consideration of the Author! Cacti also provides its own template function, allowing you to add your own snmp_query and script! It can be said that cacti makes up all the "disadvantages" of rrdtool!

3. monitoring management workstation configuration
In Linux, cacti uses net-snmp, rrdtool, aapche, PHP, and MySQL. The installation process is as follows:
1. install Apache + MySQL + PHP
The installation process is relatively simple. For more information, note that it is best to add SNMP support to PhP. during compilation, add-enable-SNMP.
Note. PHP cannot run in safe mode. Otherwise, cacti does not work properly. The program under/usr/local/bin/cannot be called.
2. Install rrdtool
Official Website: http://people.ee.ethz.ch /~ Oetiker/WebTools/rrdtool/
Download:
Http://people.ee.ethz.ch /~ Oetiker/WebTools/rrdtool/pub/rrdtool-1.0.x/rrdtool-1.0.50.tar.gz
Then
./Configure-Prefix =/usr/local/rrdtool
Make
Make install

Compared with MRTG, rrdtool comes with the GD library, so you do not need to install the GD library first. (However, because the GD library provided by rrdtool does not support Chinese characters, the diagram drawn by rrdtool cannot contain Chinese characters. Otherwise, garbled characters may occur ).

Note: The version of rrdtool1.2 no longer comes with external lib libraries (such as cgilib and zlib), so you need to download the SDK from http: // people. ee. ethz. ch /~ Oetiker/WebTools/rrdtool/pub/libs/download these libraries for installation. We recommend that you use version 1.0 for ease of use.

Run rrdtool to check whether the installation is correct,
If the command fails to be executed and the system prompts that the command does not exist, copy all executable files of rrdtool to/usr/local/bin.
CP/usr/local/rrdtool/bin/*/usr/local/bin

3. Install net-snmp
The SNMP service is installed under RH, but it seems that there are no snmpwalk or snmpget commands, so net-snmp needs to be installed. NET-SNMP Official Website: http://www.net-snmp.org/
Download net-snmp-5.1.3.1.tar.gz
Tar zxvf net-snmp-5.1.3.1.tar.gz
CD net-snmp-5.1.3.1
./Configure
Make
Make install
Run snmpget and snmpwalk to test whether the installation is successful.
The snmpwalk name of the RPM package is net-snmp-utils. *. rpm. You can also install it from the installation disc.
4. Install cacti
Http://www.cacti.net/
A) install the cacti source file
Download cacti-0.8.6f.tar.gz
Decompress the package to the root directory of the website.
# Cp cacti-0.8.6f.tar.gz/usr/local/apache2/htdocs
# Cd/usr/local/apache2/htdocs
# Tar xzvf cacti-0.8.6f.tar.gz
# Music cacti-0.8.6f cacti
# Chown-r Apache. Apache cacti
# Cd cacti

B) configure the MySQL database
Configure users and databases for cacti:
# Mysql-u root-P
Mysql> Create Database cactidb;
Mysql> grant all privileges on cactidb to cactiuser @ localhost identified by 'Password ';
Mysql> quit
Configure cacti to connect to the database
# Vi/usr/local/apache2/htdocs/cacti/include/config. php

$ Database_type = "MySQL ";
$ Database_default = "cactidb ";
$ Database_hostname = "localhost ";
$ Database_username = "cacti ";
$ Database_password = "password ";
C) run the cacti data collection program on the regular crontab.
# Vi/etc/crontab
*/5 */usr/local/bin/PHP/usr/local/apche2/htdocs/cacti/poller. php>/dev/null 2> & 1

D) Configure cacti
Enter:
Http: // ip/cacti
Go to the initial cacti settings page:
Here we need to enter some original information:

Next-"
Enter some information, such as the location of rrdtool, PHP, snmpwalk, and snmpget, and use UCD-SNMP or net-snmp.
Enter the original user and password: admin/admin-
Change admin user password-"
Click Save

Installation Complete !!!
Now you can enter the cacti world in the browser!
5. Test

Iv. configuration on the monitored end
In most cases, we monitor servers. Take RedHat Linux as an example to see how to enable the SNMP service.
The monitoring end can collect data only when the SNMP service is enabled.
Open the default/etc/snmp. conf file and change the following Configuration:
1. Search for the following fields:
Code:
# Sec. Name source community
Com2sec notconfiguser default public

Change the "Comunity" field to the password you want to set, for example, "public ".
Change "default" to which machine you want to view your SNMP information, such as 10.10.10.10.

2. Search for the following fields: code:
####
# Finally, grant the Group read-only access to the systemview view.
# Group context sec. Model sec. Level prefix read write notif
Access notconfiggroup "" any noauth exact all none

Change the "read" field to all.
Code:
# Access notconfiggroup "" any noauth exact systemview none

3. Search for the following fields: code:
# Incl/excl subtree mask
# View all supported ded. 1 80
Remove "#" before this row.

Save and close.

4. Run the/etc/init. d/snmpd start command to run snmpd.
5. If a firewall exists, open UDP port 161.
Run netstat-ln to check whether port 161 is enabled.

Use ntsysv to enable the SNMP service to run automatically at each startup.
If the SNMP service is not installed, find the net-snmp.rpm on the Rh installation CD and install it again.

V. Test
Open the local SNMP service,
Open http: // localhost/cacti
By default, cacti has four parameters of localhost, which can be viewed directly.

6. troubleshooting
1. First, check whether there is data In RRA /.
2. snmpwalk-V 2C-C public serverip if is used to test whether the SNMP service is enabled for the controlled object (serverip ).
3. snmpwalk-V 2C serverip-C public. 1.3.6.1.4.1.2021.10.1.3 check whether the controlled end has CPU load data returned
4./usr/local/bin/PHP/usr/local/apche2/htdocs/cacti/poller. php is used to test whether PHP can collect data. If the above information is correct, but this step fails, it is likely that the PHP configuration is incorrect or sulinux is enabled.
5. If data can be collected in step 1 snmpwalk but cannot be collected in step 2, it may be a problem with PHP settings. Modifying PHP. ini may be caused by PHP permissions.

VII. Installation of rrdtool1.2
The rrdtool of version 1.2 draws more beautiful images than those of version 1.0. GD is used in version 1.0 and libart and FreeType is used in version 1.2. It takes a little longer to draw images.
Version 1.2 installation, can see http://bbs.chinaunix.net/forum/viewtopic.php? T = 552224
The above installation is troublesome and requires a lot of libraries to be installed. In fact, yes. You can directly install rpm and RedHat systems. You can find these libraries on the installation disc and install them. major packages include:
Libart_lgpl
Libart_lgpl-devel
Libpng
Libpng-devel
Zlib
Zlib-devel
FreeType
FreeType-devel
Find the above packages and run rpm-IVH *. RPM directly.
It seems that cgilib does not exist, and the cgilib downloaded from the official website of rrdtool cannot be installed. We do not need rrdcgi, so we can leave it empty.
Decompress rrdtool 1.2 after installation.
./Configure-Prefix =/usr/local/rrdtool-Disable-rrdcgi
Make
Make install
CP/usr/local/rrdtool/bin/*/usr/local/bin/

Refer:
Rrdtool teaching http://www.study-area.org/tips/rrdtool/rrdtool.html
Monitoring System Performance http://bbs.chinaunix.net/forum/viewtopic.php using cacti? T = 594019

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.