Adding hosts and services to Nagios - Redhat hosts
Adding Redhat host to Nagios
1. Connect to Nagios server (nagios.apoyar with neal username and apoyar.key)
- cd /usr/local/etc/nagios/objects/machines
- open and edit .cfg file (depending on whether we are adding host for Apoyar or other customers)
2. Add the host name in member list to recognize Nagios probe for checks
Save file (:wq!) and exit vi editor
Go to below path
• cd /usr/local/etc/nagios/objects
• vi services.cfg
3. Add the new hostname to the services, which we need for new server in Nagios to monitor.
Save file (:wq!) and exit vi editor
4. Need to create user name with home folder for user
- adduser nagios
Set password for nagios to access from Nagios server
- passwd nagios
- cd /home/nagios
- mkdir .ssh
- mkdir bin
5. After that need to change owner of those folder which is created by root.
- chown nagios:nagios .ssh/ -R
- chown nagios:nagios bin –R
6. Copy public key (authorized_keys) file from any existing working server to access server password authentication less and change permissions on it as below
chmod 500 /home/nagios/.ssh/authorized_keys
chown nagios:nagios /home/nagios/.ssh/ authorized_keys then try to ssh new server from nagios server (It should work)
7. Need to install nagios packages on host machine
yum install nagios-plugins
yum install perl
yum install python3-psutil
ln -s /bin/python3 /usr/bin/python
yum updateinfo
dnf install perl-Array-Unique
dnf install perl-File-Slurp
dnf install perl-Number-Format
dnf install perl-utils
dnf install nagios-plugins-perl
dnf install perl-LWP-Protocol-https
8. Copy required plugins from existing server on new server into bin folder and change permissions on those plugins as below
chmod 755 /home/nagios/bin/*
chown nagios:nagios /home/nagios/bin/*
9. Run below command on nagios server and check syntax errors with below command
/usr/local/bin/nagios -v /usr/local/etc/nagios/nagios.cfg
10. If we got all errors and warning zero, then go to nagios dashboard (nagios.apoyar.eu) and restart the nagios process it.