Add a New Host For Monitoring Nagios (DB-Instance)
Configuration
DB-Instance
Install Prerequirement
apt update
apt install -y autoconf gcc libmcrypt-dev make libssl-dev dc build-essential gettext libdbd-mysql-perl
Download Source
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.4.6.tar.gz
tar zxf nagios-plugins.tar.gz
Install and compile
cd nagios-plugins-release-2.4.6/
./tools/setup
./configure
make
make install
Install NRPE Daemon on Agent
apt install -y autoconf automake gcc libc6 libmcrypt-dev make libssl-dev
Download NRPE (nrpe-4.1.0)
cd /tmp
wget --no-check-certificate -O nagios-nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.1.0/nrpe-4.1.0.tar.gz
tar zxf nagios-nrpe.tar.gz
Configure script and compile NRPE
cd nrpe-4.1.0/
./configure --enable-command-args
sudo make all
sudo make install-groups-users
sudo make install
sudo make install-config
sudo make install-init
Update Agent NRPE Configuration\
nano /usr/local/nagios/etc/nrpe.cfg
line 61 : add ip 0.0.0.0
line 106 : add the NMS Nagios private server ip
line 306 : add the script
systemctl start nrpe.service
systemctl enable nrpe.service
systemctl status nrpe.service
Install mysql_health Plugin
cd
wget https://labs.consol.de/assets/downloads/nagios/check_mysql_health-2.2.2.tar.gz
tar xzf check_mysql_health-2.2.2.tar.gz
cd check_mysql_health-2.2.2/
./configure
make
cp plugins-scripts/check_mysql_health /usr/local/nagios/libexec
Create Database
mysql -u root -p
create user 'nagiosrizwan'@'%' identified by 'pass123';
GRANT SELECT, PROCESS, SUPER ON *.* to 'nagiosrizwan'@'%';
flush privileges;
NMS-Nagios
Install pre-requisites package
apt -y install libdbd-mysql-perl
Install mysql_health Plugin
cd
wget https://labs.consol.de/assets/downloads/nagios/check_mysql_health-2.2.2.tar.gz
tar xzf check_mysql_health-2.2.2.tar.gz
cd check_mysql_health-2.2.2/
./configure
make
cp plugins-scripts/check_mysql_health /usr/local/nagios/libexec
## Define Host - DB Instance
define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name <linux-host2>
alias mysql_server
address <ip-private-db>
notification_interval 1
notification_options d,u,r,f,s
check_interval 1
retry_interval 1
contact_groups admins
notifications_enabled 1
notification_period 24x7
}