View
231
Download
0
Category
Preview:
Citation preview
8/10/2019 Monitoring IT Infrastructure With Nagios Core
1/41
8/10/2019 Monitoring IT Infrastructure With Nagios Core
2/41
NagiosCore
Is an open source system and network monapplication
initially designed to work on Linuxit should work on most Unixes, as well
(Ubuntu, openSUSE, Fedora etc.)
8/10/2019 Monitoring IT Infrastructure With Nagios Core
3/41
Free Server & Network Monitoring To
Monit, Ganglia, Munin, Cacti, Nagios, Za
Observium, Zenoss, Collectd, Argus
http://sixrevisions.com/tools/10-free-server-networ
monitoring-tools-that-kick-ass/
http://en.wikipedia.org/wiki/Comparison_of_networoring_systems
More details on these tools can be found here:
8/10/2019 Monitoring IT Infrastructure With Nagios Core
4/41
Nagios can be complicated to install aconfigure, but its wealth of features arunmatched by any free tool out in the
It is geared for the experienced IT netwadministrators
8/10/2019 Monitoring IT Infrastructure With Nagios Core
5/41
Requirements
Mandatory :
A machine running Linux (or UNIX variant) that has network aa C compiler installed
Optional :
You are not required to use the CGIs included with Nagios Core
use it, you need to have installed:
a web server (preferably Apache)PHPThomas Boutells GD library version 1.6.3 or higher(this allowNagios with web interface)
8/10/2019 Monitoring IT Infrastructure With Nagios Core
6/41
8/10/2019 Monitoring IT Infrastructure With Nagios Core
7/41
Contact notifications when service or host problems ocget resolved (via email, pager, etc.)
Optional escalation of notifications to different contact
Ability to define event handlers that are run during servhost events, allowing proactive problem resolution
Simple authorization scheme that allows you restrict wusers can see and do from the web interface
8/10/2019 Monitoring IT Infrastructure With Nagios Core
8/41
How it works:
8/10/2019 Monitoring IT Infrastructure With Nagios Core
9/41
Installing (steps):
1) Required packages
Install Apache 2
Install PHP Install GCC compiler and development libraries * Install GD development libraries **
*GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project, supporting various programmi
**GD Graphics Library is a graphics software library by Thomas Boutell and others for dynamically manipulating ima
> sudo apt-get install apache2> sudo apt-get install libapache2-mod-php5
> sudo apt-get install build-essential> sudo apt-get install libgd2-xpm-dev (With Ubuntu 7.10+)(sudo apt-get install libgd2-dev with With Ubuntu 6.10)
8/10/2019 Monitoring IT Infrastructure With Nagios Core
10/41
2) Users and groups
Create a new nagiosuser, nagiosgroup (for Ubuntu 6.0 and earlier) anuser to the groupCreate a new nagcmdgroup for allowing external commands to be subthrough the web interfaceAdd nagios user (nagios) and apache user (www-data) to nagcmdgrou
> sudo -s> /usr/sbin/useradd -m -s /bin/bash nagios> passwd nagios--On older Ubuntu (6.01 and earlier) do also:> /usr/sbin/groupadd nagios> /usr/sbin/usermod -G nagios nagios--> /usr/sbin/groupadd nagios> /usr/sbin/usermod -G nagios nagios
8/10/2019 Monitoring IT Infrastructure With Nagios Core
11/41
> /usr/sbin/groupadd nagcmd> /usr/sbin/usermod -a -G nagcmd nagios> /usr/sbin/usermod -a -G nagcmd www-data
3) Download Nagios and the Plugins
> mkdir ~/downloads> cd ~/downloads
> wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5> wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios1.4.16.tar.gz
8/10/2019 Monitoring IT Infrastructure With Nagios Core
12/41
4) Compile and Install Nagios
Compile (make all)Install binaries, init script, sample config files and set permissions on thexternal command directory (make install, make install-init, make install-cmake install-commandmode)
> cd ~/downloads> tar xzf nagios-3.5.0.tar.gz> cd nagios-3.5.0> ./configure --with-command-group=nagcmd
> make all> make install> make install-init> make install-config> make install-commandmode
8/10/2019 Monitoring IT Infrastructure With Nagios Core
13/41
5) Configure email
Change the email address associated with the nagiosadmin contact definitioaddress youd like to use for receiving alerts
(in usr/local/nagios/etc/objects/contacts.cfgfile)
6) Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory (make insCreate a nagiosadminaccount for logging into the Nagios web interfaceRestart Apache
> make install-webconf> htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin> /etc/init.d/apache2 reload
8/10/2019 Monitoring IT Infrastructure With Nagios Core
14/41
7) Compile and Install the Nagios Plugins
It might be necessary to install first OpenSSLlibrary (sudo apt-get install lif using last nagios version (nagios-3.5.0.tar.gz, nagios-plugins-1.4.16.tar.
> sudo apt-get install libssl-dev( Install OpenSSL library)> /etc/init.d/nagios restart> cd ~/downloads> tar xzf nagios-plugins-1.4.16.tar.gz> cd nagios-plugins-1.4.16> ./configure --with-nagios-user=nagios --with-nagios-group=nagios
> make> make install
8/10/2019 Monitoring IT Infrastructure With Nagios Core
15/41
8) Verify and start Nagios
Start Nagios when the system bootsVerify sample Nagios configuration filesStart Nagios
> ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios> /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg> /etc/init.d/nagios start
9) Login to the Web Interface
http:///nagios/; credentials: nagiosadmin/
8/10/2019 Monitoring IT Infrastructure With Nagios Core
16/41
8/10/2019 Monitoring IT Infrastructure With Nagios Core
17/41
Nagios main files:
Nagios Config Folder -> /usr/local/nagios/etc/
Nagios Main Config File -> nagios.cfg
Resource File -> resource.cfgCGI Config File -> cgi.cfg
Object Config Files:commands -> .../objects/commands.cfgcontacts -> .../objects/contacts.cfglocalhost -> .../objects/localhosts.cfg
printer-> .../objects/printer.cfgswitch -> .../objects/switch.cfgtemplates -> .../objects/templates.cfgtimeperiods -> .../objects/timeperiods.cfgwindows -> .../objects/windows.cfg
8/10/2019 Monitoring IT Infrastructure With Nagios Core
18/41
What are the Objects?Objects are all the elements that are involved in the monitoring and notific
Hosts:Are one of the central objects in the monitoring logic
are usually physical devices on your network (servers, workstations, rouswitches, printers, etc.)have an address of some kind (e.g. an IP or MAC address)
have one or more more services associated with themcan have parent/child relationships with other hosts, often representing network connections, which is used in the network reachability logic
8/10/2019 Monitoring IT Infrastructure With Nagios Core
19/41
ServicesAre one of the central objects in the monitoring logic
Services are associated with hostsand can be:
Attributes of a host (CPU load, disk usage, uptime, etc.)Services provided by the host (HTTP, POP3, FTP, SSH, etc.)Other things associated with the host (DNS records, etc.)
Contacts
Are people involved in the notification process, which:
have one or more notification methods (cellphone, pager,email, instanmessaging, etc.)receive notifications for hosts and services they are responsible for
8/10/2019 Monitoring IT Infrastructure With Nagios Core
20/41
TimeperiodsAre used to control:
When hosts and services can be monitoredWhen contacts can receive notifications
Commands:Are used to control:
When hosts and services can be monitoredWhen contacts can receive notifications
Host Groups/Service Groups/Contact Groups
Host/Service groupsmake it easier to view the status of related hosts/sthe Nagios web interfaceContact groupsmake it easier to define all the people who get notified wcertain host or service problems occur
8/10/2019 Monitoring IT Infrastructure With Nagios Core
21/41
Host - Service - Command - executable command file
8/10/2019 Monitoring IT Infrastructure With Nagios Core
22/41
#'check_local_users' command definition
define command{command_name check_local_userscommand_line $USER1$/check_users-w $ARG1$ -c $ARG2$
}
Sample command from /usr/local/nagios/etc/objects/commands.cfg
$USER1$appears in resource.cfgand is the default location for plugi(/usr/local/nagios/libexec)check_usersis an executable command file from$USER1$ location
8/10/2019 Monitoring IT Infrastructure With Nagios Core
23/41
Service definition from localhost.cfg:uses the command name as it appears in commands.cfg$ARG1$, $ARG2$ are replaced with concrete values
8/10/2019 Monitoring IT Infrastructure With Nagios Core
24/41
Monitor Windows machine
8/10/2019 Monitoring IT Infrastructure With Nagios Core
25/41
On Ubuntu monitoring server:
1. In /usr/local/nagios/etc/nagios.cfg file uncomment the following line:cfg_file=/usr/local/nagios/etc/objects/windows.cfg
2.In /usr/local/nagios/etc/objects/windows.cfgfile replace the IP addresshost with the IP of monitored Windows machine
On the monitored Windows machine:
1. Download NSClient++ (http://sourceforge.net/projects/nscplus/)2. Install NSClient++ (no password set)3. Start NSClient++ service
8/10/2019 Monitoring IT Infrastructure With Nagios Core
26/41
Monitor a printer
In order to be able to do this, check_hpjd plugin muinto plugin home directory (/usr/local/nagios/libexec)
8/10/2019 Monitoring IT Infrastructure With Nagios Core
27/41
check_hpjd plugin
Check_hpjdplugin will only get compiled and installed if you have the net-net-snmp-utilspackages installed on your system
Simple Network Management Protocol (SNMP)is an "Internet-standard for managing devices on IP networks.
SNMP is one of the most commonly used technologies when it comes to nemonitoring
MIB(Management Information Base)is a collection of information organihierarchically. These are accessed using a protocol such as SNMP.
OIDsor Object Identifiersuniquely identify manged objects in a MIB hie
Used terms:
8/10/2019 Monitoring IT Infrastructure With Nagios Core
28/41
Install net-snmp
1. Install snmp if not installed:> apt-get update && apt-get install snmpd
2. Enable snmp:Edit the file /etc/snmp/snmp.conf and comment out the line containing "
From the console (Ctrl-Alt-t), enter the following commands:> sudo apt-get install snmp-mibs-downloader> sudo download-mibs
3. Restart smtp:/etc/init.d/snmpd restart
4. You should be able to test this configurationby running the following co> snmpwalk -v 2c -c public system
snmpwalk -v 2c -c public 127.0.0.1 system
8/10/2019 Monitoring IT Infrastructure With Nagios Core
29/41
snmpwalk v 2c c public 127.0.0.1 system
8/10/2019 Monitoring IT Infrastructure With Nagios Core
30/41
Re-compile Nagios plugin
1. Go to the location where the plugin (nagios-plugins-1.4.16.tar.gz) is> cd /home/c/downloads/
2. Go to the location where the plugin (nagios-plugins-1.4.16.tar.gz) is> cd /home/c/downloads/
3. Recompile:> ./configure --with-nagios-user=nagios --with-nagios-group=> make> make install
4. Restart Nagios:> sudo /etc/init.d/nagios restart
8/10/2019 Monitoring IT Infrastructure With Nagios Core
31/41
Configure Nagios to display the printer
1. Remove the # sign from the following line in the main configuration
(/usr/local/nagios/etc/nagios.cfg):
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg
2. Edit the printer.cfg file (/usr/local/nagios/etc/objects/printer.cfg) and reprinter IP (and name, alias and so on) with the correct value
3. Restart Nagios:> sudo /etc/init.d/nagios restart
8/10/2019 Monitoring IT Infrastructure With Nagios Core
32/41
Monitor a Linux/Unix host
8/10/2019 Monitoring IT Infrastructure With Nagios Core
33/41
On Monitored Linux host
Download Nagios Plugins and NRPE Add-onCreate nagios account
Install Nagios PluginInstall NRPESetup NRPE to run as daemonModify the /usr/local/nagios/etc/nrpe.cfg
1) Download Nagios Plugins and NRPE Add-on
2) Create Nagios account> useradd nagios> passwd nagios
3) Install nagios-plugin
8/10/2019 Monitoring IT Infrastructure With Nagios Core
34/41
4) Install NRPE (NRPE - Nagios Remote Plugin Executor) addon
> cd ~/downloads> wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.142.14.tar.gz
> tar xzf nrpe-2.14.tar.gz> cd nrpe-2.14> ./configure
###################
if ./configure does not succeed do this:
> apt-get install libssl-dev> apt-file search libssl | grep libssl-dev> ./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-linux-gnblue is the location where ssl library actually is)
####################
8/10/2019 Monitoring IT Infrastructure With Nagios Core
35/41
> make all> make install-plugin> make install-daemon> make install-daemon-config> sudo apt-get install xinetd
> make install-xinetd
5) Setup NRPE to run as daemon (i.e as part of xinetd):Xinetd (extended Internet daemon) is an open-source super-server daemoruns on many Unix-like systems and manages Internet-based connectivity
Modify the /etc/xinetd.d/nrpeto add the ip-address of the Nagios monitoserver to the only_from directive.Note that there is a space after the 127.0.0.1 and the nagios monitoring sip-address (in this example, nagios monitoring server ip-address is: 192.1
only_from = 127.0.0.1 192.168.1.2
8/10/2019 Monitoring IT Infrastructure With Nagios Core
36/41
8/10/2019 Monitoring IT Infrastructure With Nagios Core
37/41
Download NRPE Add-onInstall check_nrpe
Create host and service definition for remote hostRestart the nagios service
On Monitoring Server
1. Download NRPE Add-on2. Install check_nrpe on the nagios monitoring server
> cd ~/downloads
> wget http://downloads.sourceforge.net/project/nagios/nrpe- 2.14/nrpe-2.14.tar.gz> tar xzf nrpe-2.14.tar.gz> cd nrpe-2.14> ./configure
http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-8/10/2019 Monitoring IT Infrastructure With Nagios Core
38/41
###################
Note: If you get the checking for SSL headers configure: error: Cannot fheaders error message while performing ./configure, do the following:
> apt-get install libssl-dev> apt-file search libssl | grep libssl-dev> ./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-
###################
> make all> make install-plugin
Verify whether nagios monitoring server can talk to the remotehost.> /usr/local/nagios/libexec/check_nrpe -H 192.168.1.3
Note: 192.168.1.3 in the ip-address of the monitored host described above
8/10/2019 Monitoring IT Infrastructure With Nagios Core
39/41
3. Create host and service definition for remotehost
Create a new configuration file /usr/local/nagios/etc/objects/remotehost.define the host and service definition for this particular remotehost. It istake the localhost.cfg and copy it as remotehost.cfgand start modifying according to your needs.
define host{use linux-serverhost_name remotehost
alias Remote Hostaddress 192.168.1.3contact_groups admins}
8/10/2019 Monitoring IT Infrastructure With Nagios Core
40/41
define service{use generic-servicehost_name remotehost
service_description Root Partitioncontact_groups adminscheck_command check_nrpe!check_disk}
Note: In all the above examples, replace remotehost with the correspohostname of your remotehost.
4) Restart the nagios serviceservice nagios reload
8/10/2019 Monitoring IT Infrastructure With Nagios Core
41/41
Resources:
1. http://nagios.sourceforge.net/docs/3_0/quickstart.html2. http://library.nagios.com/library/products/nagioscore/manuals/
3. http://sixrevisions.com/tools/10-free-server-network-monitoring-toolskick-ass/
4. http://en.wikipedia.org/wiki/Comparison_of_network_monitoring_sys5. https://nagios.demo.netways.de/nagios/6. http://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp
and-oids-work7. http://askubuntu.com/questions/141564/what-is-snmp-used-for8. http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-h
using-nagios-30/
http://nagios.sourceforge.net/docs/3_0/quickstart.htmlhttp://library.nagios.com/library/products/nagioscore/manuals/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/https://nagios.demo.netways.de/nagios/http://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/http://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://askubuntu.com/questions/141564/what-is-snmp-used-forhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttp://www.paessler.com/knowledgebase/en/topic/653-how-do-snmp-mibs-and-oids-workhttps://nagios.demo.netways.de/nagios/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://sixrevisions.com/tools/10-free-server-network-monitoring-tools-that-kick-ass/http://library.nagios.com/library/products/nagioscore/manuals/http://nagios.sourceforge.net/docs/3_0/quickstart.htmlRecommended