Use yum lnmp to build cacti in CentOS

Source: Internet
Author: User
Tags rrd rrdtool mrtg

Use yum lnmp to build cacti in CentOS
I. Introduction to cacti network management (such as host load and network traffic monitoring) is an important part of the daily work of system management personnel, many vendors provide their own solutions. One of the most famous early open-source network management software, MRTG, was developed using perl to implement communication between management workstation and device proxy processes through the SNMP protocol, to monitor the device management and running status. The MRTG installation and configuration are simple and the graphic interface is intuitive, because it was widely favored by network administrators at that time, and it also contributed to my early network management work. However, MRTG also has many inherent drawbacks, such as the use of text-based databases, data cannot be reused; data can only be viewed by day, week, month, or year; each graph can only draw two DS (one line and one block). Every Data fetch needs to be drawn once, which wastes system resources. At the same time, it does not provide management functions. In view of this, the author of MRTG later developed another tool, rrdtool. Rrdtool is a data recorder with excellent performance and a powerful drawing engine. It uses the rrd data storage format, and the data can be reused. In terms of plotting, it can define any time period for plotting and draw multiple DS. But it also has its own disadvantages: although it provides powerful data storage and drawing functions, rrdtool does not provide data collection functions similar to those integrated in MRTG. At the same time, it provides too many parameters, making it inconvenient to use the command line interface. In addition, rrdtool does not provide management functions. So cacti came into being.

To put it simply, Cacti is a forefront of rrdtool. It has built-in quick data acquisition tools, excellent drawing templates, and many well-designed data acquisition scripts, this allows you to easily draw trend diagrams of host load, network traffic, and other information by combining the powerful data capture, data storage, and drawing functions of rrdtool. The latest software version is 0.8.7g.

Cacti is a software implemented in php. Its operation requires the support of website servers (such as apache) and PHP environments. At the same time, cacti also requires Mysql to work with PHP programs to store some variable data and call the variable data, such as host name, Host ip address, snmp group name, port number, template information, and other variables. The statistics on host load, network traffic, and other information by rrdtool must be implemented through the SNMP protocol. The data captured by SNMP is stored in rrd files generated by rrdtool, which are usually located in the rra directory of cacti. Rrdtool processes rrd files for data update and storage, and rrd files are static Archive files (Round Robin Archive ), the number of data records it can store has been defined at the time of creation. This picture briefly describes how cacti works.

Cacti instance application

1) network settings
2) host system
(1) network interface traffic (inbound and outbound bandwidth)
(2) monitor CPU load, memory, and so on
(3) Monitoring disk space, number of processes, and so on
......................................... And so on.3) common monitoring objects of cacti
(1) server resources: CPU, memory, disk, process, connections, etc.
(2) server types: WEB, Mail, FTP, database, and Middleware
(3) Network Interfaces: traffic, forwarding speed, and Packet Loss Rate
(4) network device performance, configuration files (comparison and backup), and number of routes
(5) Security Device Performance, connections, and attacks
(6) device running status: fan, power supply, temperature
(7) data center operating environment: current, voltage, temperature and humidity

These are all materials found online .......

Now, the introduction is complete, and we will start to build it this time:

1. Build the lnmp platform and use yum, which is very simple ......

Service snmpd start

Service nginx start

Service php-fpm start

You need to ensure that the boot starts, and selinux is disabled .......

2. Install snmp and use SNMP to collect data

[Root @ www/] # yum-y install lm_sensors net-snmp-utils

3. cacti relies on rrdtool to generate charts. Therefore, you must first install rrdtool:

[Root @ www/] # yum-y install cairo-devel glib2-devel pango-devel intltool install dependency package

[Root @ www/] # wgethttp: // oss. oetiker. ch/rrdtool/pub/rrdtool-1.4.7.tar.gz


[Root @ www/] # tar-zxvf rrdtool-1.4.7.tar.gz

[Root @ www/] # cd rrdtool-1.4.7

[Root @ www/] #./configure -- prefix =/usr/local & make install

4. Go to the database to create cacti data and create a user:

Create database cactidb default charactersetutf8; # create a database grant all on cactidb. * to cactiuser @ localhost identified by '20140901'; # create a mysql user

Use cactidb # use the database you just created

Source/usr/local/nginx/html/cacti. SQL # import cacti data

5. Edit the cacti configuration file

[Root @ www/] # vi/usr/share/nginx/html/cacti/include/config. php

$ Database_type = "mysql"; # Database Type

$ Database_default = "cactidb"; # Database Name

$ Database_hostname = "localhost"; # Database Host

$ Database_username = "cactiuser"; # Database User

$ Database_password = "123456"; # Database Password

$ Database_port = "3306"; # Database Port

$ Database_ssl = false;

6. Modify the nginx configuration file as follows:

[Root @ www cacti] # vi/etc/nginx/conf. d/default. conf

The nginx configuration file for lnmp installed with yum needs to be modified here. If location is modified in nginx. conf, The nginx startup will fail.

Location /{
Root html;
Index. php;
}
Location ~ \. Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
Fastcgi_buffer_size 8 k;
}

Note: This must be correct. Otherwise, the 403 error will be reported, or the page is too large ......

Then restart nginx.

7. Set the time zone:

If this is not set, the page may be full of logs when you access cacti, telling you that the time zone is incorrect.

[Root @ www cacti] # vi include/global_constants.php

Add

date_default_timezone_set("Asia/Chongqing");

8. Configure snmp and edit/etc/snmp/snmpd. conf:

vi /etc/snmp/snmpd.conf

Then, find line 41 and change the public name to a complicated name:

com2sec notConfigUser  default       public

Then 62 rows are found.

access  notConfigGroup ""      any       noauth    exact  systemview none none

Change systemview to all:

access  notConfigGroup ""      any       noauth    exact  all none none

Then remove the comment of 85 rows:

View all supported ded. 1 80

Sometimes this can also be commented out .......

Save the configuration file and start snmp

service snmpd start

9. Schedule Tasks

[Root @ www cacti] # crontab-u cactiuser-e

*/5 * cactier php/var/www/html/cacti/poller. php>/dev/null &# Use cactier to capture data every five minutes. This time should be the minimum interval. I do not recommend you change it to a smaller value.

Then you can access: http: // 192.168.1.31/cacti. In order to save trouble, you will not upload images ......

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.