Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
How to configure Nagios in Fedora ?
1. DATACENTER MANAGEMENT NAGIOS CONFIGURATION
Submitted By
Pankaj U. Rane (120851923024)
P.Venkatesh(120851923027)
Install and configure Nagios on Fedora Core 8 (VM or Physical Machine)
Monitor the following:
>> Local Machine
>> Remote Linux Machine (preferably Fedora) – Hostname to be displayed as “LINUX1”
>> Remote Windows Machine – Hostname to be displayed as “WIN1”
>> Remote Website – Name to be displayed as “MYWEBSITE”
*** MONITORING THE WINDOWS MACHINE***
To achieve this , we need to install an agent on the WINDOWS Machine.
Agent acts as a proxy between the Nagios Plugin that does the monitoring and the
actual service or attribute of the windows machine.
Client used for this user manual is NSClient++
The check_nt plugin will be used to communicate with the NSClient++
Steps involved:
Perform first-time pre-requisite.
Install monitoring agent on the Windows Machine.
Create new host and service definitions for monitoring the Windows Machine.
Restart the Nagios daemon.
Download the NSClient++ installer package from www.nsclient.org to the target
machine you wish to install it on.
Run the NSClient++ MSI installer package to initiate the installation. The welcome
screen will appear. Click Next to continue to the next step.
Read through the End User License Agreement.
Once you have agreed to itsterms, check the acceptance box and click Next to
continue.
You may customize the installation options on the next screen if you wish. No
changes are required for an working installation of the agent. Click Next to continue.
2. If an existing NSClient++ installation exists on the target machine, you will have the
option of using the old configuration file. This option is not enable if this is the first
time you are installing the client. Click Next to continue.
In the next step you will need to configure the NSClient++ agent. These steps
are important! Make sure you: Enter the IP address of the Nagios XI or Nagios
Core server in the Allowed hosts box.
Enter a password in the NSClient password box that will be required for
communication between the Nagios server and the Windows machine.
Check the following boxes in the Modules to load section:
Enable common check plugins Enable , nsclient server (check_nt) , NRPE server
and WMI checks. Click Next to continue.
Click the Install button on the next screen to begin the installation.
When the installation completes, make sure to check the Start service option and click
Finish to complete the setup.
The NSClient++ agent will now be running as a service, which means the Windows
machine is ready to be monitored with Nagios.
And now to Start->Run->cmd->services.msc and click on NSClient++ and select
the Logon tab and enable “Allow service to interact with desktop” and click “OK”
and Restart the NSClient++ service.
NOW CONFIGURE FEDORA TO MONITOR WINDOWS
#nano /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring a Windows Machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
uncomment the cfg_file and save nagios.cfg
*** NAGIOS SERVER INSTALLATION***
Before installing Nagios server check the pre-requistives :
apache - #yum list installed | grep httpd
php
- #yum list installed | grep php
gcc compiler - # yum list installed | grep gcc
GD Development libraries - # yum list installed | grep gcc
net-snmp - # yum list installed | grep net-snmp (if not installed #yum install net-snmp)
Server Installation of Nagios :
Step1 : Create and manage account and group
a) Make sure you are in “root”
b) Create a new nagios user and give it a password
#whoami
3. root
#cat /etc/passwd
#useradd –m nagios ( -m : To create a user in home dir)
#ls /home/
nagios
#passwd nagios ( Set the password the nagios user)
c) Check if a group exist with the nagios name.
#cat /etc/group
#cat /etc/group | cut –d”:” –f1 | sort –u | less
nagios
d) Create a new nagcmd group for allowing external commands to be submitted through the
web interface.
#groupadd nagcmd
#cat /etc/group | grep nagcmd
nagcmd:x:502
e) Add both the nagios user and the apache user to the group.
#usermod –a –G nagcmd nagios
#usermod –a –G nagcmd apache
#cat /etc/group | grep nagcmd
nagcmd:x:502:nagios,apache
f) Download Nagios and Plugin Source Code.
nagios-3.4.1.tar.gz
nagios-plugins-1.4.16
g) Compile and install nagios
i) Extract the nagios source code tarball.
#tar xzf nagios-3.4.1.tar.gz
#ls –l
nagios-3.4.1
#cd nagios-3.4.1
nagios>#ls
ii) Run the nagios configure script, passing the name of the group you created earlier.
nagios>#./configure - -with-command-group=nagcmd
iii) Compile the nagios source code
nagios>#make all
iv) Install binaries , init scripts , sample config files and set permissions on the external
command directory.
nagios># make install
nagios># make install-init
nagios># make install-config
nagios># make install-commandmode
v) Configuration customization
4. #nano /usr/local/nagios/etc/objects/contact.cfg
Define contact {
email
pankaj.rane2k8@gmail.com ; (Note: should be type in single line)
and save contact.cfg
vi) Configure the web interface
a) Install the nagios web config file in the Apache conf.d directory.
nagios># make install-webconf
b) Install the classic theme for the nagios web interface
nagios># make install-classicui
c) Create a nagiosadmin account for loggin into the nagios web interface.
Note : Remember the password of nagiosadmin
We will use the htpasswd for this , htpasswd is used to create and update the flat-files used to
store usernames and passwords for basic authentication of HTTP users.
#htpasswd –c /usr/local/nagios/etc/htpasswd.users
nagiosadmin
New passwd:nagiosadmin123
Re-type passwd:nagiosadmin123
#service httpd restart
#cd .. ( come out of nagios folder)
#ls –l
#tar xzf nagios-plugin.tar.gz
#cd nagios-plugin
#./configure - -with-nagios-user=nagios - -with-nagios-group=nagios
#make
#make install
d) Start Nagios
Add nagios to the list of system services and have it automatically start when the system boots.
#chkconfig - -add nagios
#chkconfig nagios on
The chkconfig command updates and queries runlevel information for system services.
Verify the sample nagios configuration files.
nagios-plugin>#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
0 warnings
0 Errors
#service nagios start
SE-linux is in enforcing mode make it disabled.
#getenforce
Permissive
#setenforce 0 - To disable
5. Go to browser http://localhost/nagios/
Username : nagiosadmin
Password:nagiosadmin123
*** MONITORING THE REMOTE LINUX MACHINE***
How to?
Use the NRPE daemon to execute Nagios plugins on the remote server and report back to the
monitoring host server.NRPE-Nagios Remote Plugin Executor.
Step1: Remote server installation and setup ( Nagios client)
Check openssl-devel is installed
#yum list installed | grep openssl-devel
Create nagios user account on remote server to be monitored
#useradd nagios
#passwd nagios
New passwd:Password1234
Download and install Nagios Plugin nagios-plugin-1.4.16.tar.gz
#tar xzf nagios-plugin-1.4.16.tar.gz
#cd nagios-plugin-1.4.16
#./configure - -with-nagios-user=nagios - -with-nagios-group=nagios
#make
#make install
Change the permissions on the plugins directory and the plugins to the nagios user.
nagios-plugin>#chown nagios.nagios /usr/local/nagios/
nagios-plugin>#chown nagios.nagios /usr/local/nagios/libexec/
Install xinetd package
6. nagios-plugin>#yum install xinetd
#cd . .
Download nrpe-2.13.tar.gz
#tar zxf nrpe-2.13.tar.gz
#cd nrpe-2.13
#./configure
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config
#make install-xinetd
POST NRPE Configuration
Edit xinetd NRPE Entry:
Add nagios monitoring server to the “only_from” directive:
nrpe>#nano /etc/xinetd.d/nrpe
only_from = 127.0.0.1 192.168.145.132
EDIT SERVICES FILE ENTRY
Add entry for nrpe daemon:
nrpe>#nano /etc/services
go to bottom and write
nrpe
5666/tcp
and save services
Restart xinetd and set to start at boot
nrpe>#chkconfig xinetd on
nrpe>#service xinetd start
#netstat –antp | grep 5666
If you can‟t see the service disable SE Linux
#NRPE
7. #nano /etc/selinux/config
Set to be disabled , if it is permissive - Restart the system
#service xinetd restart
#netstat –antp | grep 5666
Check NRPE daemon is functioning
#/usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.13
#/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
Disk OK – free space:/boot 167MB(93% inode=99%);
-w 20% (Warning)
-c 10% (Critical Warning)
-p /dev/sda1 (Parameter passing primary storage)
***NOW GO TO NAGIOS SERVER***
Download NRPE into the server, compile and configure NRPE
#tar xzf nrpe.tar.gz
#cd nrpe
nrpe>#./configure
nrpe>#make all
nrpe>#make install-plugin
CREATE NRPE COMMAND DEFINITION
A command definition needs to be created in order for the check_nrpe plugin to be used by
nagios.
#nano /usr/local/nagios/etc/objects/commands.cfg
#######################################
# NRPE CHECK COMMAND
8. # Command to use NRPE to check remote host
######################################
define command{
command_name check_nrpe
command_line
$USER1$check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#######################################
# CHECK WEBSITE RESPONSE
# Command to check public service
######################################
# „check_website_response‟ command definition
define command{
command_name check_website_response
command_line $USER1$/check_website_response.sh –u $ARG1$ -w $ARG2$ -c $ARG3$
}
And save the commands.cfg
Create new linux-box-remote object template file:
#nano /usr/local/nagios/etc/objects/linux-box-remote.cfg
define host {
name linux-box-remote
; None of this template
use
; Inherit default values
generic-host
check_period
24x7
check_interval
5
retry_interval
1
max_check_attempts
10
check_command
check-host-alive
notification_period
24x7
9. notification_interval
30
notification_options
d,r
contact_groups
admins
register
0
; DO NOT REGISTER TIS-IT IS A TEMPLATE
}
define host{
use
linux-box-remote
; Inherit default values from template
host_name
LINUX1
; Remote Linux Server
alias
Fedora
; Alias Name
address
192.168.145.134
; IP
}
define service{
use
generic-service
host_name
fc8
service_description
CPULoad
check_command
check_nrpe!check_load
}
Save linux-box-remote.cfg
ACTIVATE the linux-box-remote.cfg template
#nano /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring remote Linux machine
cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg
save nagios.cfg and exit
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#service nagios restart
#service httpd restart
Open the browser http://localhost/nagios
10. Username: nagiosadmin
Password:Password123
Click on host
*** MONITORING PUBLICLY AVAILABLE SERVICES***
Examples of Pubic Services – HTTP , POP3 , IMAP etc
#cd /usr/local/nagios/libexec
(All the commands are stored in this path)
Copy check_website_response.sh to /usr/local/nagios/libexec
Add the following lines to nagios.cfg
# Definitions for monitoring Public Service
Cfg_file=/usr/local/nagios/etc/objects/publichost.cfg
Add the following to the /usr/local/nagios/etc/objects/commands.cfg
# „check_website_response‟ command definition
Define command {
Command_name
check_website_response
Command_line $USER1$/check_website_response.sh –u $ARG1$ -w $ARG2$ -c
$ARG3$
}
#cd /usr/local/nagios/libexec
libexec>#ls –l check_website_response.sh
#chmod 755 check_website_response.sh
#./ check_website_response.sh
# check_website_response.sh –w 1000 –c 2000 –u http://192.168.1.181/
RESPONSE:OK
11. Create the file publichost.cfg under the path /usr/local/nagios/etc/objects
define host
{
use
generic-host
; Inherit default values from a template
host_name
MYWEBSITE ; Website Name
max_check_attempts 3
contact_groups
admins
}
define service {
host_name
MYWEBSITE
service_description
Website Response : www.mywebsite.in
check_command
check_website_response!"http://192.168.1.181/"!1000!2000
max_check_attempts 5
check_interval
1
retry_interval
1
check_period
24x7
}
Save publichost.cfg
TESTING
#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
#service nagios restart
Go to browser http://localhost/nagios
Username: nagiosadmin
Password:Password123
Click on Host and Services