NAGIOS
To install the nagios core :-
Make the repo
Then, check the ping
user
# useradd nagios
# wget -o nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.5.8.tar.gz
# tar -xvf nagioscore.tar.gz
# groupadd nagcmd
# usermod -aG nagcmd nagios
# cd nagioscore-nagios-4.5.8
# ./configure
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf
# cd /
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# systemctl enable –now httpd
# systemctl enable –now nagios
# firewall-cmd --permanent --add-service=http
# firewall-cmd –reloadfirew interface :-
http://<ip of nagios server>/nagios
To install plugins :-
# wget -o http://nagios-plugins.org/download/nagios-plugins-2.4.12.tar.gz
# cd nagios-plugins-2.4.12
# ./configure
# make all
# make install
NAGIOS
# cd /
# cd /usr/local/nagios/libexec ( some files comes in to this file so my plugins have been done)
# cd /
# systemctl restart nagios
# systemctl restart httpd
Then check on browser
http://<ip of server>/nagios
( then services will be up)
Client Machine :- { to install the plugins}
# wget https:/wh/github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.12/nagios-plugins-
2.4.12.tar.gz
# yum install gcc glibc glibc-common make php gd gd-devel wget net-snmp openssl-devel
# useradd nagiosuser
# tar xvf nagios-plugins-2.4.12
# cd /nagios-plugins-2.4.12
# ./configure
# make all
# make install
#cd /usr/local/nagios/
#cd libexec ( some files will be come in this like green colour)
To install the nrpe for adding host :-
ma
lsls
# cd /nrpe-4.1.1/
# ./configure
# mak
# make install
# make install-init
# make install-config
# vim /usr/local/nagios/libexec/check_nrpe -H 192.168.1.212 -c check_users ( check the connectivity
Cd /
NAGIOS
# vim /usr/local/nagios/etc/nrpe.cfg ( this is the main file)
Mention the ip entries of nagios server)
Allowed_hosts = <ip of server>
# systemctl enable –now nrpe
# firewall-cmd –permanent –add-service=nrpe
# firewall-cmd --reload
# netstat -ntulp | grep “5666”
fi
Server side :-
# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.1.1/nrpe-4.1.1.tar.gz
# tar xvf nrpe-4.1.1.tar.gz
# cd nrpe-4.1.1/
# ./configure
# make all
# make install
#make install-init
# make install-config
# cd /
# vim /usr/local/nagios/etc/nrpe.cfg
( mention the ip address of nagios server )
# systemcl enable –now nrpe
# firewall-cmd –permanent –add-service=nrpe
# firewall-cmd --reload
# vim /usr/local/nagios/etc/objects/192.168.1.212.cfg ( I make file within the object folder for add host or services )
# Default Linux Host Template ##
define host{
name linux-anjali ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
NAGIOS
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE
## Default
define host{
use linux-anjali ; Inherit default values from a template
host_name anjali.example.com ; The name we're giving to this server
alias rhel8 ; A longer name for the server
address 192.168.1.94 ; IP address of Remote Linux host
Save &exit this file
# vim /usr/local/nagios/etc/objects/services.cfg
define service {
use local-service ; Name of service template to use
host_name anjali.example.com
service_description Root Partition
check_command check_local_disk!20%!10%!/
# Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users.
define service {
NAGIOS
use local-service ; Name of service template to use
host_name anjali.example.com
service_description Current Users
check_command check_local_users!20!50
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 processes.
define service {
use local-service ; Name of service template to use
host_name anjali.example.com
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
# Define a service to check the load on the local machine.
define service {
use local-service ; Name of service template to use
host_name anjali.example.com
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
NAGIOS
# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free
define service {
use local-service ; Name of service template to use
host_name anjali.example.com
service_description Swap Usage
check_command check_local_swap!20%!10%
# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.
define service {
use local-service ; Name of service template to use
host_name anjali.example.com
service_description SSH
check_command check_ssh
notifications_enabled 0
# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.
define service {
use local-service ; Name of service template to use
NAGIOS
host_name anjali.example.com
service_description HTTP
check_command check_http
notifications_enabled 0
Save & exit this file
# vim /usr/local/nagios/etc/objects/command.cfg
Line no 231
v# systemctl restart nagios
# systemctl restart http
# systemctl restart nagios
# vim /usr/local/nagios/etc/nagios.cfg
Mention the some entries 35
Cfg_file=/usr/local/nagios/etc/objects/192.168.1.212.cfg
Cfg_file=/usr/local/nagios/etc/objects/service.cfg
Save & exit this file
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg ( check the error of vim
/usr/local/nagios/etc/nagios.cfg)
# systemctl enable –now nrpe
# systemctl restart nagios# systemctl restart nrpe
# systemctl restart httpd
then, check the browser
NAGIOS