Cacti+nagios Monitoring platform for Perfect integration

Source: Internet
Author: User
Tags php language php json rrdtool snmp snmp error

Recently there are many students on nagios and cacti integration is very tangled, close-up this article for your reference, to solve everyone in nagios and cacti integration process encountered problems.

One, cacti installation deployment

As a Linux SA, the most important thing in daily life is to ensure the normal and stable operation of the website, we need to monitor the running state of the website and the server in real time, then we need to use open source software (cacti, nagios, Zabbix, etc.) monitoring to realize.

Cacti is a PHP language implementation of a software, its main function is to use the SNMP service to obtain data, and then use RRDtool to store and update the data, when the user needs to view the data with the RRDtool to generate a chart presented to the user. Therefore, SNMP and RRDtool are the key to cacti.

SNMP is related to the collection of data, RRDtool is related to data storage and chart generation. The SNMP catch data is not stored in MySQL, but exists in the RRDtool generated RRD file (under the Rra folder in the cacti root directory, the RRA suffix is typically the name). The simple schematic diagram is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/51/53/wKiom1RjLqGQZj6_AADtWDiurSU684.jpg "title=" 1.png " alt= "Wkiom1rjlqgqzj6_aadtwdiursu684.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

1, cacti server-side installation

Download cacti related software, total need three software, the following:

http://www.cacti.net/downloads/cacti-0.8.8a.tar.gzhttp://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gzhttp:/ /www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz

2. Install Lamp system Environment

Here is the Yum installation, with the installation command:

Yum install httpd mysql mysql-server php php-mysql php-json php-pdo-y

3, install RRDtool Collection tool

Before installing the RRDtool, you need to install the appropriate Lib library, as follows:

Yum install cairo-devel libxml2-devel pango pango-devel–ytar xzf rrdtool-1.4.5.tar.gz; cd rrdtool-1.4.5;./configure- -prefix=/usr/local/rrdtool/make &&make install;ln-s/usr/local/rrdtool/bin/*/usr/local/bin/

4. Install SNMP Service

Yum Install Net-snmp Net-snmp-utils–y

5, install cacti main program

Tar xzf cacti-0.8.8a.tar.gz && mv cacti-0.8.8a/var/www/html/cacti/

6. Create a cacti database

Mysql-uroot–p Enter your password into the database and create the database: Create database cacti; grant all on cacti.* [email protected] ' localhost ' identifi Ed by "123456"; Create user and authorize flush privileges; Refresh Permissions

7. After MySQL configuration is complete, import the cacti data into the cacti database.

mysql-ucacti-p123456 cacti</var/www/html/cacti/cacti.sql After configuring MySQL, we need to set cacti RRA, log directory permissions, this is set to 777:chmod-r 77 7/var/www/html/cacti/rra/chmod-r 777/var/www/html/cacti/log/

8. Modify the cacti global configuration file

The vi/var/www/html/cacti/include/config.php is configured as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/51/53/wKiom1RjLq-whgGYAAI-UjHp99o579.jpg "title=" 2.png " alt= "Wkiom1rjlq-whggyaai-ujhp99o579.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

9. Add RRDtool Capture Task plan

*/5 * * * */usr/bin/php/var/www/html/cacti/poller.php >>/tmp/cacti_rrdtool.log 2>&1

10, cacti installation completed, test access

Via http://ip/cacti/access the following interface appears, click Next Next.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/51/51/wKioL1RjLymQ1yM5AALp9Ve5jgg677.jpg "title=" 3.png " alt= "Wkiol1rjlymq1ym5aalp9ve5jgg677.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

The default is always click Next:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/51/53/wKiom1RjLsrwAzozAAG3etnSBdQ560.jpg "title=" 4.png " alt= "Wkiom1rjlsrwazozaag3etnsbdq560.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

Enter the login interface, the first time you need to change the password:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/51/51/wKioL1RjL0DAXO7PAADu0rFQyuo031.jpg "title=" 5.png " alt= "Wkiol1rjl0daxo7paadu0rfqyuo031.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

11. Enter the cacti configuration management interface

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/51/53/wKiom1RjLt3QfqEnAAF1-gbA02s729.jpg "title=" 6.png " alt= "Wkiom1rjlt3qfqenaaf1-gba02s729.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

12, click on the device, you can add devices, the default can see 127.0.0.1 this server. Add the device to the upper right corner.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/51/53/wKiom1RjLuaA_uUoAANYI2LaHFA190.jpg "title=" 7.png " alt= "Wkiom1rjluaa_uuoaanyi2lahfa190.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

Click localhost to see the specific settings, including the version of the SNMP protocol used, the name of the monitoring, and so on:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/51/51/wKioL1RjL13iNeTSAAQ-gKm1Doo377.jpg "title=" 8.png " alt= "Wkiol1rjl13inetsaaq-gkm1doo377.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

If SNMP error occurs, check whether the SNMP service is started or has permissions. The message appears as normal.

Click the second button in the top left corner, graphs view cacti image-select localhost-the right side will display cacti every 5 minutes of the monitor image.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/51/53/wKiom1RjLvuwRsqyAAUTFoNPYUE616.jpg "title=" 9.png " alt= "Wkiom1rjlvuwrsqyaautfonpyue616.jpg" width= "680" height= "0" border= "0" hspace= "0" vspace= "width : 680px;height:300px; "/>

More cacti in-depth knowledge, can communicate together.

ii. nagios Deployment Configuration

Given the length of the problem, the Nagios deployment here is skipped, interested students can refer to my from the introductory to the advanced course oh, here directly explain how nagios+cacti to integrate.

The first step is to install the PHP JSON module and the Ndoutils, where Ndoutils is a plugin for Nagios, which can be used to deposit Nagios's acquired data into the MySQL database. Integration with cacti's plugin NPCs is also possible, and the installation of this tool is a key.

Php-json Installation Method:

wget Http://down1.chinaunix.net/distfiles/json-1.2.1.tgztar XZF json-1.2.1; cd json-1.2.1;/usr/bin/phpize;. /configure, make, make, install

After the installation, then execute the following statement to add the JSON module:

echo "Extension=json.so" >/etc/php.d/json.ini

To restart the Apache server, you can see the following on the phpinfo.php page:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/51/53/wKiom1RjLxDhE8zdAADj2yO1p8g683.jpg "title=" 10.png "alt=" wkiom1rjlxdhe8zdaadj2yo1p8g683.jpg "width=" 680 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 680px;height:300px; "/>

1, installation ndoutils:

wget Http://downloads.sourceforge.net/project/nagios/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gztar Xzf NDOUTILS-1.4B9.TAR.GZ;CD ndoutils-1.4b9;. /configure--with-mysql-inc=/usr/include/mysql--with-mysql-lib=/usr/lib/mysql--enable-mysql--with-ndo2db-user= Nagios--with-ndo2db-group=nagios&&make &&make Install

Next Configure Ndoutils:

CP Config/ndo2db.cfg-sample/usr/local/nagios/etc/ndo2db.cfg

CP Config/ndomod.cfg-sample/usr/local/nagios/etc/ndomod.cfg

Ndo2db.cfg content is as follows:

Ndo2db_user=nagiosndo2db_group=nagiossocket_type=tcpsocket_name=/usr/local/nagios/var/ndo.socktcp_port=5668db_ Servertype=mysqldb_host=localhostdb_port=3306db_name=cactidb_prefix=npc_db_user=cactidb_pass=123456max_ Timedevents_age=1440max_systemcommands_age=10080max_servicechecks_age=10080max_hostchecks_age=10080max_ Eventhandlers_age=44640debug_level=1debug_verbosity=1debug_file=/usr/local/nagios/var/ndo2db.debugmax_debug_ file_size=1000000

Ndomod.cfg content is as follows:

instance_name=defaultoutput_type=tcpsocketoutput=127.0.0.1tcp_port=5668output_buffer_items=5000buffer_file=/ Usr/local/nagios/var/ndomod.tmpfile_rotation_interval=14400file_rotation_timeout=60reconnect_interval= 15reconnect_warning_interval=15data_processing_options=-1config_output_options=2

Also add the following statement at the end of the Nagios.cfg file:

BROKER_MODULE=/USR/LOCAL/NAGIOS/BIN/NDOMOD.O config_file=/usr/local/nagios/etc/ndomod.cfg

2. Install NPC Software:

wget ftp://ftp.mirrorservice.org/sites/downloads.sourceforge.net/g/gi/gibtmirdas/npc-2.0.4.tar.gz

Tar xzf npc-2.0.4.tar.gz; MV npc/var/www/html/cacti/plugins/

Enabling NPCs via the interface

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/51/51/wKioL1RjL4ngeNIpAAGutIHsFUA752.jpg "title=" 11.png "alt=" wkiol1rjl4ngenipaagutihsfua752.jpg "width=" 680 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 680px;height:300px; "/>

3, select Enable, and then click Settings, Find NPC items, fill in the following content.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/51/53/wKiom1RjLyfwZSEeAAQoClyfAo0312.jpg "title=" 12.png "alt=" wkiom1rjlyfwzseeaaqoclyfao0312.jpg "width=" 680 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 680px;height:300px; "/>

4. Then start the NOD2DB service in the background:

/usr/local/nagios/bin/ndo2db-c/usr/local/nagios/etc/ndo2db.cfg

Viewing the background log also requires the following SQL to be executed in MySQL:

Mysql> use cacti;alter table npc_eventhandlers addlong_output text not  NULL default  '  after output;alter table npc_hostchecks addlong_ output text not null default  '  after output;alter table npc_ hoststatus addlong_output text not null default  '  after output;alter  table npc_notifications addlong_output TEXT NOT NULL default  '   After output;alter table npc_servicechecks addlong_output text not null  default  '  after output;alter table npc_servicestatus addlong_output  text not null default  '  after output;alter table npc_statehistory  addlong_output TEXT NOT NULL default  '  after output;alter table  npc_systemcommands addlong_output text not null default  '  after output; 

After successful execution, restart Nagios and ndo2db, and with page refresh you can see that the following interface represents the success of the integration.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/51/52/wKioL1RjL6bw-7bYAATC-l1PqjI207.jpg "style=" width : 680px;height:300px; "title=" 13.png "alt=" wkiol1rjl6bw-7byaatc-l1pqji207.jpg "width=" 680 "height=" "border=" 0 " Hspace= "0" vspace= "0"/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/51/53/wKiom1RjLznAKh49AAW9rA9gy9A663.jpg "style=" width : 680px;height:300px; "title=" 14.png "alt=" wkiom1rjlznakh49aaw9ra9gy9a663.jpg "width=" 680 "height=" "border=" 0 " Hspace= "0" vspace= "0"/>

Since then, NAGIOS+CACTI integration is complete, welcome everybody to exchange together!

This article is from the "Wu Guangko-focus on automated Operations" blog, please be sure to keep this source http://wgkgood.blog.51cto.com/1192594/1575830

Cacti+nagios Monitoring platform for Perfect integration

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.