MonitoringExchange
NagiosForge
NagiosWiki
Nagios Community Platform powered by NETWAYS

HowTos:BestPractice:NagiosFromSourceDebian

Search  
From MonEx Wiki
Jump to: navigation, search

Nagios from Source (Debian/Ubuntu)

Contents


These Best Practice guide are intended to provide you with simple instructions on how to install Nagios from source (code) on Debian or Ubuntu and have it monitoring your local machine within 20 minutes.
No advanced installation options are discussed here - just the basics that will work for 95% of users who want to get started.

The advanced installations are discussed on another Best Practice Guide. The basic Nagios installation is always this Best Practice.


Requirement

What do you needed?

  • Installing Debian/Ubuntu System (best a minimal installation)
  • The Build programs (gcc, make, etc.)
apt-get install apache2 build-essential libgd-dev libperl-dev openssl gcc make autoconf automake
  • Create Nagios-User and Nagios-Groups
- groupadd -g 9000 nagios
- groupadd -g 9001 nagcmd
- useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c "Nagios User" nagios 


Installation

You need for a simple Nagios System two Sourcefiles from the Nagios Homepage Download:

  • nagios-x.x.x.tar.gz
  • nagios-plugins-x.x.x.tar.gz

Save the Source-Files on your Nagios-Server in the /usr/local/src directory.

Nagios

  • Extract the Nagios source code tarball
tar xzvf nagios-x.x.x.tar.gz
  • change into the sourcefolder
cd nagios-x.x.x
  • Run the Nagios configure script, passing the name of the group you created earlier like so
    With the --help command you see a lot of configuration options.
    I'm installing with this options
./configure --enable-nanosleep --enable-embedded-perl --with-command-group=nagcmd
  • Compile the Nagios source code
make all
  • Install binaries, init script, sample config files and set permissions on the external command directory
make install
make install-init
make install-config
make install-commandmode


Nagios Plugins

  • Extract the Nagios plugins source code tarball
tar xzvf nagios-plugins-x-x-x-tar.gz
  • change into the sourcefolder
cd nagios-plugins-x.x.x
  • Run the Nagios Plugins configure script
    With the --help command you see a lot of configuration options
./configure --with-ipv6 --with-nagios-user=nagios --with-nagios-group=nagios
  • Compile and install the plugins
make
make install
  • The Nagios Check-Plugins will be installing into the folder /usr/local/nagios/libexec


Configuration

Apache2

  • Copy the Nagios web config file in the Apache conf.d directory
cp /usr/local/src/nagios-x.x.x/sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf
  • Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  • Restart Apache to make the new settings take effect.
/etc/init.d/apache2 reload


Nagios

Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed...

  • Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.
vi /usr/local/nagios/etc/objects/contacts.cfg


First Start

  • Configure Nagios to automatically start when the system boots
update-rc.d nagios defaults 99
  • Verify the sample Nagios configuration files with follow command
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  • If there are no errors, start Nagios.
/etc/init.d/nagios start


Login to the Web Interface

  • You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.
http://localhost/nagios/
  • Click on the "Service Detail" navbar link to see details of what's being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time.