SlideShare una empresa de Scribd logo
1 de 9
Descargar para leer sin conexión
Nagios : Quick install and configuration guide

                            Jonathan Lyard {jonathan.lyard@bull.net}
                                          Version 0.1

                                               April 14, 2006


                                                    Abstract

         Nagios is an efficient tool for network and system monitoring. However, first install and configu-
     ration is pretty intricate since it requires to understand a major part of the official documentation (250
     pages). This tutorial is for ones who want to quickly build a working configuration so as to monitor
     simple networks including NFSv4 clients and servers. This guide goes through installation and basic
     configuration of Nagios.




Contents
1 Install                                                                                                        2
   1.1   Copy distribution and plug in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .           2
   1.2   Create user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .           2
   1.3   Configuration and compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .              2

2 Configuration                                                                                                   4
   2.1   Time periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .            4
   2.2   Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .          5
   2.3   Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .           5
   2.4   Hostgroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .            6
   2.5   Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .          6
   2.6   Web server configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .             7

3 Run Nagios                                                                                                     9




                                                        1
1    Install

1.1 Copy distribution and plug in
First, you must get the latest Nagios release (nagios-x.y.tar.gz) and the official Nagios plugins
(nagios-plugins-x.y.z) from http://www.nagios.org/download/. I also advise to get the official
Nagios documentation (http://www.nagios.org/docs/) if you plan to tune the configuration explained here.
Unpack the tarball :
tar xzf nagios-2.0.tar.gz tar xzf nagios-plugins-1.4.2.tar.gz 1.2


1.2 Create user
First, we need to create the user Nagios will run under :

adduser nagios mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios

You will probably want to issue external commands from the web interface. So you need to identify the
user your web-server run as. For Apache, you can get it with :

grep "^User" /etc/httpd/conf/httpd.conf

By default, the user is Apache. See /etc/passwd file or report to you web-server installation if you
are running another web server. Also note that the path to httpd.conf can vary depending on your
system.
We need to create a group whose members include the user your web server is running as and the user
Nagios is running as.
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd apache
/usr/sbin/usermod -G nagcmd nagios

Recall to replace apache by the user name you obtained at last step.


1.3 Configuration and compilation
We can now configure and install Nagios. Go to the directory where you untared the distribution and
run :

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios
--with-nagios-group=nagios --with-command-group=nagios

Depending on your system, you should get a configuration like the following :




                                                    2
Configuration summary for nagios 2.0 02-07-2006 ***:

            General      Options:
            ————————-
            Nagios       executable: nagios
            Nagios       user/group: nagios,nagios
            Command user/group: nagios,nagios
            Embedded Perl: no
            Event        Broker: yes
            Install      ${prefix}: /usr/local/nagios
            Lock         file: ${prefix}/var/nagios.lock
            Init         directory: /etc/rc.d/init.d
            Host         OS: linux-gnu
            Web          Interface Options:
            ————————
            HTML         URL: http://localhost/nagios/
            CGI          URL: http://localhost/nagios/cgi-bin/
            Traceroute (used by WAP): /bin/traceroute


Now let’s compile and install :

make all
make install
make install-init
make install-config

make install-init allows to run nagios at startup (/etc/rc.d/init.d/nagios). This does
not always work (I had problems on Fedora Core 4) but we see another way to run it at startup later on.
make install-config installs the sample configuration files. This will be useful to setup a basic
configuration.
In order for nagios to be of any use to you, you need to install some plugins. First, install the official
plugins. Go to the directory where you untared nagios-plugin-x.y.z and run :

./configure
make
make install




                                                       3
2       Configuration
Normally, you should already have some configuration sample files in /usr/local/nagios/etc.
Else, try to run again make install-config. Files should be called xxxx.cfg-sample, so you
need to rename them :

cd /usr/local/nagios/etc
mv bigger.cfg-sample bigger.cfg
(...)

The entry point is through nagios.cfg. This file is run first when nagios starts. You may not need a
lot of modifications in this file.

log_file=/usr/local/nagios/var/nagios.log

indicates where the logs will go. Set the appropriate owner of the log file :

chown nagios.nagios /usr/local/nagios/var/nagios.log

Other configuration files are called from nagios.cfg, for instance at lines :

cfg_file=/usr/local/nagios/etc/checkcommands.cfg
cfg_file=/usr/local/nagios/etc/misccommands.cfg

Those files contain commands definition.
And finally, our own configuration will be written in a new file (ma_conf.cfg for instance) so we need
to replace :

cfg_file=/usr/local/nagios/etc/minimal.cfg

By :

cfg_file=/usr/local/nagios/etc/ma_conf.cfg

To create our configuration, we will take minimal.cfg as the basis :

cp minimal.cfg ma_conf.cfg

And now let’s edit it to setup a configuration for a simple network with one monitoring station and one
NFSv4 server.


2.1 Time periods
Time periods are used to define some monitoring periods. For the time being we can keep 24*7 but you
may need to change it -for instance not to receive alarms if your NFS servers are down during night.



                                                    4
2.2 Contacts
You will certainly need to add some contacts, which are persons in charge of monitoring the network. By
default they will receive notification in 24*7 by e-mail.

define contact{

contact_name adminNFS

      alias Jonathan Lyard
      service_notification_period 24x7
      host_notification_period 24x7
      service_notification_options w,u,c,r
      host_notification_options d,r
      service_notification_commands notify-by-email
      host_notification_commands host-notify-by-email
      email adminNFS@localhost

      }


Now let’s create a contact group. This one will be used to indicate which contacts should be notified for
each issue. Here is only one group, but feel free to add all groups you need (for instance if the ones in
charge of NFS administration are different from network administrators).


define contactgroup{

contactgroup_name admins

alias Nagios Administrators

members nagios-admin,adminNFS

}


2.3 Hosts
In addition to localhost, you must specify all hosts your are monitoring. I assume they are all on-link
(in the same LAN as your monitoring station). Else, see Nagios official documentation to get it working
through routers (use parents option).
Here is what is required in order to monitor a machine called nfs2 with IP address 192.168.0.5. Alarms
from this host will be reported to the "admins" group.




                                                   5
define host{

      use generic-host ; Name of host template to use
      host_name nfs2
      alias nfs2
      address 192.168.0.5
      check_command check-host-alive
      max_check_attempts 10
      notification_interval 120
      notification_period 24x7
      notification_options d,r
      contact_groups admins
      }


2.4 Hostgroups
In this basic configuration, we will only have one hostgroup. You can define several hostgroups to group
hosts together in Nagios interface.


define hostgroup{

      hostgroup_name nfsv4config
      alias NFSv4 test configuration
      members localhost,nfs2
      }


2.5 Services
Finally, one can find services definition. Services do not necessarily mean real services that run on host
(FTP, POP, HTTP...) but also some other types of metric associated with the host (response to ping,
number of logged-in user, free disk space...).
For instance, to monitor connectivity for localhost and our nfs2 server, we need the following service
definition :

define service{

use         generic-service ; Name of service template to use

host_name localhost,nfs2



                                                   6
service_description PING

is_volatile 0

check_period 24x7

max_check_attempts 4

normal_check_interval 5

retry_check_interval 1

contact_groups admins

notification_options w,u,c,r

notification_interval 960

notification_period 24x7

check_command check_ping!100.0,20%!500.0,60%

}

Later on, we will also define a service to monitor NFSv4.


2.6 Web server configuration
In this step, you will learn how to configure the web-server. I assume you are using Apache, but the
configuration may be similar for other web-servers. Check your own web-server’s documentation to put
it at work.
Add the following lines in httpd.conf (in general /etc/httpd/conf/httpd.conf).

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
Directory /usr/local/nagios/sbin

#           SSLRequireSSL

            Options ExecCGI
            AllowOverride None
            Order       allow,deny
            Allow       from all
            #           Order deny,allow
            #           Deny from all
            #           Allow from 127.0.0.1



                                                  7
AuthName Nagios Access
             AuthType Basic
             AuthUserFile /usr/local/nagios/etc/htpasswd.users
             Require valid-user
             /Directory

Alias /nagios /usr/local/nagios/share
Directory /usr/local/nagios/share

#            SSLRequireSSL

             Options None
             AllowOverride None
             Order        allow,deny
             Allow        from all
             #            Order deny,allow
             #            Deny from all
             #            Allow from 127.0.0.1
             AuthName Nagios Access
             AuthType Basic
             AuthUserFile /usr/local/nagios/etc/htpasswd.users
             Require valid-user
             /Directory

This configuration enable authentication. The first directory entry is for CGI scripts, the second for html
pages. Of course, you can tune this configuration to fit your requirements.
You can also disable authentication by setting use_authentication=0 in /usr/local/nagios/etc/cgi.cfg
but then, you will not be allowed to run remote commands. Use it only if you have a problem with au-
thentication.
You now need to create one or more users being able to authenticate. For the first one (-c to create the
file htpasswd.users) :

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

and for (possible) next users :

htpasswd /usr/local/nagios/etc/htpasswd.users nagiosadmin2

Then, you need to give some rights to the users.



                                                   8
You can do it by editing the file /usr/local/nagios/etc/cgi.cfg.
For instance :

authorized_for_system_information=nagiosadmin,nagiosadmin2

And so on for all line you want to grant privilege to nagiosadmin and nagiosadmin2. I have uncommented
all authorized line and give access to nagiosadmin. I advised to at least do the same if want to be able to
configure everything from the web interface.
For more details on the access rights, read the chapter "Authentication and Authorization in the CGIs" in
Nagios official documentation.
Restart your web browser to take modifications into account :

/usr/sbin/httpd -k restart

You should be able to point http://localhost in your web browser proving that your web server is
up.
You should also be able to point http://localhost/nagios/ and authenticate yourself with one
of the user created previously (htpasswd). At this time, the CGI will not works since Nagios is not
running.


3    Run Nagios
To run Nagios, you can use the following command to make it start as a foreground process:

/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg &

If make install-init failed to make Nagios run at startup you can add this command to /etc/rc.d/rc.local
(here on FC4 but path and filename can vary depending on distribution).
To check that all configuration files are alright, you can issue :

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Finally, a useful command to restart Nagios and therefore consider modifications in the configuration
files :

killall -SIGHUP nagios

Enjoy monitoring systems with Nagios!




                             Jonathan Lyard {jonathan.lyard@bull.net}




                                                     9

Más contenido relacionado

La actualidad más candente

Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016StackIQ
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04SANTIAGO HERNÁNDEZ
 
Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2IMC Institute
 
Free radius billing server with practical vpn exmaple
Free radius billing server with practical vpn exmapleFree radius billing server with practical vpn exmaple
Free radius billing server with practical vpn exmapleChanaka Lasantha
 
How to Become Cloud Backup Provider
How to Become Cloud Backup ProviderHow to Become Cloud Backup Provider
How to Become Cloud Backup ProviderCloudian
 
Implementing DNS in Samba PDC
Implementing DNS in Samba PDCImplementing DNS in Samba PDC
Implementing DNS in Samba PDCJalpa Soni
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingOpen Source Consulting
 
Les défis des architectures cloud sur OpenStack
Les défis des architectures cloud sur OpenStackLes défis des architectures cloud sur OpenStack
Les défis des architectures cloud sur OpenStackOsones
 
Whitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxWhitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxRoger Eisentrager
 
[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기
[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기
[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기NAVER D2
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup providerCLOUDIAN KK
 
Linux con europe_2014_f
Linux con europe_2014_fLinux con europe_2014_f
Linux con europe_2014_fsprdd
 
Linux Daemon Writting
Linux Daemon WrittingLinux Daemon Writting
Linux Daemon Writtingwinsopc
 
Hadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup InsightsHadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup InsightsSruthi Kumar Annamnidu
 

La actualidad más candente (18)

Lab docker
Lab dockerLab docker
Lab docker
 
Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04
 
Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2Set up Hadoop Cluster on Amazon EC2
Set up Hadoop Cluster on Amazon EC2
 
Free radius billing server with practical vpn exmaple
Free radius billing server with practical vpn exmapleFree radius billing server with practical vpn exmaple
Free radius billing server with practical vpn exmaple
 
How to Become Cloud Backup Provider
How to Become Cloud Backup ProviderHow to Become Cloud Backup Provider
How to Become Cloud Backup Provider
 
Implementing DNS in Samba PDC
Implementing DNS in Samba PDCImplementing DNS in Samba PDC
Implementing DNS in Samba PDC
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource Consulting
 
Installing lemp with ssl and varnish on Debian 9
Installing lemp with ssl and varnish on Debian 9Installing lemp with ssl and varnish on Debian 9
Installing lemp with ssl and varnish on Debian 9
 
RDO-Packstack Workshop
RDO-Packstack Workshop RDO-Packstack Workshop
RDO-Packstack Workshop
 
Les défis des architectures cloud sur OpenStack
Les défis des architectures cloud sur OpenStackLes défis des architectures cloud sur OpenStack
Les défis des architectures cloud sur OpenStack
 
Whitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxWhitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on Linux
 
[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기
[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기
[Hello world 오픈세미나]varnish로 웹서버성능 향상시키기
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup provider
 
Linux con europe_2014_f
Linux con europe_2014_fLinux con europe_2014_f
Linux con europe_2014_f
 
Linux Daemon Writting
Linux Daemon WrittingLinux Daemon Writting
Linux Daemon Writting
 
D space manual
D space manualD space manual
D space manual
 
Hadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup InsightsHadoop Cluster - Basic OS Setup Insights
Hadoop Cluster - Basic OS Setup Insights
 

Destacado

Install nagios
Install nagiosInstall nagios
Install nagioshassandb
 
4 things you_cannot_recover
4 things you_cannot_recover4 things you_cannot_recover
4 things you_cannot_recoverJohn Williams
 
Install nagios
Install nagiosInstall nagios
Install nagioshassandb
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios
 

Destacado (7)

Install nagios
Install nagiosInstall nagios
Install nagios
 
Webfolio
WebfolioWebfolio
Webfolio
 
4 things you_cannot_recover
4 things you_cannot_recover4 things you_cannot_recover
4 things you_cannot_recover
 
Install nagios
Install nagiosInstall nagios
Install nagios
 
Nagios 3
Nagios 3Nagios 3
Nagios 3
 
Lect21 Engin112
Lect21 Engin112Lect21 Engin112
Lect21 Engin112
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
 

Similar a Install nagios

Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNagios
 
NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.
NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.
NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.Marc Trimble
 
Installing & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOSInstalling & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOSDevin Olson
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wikishahab071
 
How to configure Nagios in Fedora ?
How to configure Nagios in Fedora ?How to configure Nagios in Fedora ?
How to configure Nagios in Fedora ?Pankaj Rane
 
Quick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage Service
Quick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage ServiceQuick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage Service
Quick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage ServiceCloudian
 
Net app ecmlp2495163
Net app ecmlp2495163Net app ecmlp2495163
Net app ecmlp2495163forum4user
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawnGábor Nyers
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting startedMunish Mehta
 
Tutorial CentOS 5 untuk Webhosting
Tutorial CentOS 5 untuk WebhostingTutorial CentOS 5 untuk Webhosting
Tutorial CentOS 5 untuk WebhostingBeni Krisbiantoro
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
Netxms install guide
Netxms install guideNetxms install guide
Netxms install guideNaga Raju N
 
Linux conf-admin
Linux conf-adminLinux conf-admin
Linux conf-adminbadamisri
 

Similar a Install nagios (20)

Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
 
NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.
NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.
NRPE - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core 4 and others.
 
Sun raysetup
Sun raysetupSun raysetup
Sun raysetup
 
Installing & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOSInstalling & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOS
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wiki
 
How to configure Nagios in Fedora ?
How to configure Nagios in Fedora ?How to configure Nagios in Fedora ?
How to configure Nagios in Fedora ?
 
Quick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage Service
Quick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage ServiceQuick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage Service
Quick-Start Guide: Deploying Your Cloudian HyperStore Hybrid Storage Service
 
Step by-step installation of a secure linux web dns- and mail server
Step by-step installation of a secure linux web  dns- and mail serverStep by-step installation of a secure linux web  dns- and mail server
Step by-step installation of a secure linux web dns- and mail server
 
Net app ecmlp2495163
Net app ecmlp2495163Net app ecmlp2495163
Net app ecmlp2495163
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
Kickstart
KickstartKickstart
Kickstart
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
 
Tutorial CentOS 5 untuk Webhosting
Tutorial CentOS 5 untuk WebhostingTutorial CentOS 5 untuk Webhosting
Tutorial CentOS 5 untuk Webhosting
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
linux installation.pdf
linux installation.pdflinux installation.pdf
linux installation.pdf
 
Freeradius edir
Freeradius edirFreeradius edir
Freeradius edir
 
Netxms install guide
Netxms install guideNetxms install guide
Netxms install guide
 
Nagios intro
Nagios intro Nagios intro
Nagios intro
 
Linux conf-admin
Linux conf-adminLinux conf-admin
Linux conf-admin
 
Linux Conf Admin
Linux Conf AdminLinux Conf Admin
Linux Conf Admin
 

Install nagios

  • 1. Nagios : Quick install and configuration guide Jonathan Lyard {jonathan.lyard@bull.net} Version 0.1 April 14, 2006 Abstract Nagios is an efficient tool for network and system monitoring. However, first install and configu- ration is pretty intricate since it requires to understand a major part of the official documentation (250 pages). This tutorial is for ones who want to quickly build a working configuration so as to monitor simple networks including NFSv4 clients and servers. This guide goes through installation and basic configuration of Nagios. Contents 1 Install 2 1.1 Copy distribution and plug in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Create user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Configuration and compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Configuration 4 2.1 Time periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3 Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.4 Hostgroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.5 Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.6 Web server configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3 Run Nagios 9 1
  • 2. 1 Install 1.1 Copy distribution and plug in First, you must get the latest Nagios release (nagios-x.y.tar.gz) and the official Nagios plugins (nagios-plugins-x.y.z) from http://www.nagios.org/download/. I also advise to get the official Nagios documentation (http://www.nagios.org/docs/) if you plan to tune the configuration explained here. Unpack the tarball : tar xzf nagios-2.0.tar.gz tar xzf nagios-plugins-1.4.2.tar.gz 1.2 1.2 Create user First, we need to create the user Nagios will run under : adduser nagios mkdir /usr/local/nagios chown nagios.nagios /usr/local/nagios You will probably want to issue external commands from the web interface. So you need to identify the user your web-server run as. For Apache, you can get it with : grep "^User" /etc/httpd/conf/httpd.conf By default, the user is Apache. See /etc/passwd file or report to you web-server installation if you are running another web server. Also note that the path to httpd.conf can vary depending on your system. We need to create a group whose members include the user your web server is running as and the user Nagios is running as. /usr/sbin/groupadd nagcmd /usr/sbin/usermod -G nagcmd apache /usr/sbin/usermod -G nagcmd nagios Recall to replace apache by the user name you obtained at last step. 1.3 Configuration and compilation We can now configure and install Nagios. Go to the directory where you untared the distribution and run : ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagios Depending on your system, you should get a configuration like the following : 2
  • 3. Configuration summary for nagios 2.0 02-07-2006 ***: General Options: ————————- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagios Embedded Perl: no Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock Init directory: /etc/rc.d/init.d Host OS: linux-gnu Web Interface Options: ———————— HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /bin/traceroute Now let’s compile and install : make all make install make install-init make install-config make install-init allows to run nagios at startup (/etc/rc.d/init.d/nagios). This does not always work (I had problems on Fedora Core 4) but we see another way to run it at startup later on. make install-config installs the sample configuration files. This will be useful to setup a basic configuration. In order for nagios to be of any use to you, you need to install some plugins. First, install the official plugins. Go to the directory where you untared nagios-plugin-x.y.z and run : ./configure make make install 3
  • 4. 2 Configuration Normally, you should already have some configuration sample files in /usr/local/nagios/etc. Else, try to run again make install-config. Files should be called xxxx.cfg-sample, so you need to rename them : cd /usr/local/nagios/etc mv bigger.cfg-sample bigger.cfg (...) The entry point is through nagios.cfg. This file is run first when nagios starts. You may not need a lot of modifications in this file. log_file=/usr/local/nagios/var/nagios.log indicates where the logs will go. Set the appropriate owner of the log file : chown nagios.nagios /usr/local/nagios/var/nagios.log Other configuration files are called from nagios.cfg, for instance at lines : cfg_file=/usr/local/nagios/etc/checkcommands.cfg cfg_file=/usr/local/nagios/etc/misccommands.cfg Those files contain commands definition. And finally, our own configuration will be written in a new file (ma_conf.cfg for instance) so we need to replace : cfg_file=/usr/local/nagios/etc/minimal.cfg By : cfg_file=/usr/local/nagios/etc/ma_conf.cfg To create our configuration, we will take minimal.cfg as the basis : cp minimal.cfg ma_conf.cfg And now let’s edit it to setup a configuration for a simple network with one monitoring station and one NFSv4 server. 2.1 Time periods Time periods are used to define some monitoring periods. For the time being we can keep 24*7 but you may need to change it -for instance not to receive alarms if your NFS servers are down during night. 4
  • 5. 2.2 Contacts You will certainly need to add some contacts, which are persons in charge of monitoring the network. By default they will receive notification in 24*7 by e-mail. define contact{ contact_name adminNFS alias Jonathan Lyard service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email adminNFS@localhost } Now let’s create a contact group. This one will be used to indicate which contacts should be notified for each issue. Here is only one group, but feel free to add all groups you need (for instance if the ones in charge of NFS administration are different from network administrators). define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagios-admin,adminNFS } 2.3 Hosts In addition to localhost, you must specify all hosts your are monitoring. I assume they are all on-link (in the same LAN as your monitoring station). Else, see Nagios official documentation to get it working through routers (use parents option). Here is what is required in order to monitor a machine called nfs2 with IP address 192.168.0.5. Alarms from this host will be reported to the "admins" group. 5
  • 6. define host{ use generic-host ; Name of host template to use host_name nfs2 alias nfs2 address 192.168.0.5 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } 2.4 Hostgroups In this basic configuration, we will only have one hostgroup. You can define several hostgroups to group hosts together in Nagios interface. define hostgroup{ hostgroup_name nfsv4config alias NFSv4 test configuration members localhost,nfs2 } 2.5 Services Finally, one can find services definition. Services do not necessarily mean real services that run on host (FTP, POP, HTTP...) but also some other types of metric associated with the host (response to ping, number of logged-in user, free disk space...). For instance, to monitor connectivity for localhost and our nfs2 server, we need the following service definition : define service{ use generic-service ; Name of service template to use host_name localhost,nfs2 6
  • 7. service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } Later on, we will also define a service to monitor NFSv4. 2.6 Web server configuration In this step, you will learn how to configure the web-server. I assume you are using Apache, but the configuration may be similar for other web-servers. Check your own web-server’s documentation to put it at work. Add the following lines in httpd.conf (in general /etc/httpd/conf/httpd.conf). ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin Directory /usr/local/nagios/sbin # SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 7
  • 8. AuthName Nagios Access AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user /Directory Alias /nagios /usr/local/nagios/share Directory /usr/local/nagios/share # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName Nagios Access AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user /Directory This configuration enable authentication. The first directory entry is for CGI scripts, the second for html pages. Of course, you can tune this configuration to fit your requirements. You can also disable authentication by setting use_authentication=0 in /usr/local/nagios/etc/cgi.cfg but then, you will not be allowed to run remote commands. Use it only if you have a problem with au- thentication. You now need to create one or more users being able to authenticate. For the first one (-c to create the file htpasswd.users) : htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin and for (possible) next users : htpasswd /usr/local/nagios/etc/htpasswd.users nagiosadmin2 Then, you need to give some rights to the users. 8
  • 9. You can do it by editing the file /usr/local/nagios/etc/cgi.cfg. For instance : authorized_for_system_information=nagiosadmin,nagiosadmin2 And so on for all line you want to grant privilege to nagiosadmin and nagiosadmin2. I have uncommented all authorized line and give access to nagiosadmin. I advised to at least do the same if want to be able to configure everything from the web interface. For more details on the access rights, read the chapter "Authentication and Authorization in the CGIs" in Nagios official documentation. Restart your web browser to take modifications into account : /usr/sbin/httpd -k restart You should be able to point http://localhost in your web browser proving that your web server is up. You should also be able to point http://localhost/nagios/ and authenticate yourself with one of the user created previously (htpasswd). At this time, the CGI will not works since Nagios is not running. 3 Run Nagios To run Nagios, you can use the following command to make it start as a foreground process: /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg & If make install-init failed to make Nagios run at startup you can add this command to /etc/rc.d/rc.local (here on FC4 but path and filename can vary depending on distribution). To check that all configuration files are alright, you can issue : /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Finally, a useful command to restart Nagios and therefore consider modifications in the configuration files : killall -SIGHUP nagios Enjoy monitoring systems with Nagios! Jonathan Lyard {jonathan.lyard@bull.net} 9