1. 连接被监控端出现Connection reset by peer 的问题
1 | 使用官方安装脚本(./fullinstall)在配置Allow host 时未输入监控端地址或输入错误导致的问题 |
2. 监控端只需要编译出check_nrpe 插件,并放到相应的位置即可
1 | 1. 直接从被监控端拷贝,并修改权限 |
CentOS 安装NDOUtils
Prerequisites
Installing MySQL or MariaDB is required.
CentOS 5.x / 6.x
1 | yum install -y mysql mysql-server mysql-devel |
CentOS 7.x
1 | yum install -y mariadb mariadb-server mariadb-devel |
Start And Configure MySQL / MariaDB
Before configuring MySQL / MariaDB you must start the service and configure it to boot on startup.
CentOS 5.x / 6.x
1 | service mysqld start |
Check that it is running:
1 | ps x | grep mysql | grep -v grep |
Which should output something like:
1 | 1969 pts/0 S 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql |
Configure it to start when the system boots:
1 | chkconfig --add mysqld |
CentOS 7.x
1 | systemctl start mariadb.service |
Check that it is running:
1 | ps ax | grep mysql | grep -v grep |
Which should output something like:
1 | 2781 ? Ss 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr |
Configure it to start when the system boots:
1 | systemctl enable mariadb.service |
Define MySQL / MariaDB Root Password
Now to define the password for the root account in MySQL / MariaDB.
The password being defined is ‘mypassword‘ and will be used in future commands (we suggest you use a more secure password).
The ‘single quotes‘ are used to define the boundaries of the password, this is extremely important when the password contains a space or special characters.
1 | /usr/bin/mysqladmin -u root password 'mypassword' |
Password Note:
In future commands you will see the password is provided using the -p argument like follows:
1 | mysql -u root -p'mypassword' |
NOTE: It’s very important to NOT put a space between the -p and the ‘mypassword’.
Create Database
NDOUtils requires a database to be created which will be called nagios.
There will also be a dedicated user account called ndoutils with the password ndoutils_password (we suggest you use a more secure password).
The storage location of the database will be the default location that MySQL / MariaDB uses, this can be changed however it is not covered in this guide.
This command will connect to the local MySQL / MariaDB database engine interface.
1 | mysql -u root -p'mypassword' |
Now execute these four commands (press **Enter** after each command):
1 | CREATE DATABASE nagios DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; |
Now you can exit the local MySQL / MariaDB database engine interface.
1 | \q |
Run this command to ensure that the database has been created:
1 | echo 'show databases;' | mysql -u ndoutils -p'ndoutils_password' -h localhost |
The last command should output something like:
1 | Database |
Linux Kernel Settings
NDOUtils uses the kernel message queue for transferring the data from Nagios to NDOUtils. We are going to increase the default values the Kernel boots with to ensure it operates optimally.
First create a backup copy of the /etc/sysctl.conf file:
1 | cp /etc/sysctl.conf /etc/sysctl.conf_backup |
Now make the required changes:
1 | sed -i '/msgmnb/d' /etc/sysctl.conf |
The last command should output something like:
1 | net.ipv4.ip_forward = 0 |
There is no need to reboot the system, the last command ensured the new settings are active in the kernel.
Downloading NDOUtils Source
1 | cd /tmp |
Compile NDOUtils
1 | cd /tmp/ndoutils-2.1.3/ |
Install Binaries
This step installs the binary files.
1 | make install |
Initialize Database
This prepares the database for NDOUtils.
1 | cd db/ |
The command will produce output similar to the following:
1 | DBD::mysql::db do failed: Table 'nagios.nagios_dbversion' doesn't exist at ./installdb line 52. |
That first line of output that says failed: Table ‘nagios.nagios_dbversion’ doesn’t exist is expected, it’s testing to make sure the database hasn’t already been intiaialized.
Install Configuration Files
This installs the config files as well as configuring the MySQL / MariaDB credentials so NDOUtils can connect to the database.
The two config files are:
/usr/local/nagios/etc/ndo2db.cfg
The following lines are defined in this file:
1 | db_user=ndoutils |
You should make sure the username and password are correct.
/usr/local/nagios/etc/ndomod.cfg
No changes are required in this file.
Using the default username and password the following commands install the configuration files and make the required changes.
1 | make install-config |
Install Service / Daemon
This installs the service or daemon files and configure them to start on boot.
CentOS 5.x / 6.x
1 | make install-init |
CentOS 7.x
1 | make install-init |
Information on starting and stopping services will be explained further on.
Start Service / Daemon
Different Linux distributions have different methods of starting the ndo2db service.
CentOS 5.x
1 | service ndo2db start |
CentOS 6.x
1 | start ndo2db |
CentOS 7.x
1 | systemctl start ndo2db.service |
Update Nagios To Use NDO Broker Module
Now you need to tell Nagios to use the NDO broker module. This is as simple as adding the following line to the nagios.cfg file:
1 | broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg |
The following commands will add that line as well as an extra line that explains what the module is for.
1 | printf "\n\n# NDOUtils Broker Module\n" >> /usr/local/nagios/etc/nagios.cfg |
Restart Nagios
Now you need to restart Nagios to use the NDO broker module. Different Linux distributions have different methods of restarting Nagios Core. We will also check the status of the Nagios service to ensure it’s running after these changes.
CentOS 5.x / 6.x
1 | service nagios restart |
CentOS 7.x
1 | systemctl restart nagios.service |
The last command should show Nagios running:
CentOS 5.x / 6.x
1 | nagios (pid 5345) is running... |
CentOS 7.x
1 | ● nagios.service - LSB: Starts and stops the Nagios monitoring server |
Check NDOUtils Is Working
There are a couple of different ways to ensure NDO2DB is working.
This command will show Nagios successfully loaded the NDO module:
1 | grep ndo /usr/local/nagios/var/nagios.log |
The last command should output something like:
1 | [1475544660] ndomod: NDOMOD 2.1.1 (09-06-2016) Copyright (c) 2009 Nagios Core Development Team and Community Contributors |
This command will show you the database with populated data:
1 | echo 'select * from nagios.nagios_logentries;' | mysql -u ndoutils -p'ndoutils_password' |
The last command should output something like:
1 | logentry_id instance_id logentry_time entry_time entry_time_usec logentry_type logentry_data realtime_data inferred_data_extracted |
Service Commands
Different Linux distributions have different methods of starting / stopping / restarting / status ndo2db.
CentOS 5.x
1 | service ndo2db start |
CentOS 6.x
1 | start ndo2db |
CentOS 7.x
1 | systemctl start ndo2db.service |