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

Installation and error handling of plug-ins needed for the combination of Cacti and nagios

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Cacti and Nagios installation will not be introduced here.

What we introduce here is the integration of nagios and cacti, first of all, we need to install php json module and ndoutils, in which Ndoutils is a plug-in of nagios, which can be used to store the data obtained by nagios into the mysql database. It is also possible to integrate with cacti's plug-in npc, and the installation of this tool is key. You also need to install and use the npc plug-in. Let's introduce the installation methods one by one.

First, install Php-json

Tar xzf json-1.2.1

Cd json-1.2.1

/ usr/bin/phpize

. / configure

Make

Make install

After installation, add the json module by executing the following statement:

Echo "extension=json.so" > / etc/php.d/json.ini

Using php-m | grep json should display the character json

If this character is not displayed, it proves that the module is not installed correctly

Workaround: yum remove php-common, then reinstall php-common

Second, install Ndoutils

Ndoutils installation

Installation of 1.DBI

Download from the official website http://www.cpan.org/modules/by-module/DBI/

DBI-1.633.tar.gz is downloaded here.

Tar-zxvf DBI-1.633.tar.gz

Cd DBI-1.633

Perl Makefile.PL

Make

Make test

There is a test error here, don't worry about it, continue with the installation.

Make install

2. Installation of DBD

DBD-mysql-4.025

Tar-zxvf DBD-mysql-4.025.tar.gz

Cd DBD-mysql-4.025

Perl Makefile.PL-- libs= "--L/usr/lib64/mysql # mysql is installed in yum. When checking the configuration, the system can generally find the location of header files and library files, without having to configure too many options.

Make

Make test

Make install

3.NDOUTILS installation

Compile and install NDOUtils

Tar-zxvf ndoutils-2.0.0

Cd ndoutils-2.0.0

. / configure-prefix=/usr/local/nagios-enable-mysql

Make

4. Copy a file

My Nagios is 3.5.1, so I copied ndomod-3x.o and ndo2db-3x. If yours is 2.X.x, please copy ndomod-2x.o and ndo2db-2x.

Cd ndoutils-2.0.0

Cd src

Cp ndo2db-3x ndomod-3x.o file2sock log2ndo / usr/local/nagios/bin

Cd / usr/local/nagios/bin

Mv ndo2db-3x ndo2db

Cd config

Cp ndo2db.cfg-sample ndomod.cfg-sample / usr/local/nagios/etc/

Cd / usr/local/nagios/etc

Mv ndo2db.cfg-sample ndo2db.cfg

Mv ndomod.cfg-sample ndomod.cfg

5. Edit ndo2db.cfg profile

Vim / usr/local/nagios/etc/ndo2db.cfg

Lock_file=/usr/local/nagios/var/ndo2db.lock

Ndo2db_user=nagios

Ndo2db_group=nagios

Socket_type=tcp

Socket_name=/usr/local/nagios/var/ndo.sock

Tcp_port=5668

Use_ssl=0

Db_servertype=mysql

Db_host=localhost

Db_port=3306

Db_name=cacti# database name

Db_prefix=npc_

Db_user=cactiuser# database user

Db_pass=huaxia# database password

Max_timedevents_age=1440

Max_systemcommands_age=10080

Max_servicechecks_age=10080

Max_hostchecks_age=10080

Max_eventhandlers_age=44640

Max_externalcommands_age=44640

Debug_level=0

Debug_verbosity=1

Debug_file=/usr/local/nagios/var/ndo2db.debug

Max_debug_file_size=1000000

6. Configure the ndomod.cfg file

Vim / usr/local/nagios/etc/ndomod.cfg

Instance_name=default

Output_type=tcpsocket

Output=127.0.0.1

Tcp_port=5668

Use_ssl=0

Output_buffer_items=5000

Buffer_file=/usr/local/nagios/var/ndomod.tmp

File_rotation_interval=14400

File_rotation_timeout=60

Reconnect_interval=15

Reconnect_warning_interval=15

Data_processing_options=-1

Config_output_options=2

8. Configure the nagios.cfg file

Vi / usr/local/nagios/etc/nagios.cfg

# modify the value of the following parameter to-1 (generally default).

Event_broker_options=-1

# copy the following and paste it into # broker_module=... Down there.

# notice that broker_module= and config_file are on one line

# Uncomment the line below if you're running Nagios 3.x

Broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg

Process_performance_data=1# note that the parameter is changed to startup state.

9. Configure startup script

Cd / usr/local/src/ndoutils-1.5.2

Cp daemon-init / etc/init.d/ndo2db

Chmod + x ndo2db

10. Start the ndo2db service

Service ndo2db start

11. Restart nagios

Service nagios restart

twelve。 View startup log information

[root@BestTone-zabbix var] # tail-f nagios.log

[1468292167] Successfully shutdown... (PID=29500)

[1468292167] ndomod: Shutdown complete.

[1468292167] Event broker module'/ usr/local/nagios/bin/ndomod-3x.o' deinitialized successfully.

[1468292167] Nagios 3.5.1 starting... (PID=14197)

[1468292167] Local time is Tue Jul 12 10:56:07 CST 2016

[1468292167] LOG VERSION: 2.0

[1468292167] ndomod: NDOMOD 1.5.2 (06-08-2012) Copyright (c) 2009 Nagios Core Development Team and Community Contributors

[1468292167] ndomod: Could not open data sink! I'll keep trying, but some output may get lost...

[1468292167] Event broker module'/ usr/local/nagios/bin/ndomod-3x.o' initialized successfully.

[1468292167] Finished daemonizing... (New PID=14198)

[1468293079] ndomod: Still unable to connect to data sink. 721 items lost, 5000 queued items to flush.

Check to see error message ndomod: Could not open data sink! I'll keep trying, but some output may get lost...

[1468293079] ndomod: Still unable to connect to data sink. 721 items lost, 5000 queued items to flush.

From the error message, you can see that ndomod did not save the data in the cacti database, the error solution:

Vim / usr/local/nagios/etc/ndo2db.cfg

Ndo2db_group=apache# changes the subordinate group of the database to apache

Cd / usr/local/nagios/bin

Chown nagios:apache ndo*# changes the subordinate group of the two main programs to apache

Cd.. / etc

Chown nagios:apache ndo*# changed the subordinate group of the two profiles to apache

13. Restart related services

Service ndo2db restart

Service nagios restart

14. Check the startup log again and find that the startup is successful and ndomod has connected to the cacti database

[root@localhost] # tail-f / var/log/messages

Mar 24 09:31:25 localhost nagios: ndomod registered for retention data'

Mar 24 09:31:25 localhost nagios: ndomod registered for contact data'

Mar 24 09:31:25 localhost nagios: ndomod registered for contact notification data'

Mar 24 09:31:25 localhost nagios: ndomod registered for acknowledgement data'

Mar 24 09:31:25 localhost nagios: ndomod registered for contact status data'

Mar 24 09:31:25 localhost nagios: ndomod registered for adaptive contact data'

Mar 24 09:31:25 localhost nagios: Event broker module'/ usr/local/nagios/bin/ndomod-3x.o' initialized successfully.

Mar 24 09:31:25 localhost nagios: Finished daemonizing... (New PID=1828)

Mar 24 10:31:25 localhost nagios: Auto-save of retention data completed successfully.

Mar 24 10:47:35 localhost kernel: hrtimer: interrupt took 3738538 ns

Third, install npc software

Tar-vxzf npc-2.0.4.tar.gz

Mv npc / var/www/html/cacti/plugins/

1. Start npc through the interface

2. In the "Settings" of "console" in Cacti, set the main path of the nagios command file and the path of nagios's URL, check the "Romote Commands" item, and click the "Save" button.

3. Execute the following sql statement in the cacti database

Execute the following sql in mysql:

Mysql > use cacti

Alter table npc_eventhandlers add long_output TEXT NOT NULL default''after output

Alter table npc_hostchecks add long_output TEXT NOT NULL default''after output

Alter table npc_hoststatus add long_output TEXT NOT NULL default''after output

Alter table npc_notifications add long_output TEXT NOT NULL default''after output

Alter table npc_servicechecks add long_output TEXT NOT NULL default''after output

Alter table npc_servicestatus add long_output TEXT NOT NULL default''after output

Alter table npc_statehistory add long_output TEXT NOT NULL default''after output

Alter table npc_systemcommands add long_output TEXT NOT NULL default''after output

4. Restart nagios and ndo2db after the successful execution. The following interface shows the effect of the integration of nagios and cacti:

Problems encountered

1) if the status of the Nagios here is off

I have also encountered, mainly to check whether the ndo2db and cacti library is normal, you can check / var/log/messages

The log information in, can not see the information may be your ndomod.cfg and ndo2db.cfg configuration errors! It is recommended that you check the configuration file. Execute several sql statements prompted above in the cacti database at the same time.

2) if there is no information in the nagios status bar

Find the table npc_programstatus in the cacti database, select programstatus_id, instance_id, status_update_time, last_command_check, last_log_rotation and other fields from the table, and delete the previous record. Refresh for a while, and you should be able to draw the chart. As shown in the following figure:

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

Database

Wechat

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

12
Report