In the 1st part I have configured the nagios and it have started to monitor the instance locally now come on the other part.adding clients to it .
Add a definition of new group for client or in the groups file add the following lines
(if you are really new with Nagios)
change the host ip for me it was 192.168.100.4 it may me some thing else for you.
fire this command and check if you have done any configuration error
Gyus enjoy I will also wotking on PNP4nagios will explain you in the next part how you can have some cool graph of the system performance generated using nagios.
Add Monitoring targets to Nagios server
Now, let us add some clients to monitor by Nagios server.
To do that we have to install nrpe and nagios-plugins in our monitoring targets.
On CentOS/RHEL/Scientifc Linux clients:
Add EPEL repository in your CentOS/RHEL/Scientific Linux 6.x or 7 clients to install nrpe package.
To install EPEL on CentOS 7, run the following command:
yum install epel-release
On CentOS 6.x systems, refer the following link.
Install “nrpe” and “nagios-plugins” packages in client systems:
yum install nrpe nagios-plugins-all openssl
On Debian/Ubuntu clients:
sudo apt-get update
sudo apt-get install nagios-nrpe-server nagios-plugins
Configure Monitoring targets
Edit /etc/nagios/nrpe.cfg file,
sudo nano /etc/nagios/nrpe.cfg
Add your Nagios server ip address:
[...] ## Find the following line and add the Nagios server IP ## allowed_hosts=127.0.0.1 192.168.1.104 [...]
Start nrpe service on CentOS clients:
CentOS 7:
systemctl start nrpe
chkconfig nrpe on
CentOS 6.x:
service nrpe start
chkconfig nrpe on
For Debian/Ubuntu Clients, start nrpe service as shown below:
sudo /etc/init.d/nagios-nrpe-server restart
Now, go back to your Nagios server, and add the clients ( in the configuration file.
To do that, Edit “/usr/local/nagios/etc/nagios.cfg” file,
sudo nano /usr/local/nagios/etc/nagios.cfg
and uncomment the following lines.
## Find and uncomment the following line ##
cfg_dir=/usr/local/nagios/etc/servers
Create a directory called “servers” under “/usr/local/nagios/etc/”.
sudo mkdir -p /usr/local/nagios/etc/serversCopy the localhost.cfg to the server directory with the client name you want i have use cl1
sudo cp -ar /usr/local/nagios/etc/objects/localhost.cfg \ /usr/local/nagios/etc/servers/cl1.cfgCreate a file called groups.cfg in side of /usr/local/nagios/etc/servers/ directory
Add a definition of new group for client or in the groups file add the following lines
(if you are really new with Nagios)
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-server ; The name of the hostgroup
alias Linux Server ; Long name of the group
members cl1 ; Comma separated list of hosts that belong to this group
}
After this save and close the file and lets go to the cl1.cfg file.change the host ip for me it was 192.168.100.4 it may me some thing else for you.
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 cl1
alias cl1.centos.lan
address 192.168.100.4
}
change only which are in bold only. and then remove the section of hot group from the file or you can comment it out. after that seatch for localhost in the file and replace it with your value of host_name in my case its cl1 and save and close the file. if you are not able to do it then fire the below command and it will tale care of the rest for you.sed -i 's/localhost/cl1/g' /usr/local/nagios/etc/servers/cl1.cfgit will replace all the occurances of localhost with cl1. and we are almost done.
fire this command and check if you have done any configuration error
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
and We are done we have successfully added a client to our nagisos. just dont forget ot restart your nagios with also add the required rule in iptables or you can face some issue with it am sure you can manage this sudo systemctl restart nagios
login on your web interface.We have successfully added our first client to nagios for monitoringGyus enjoy I will also wotking on PNP4nagios will explain you in the next part how you can have some cool graph of the system performance generated using nagios.
No comments:
Post a Comment