Tuesday, July 7, 2009

HOWTO install Nagios Core (UBUNTU)

HOWTO install Nagios Core (UBUNTU)

1.- Documents and Installer

Go to Nagios Project Page
http://www.nagios.org/

2.- Summary Steps:

Step 1 - Download Nagios Core

Required. Contains the monitoring application and web interface.

Step 2 - Download Nagios Plugins

Also Required. Allows you to monitor services, applications, metrics, and more.

Step 3 - Download Nagios Addons

Trick out your Nagios install by extending its capabilities with hundreds of community-contributed addons.

3.- Installation:

wmunguiam@server:/var/www/nagios$ sudo apt-get install php5-gd gcc make libgd2-xpm-dev libjpeg62-dev libnet-snmp-perl libxpm-dev libfreetype6 libjpeg62 libnet-snmp-perl libpng12-0


4.- User creation:

wmunguiam@server:/var/www/nagios$ sudo -s
root@server:/var/www/nagios# /usr/sbin/useradd -m -s /bin/bash nagios

root@server:/var/www/nagios# passwd nagios

Introduzca la nueva contraseña de UNIX: XZY
Vuelva a escribir la nueva contraseña de UNIX: XZY
passwd: contraseña actualizada correctamente

5.- Group creation:
root@server:/var/www/nagios# /usr/sbin/groupadd nagcmd root@server:/var/www/nagios# /usr/sbin/usermod -a -G nagcmd nagios
root@server:/var/www/nagios# /usr/sbin/usermod -a -G nagcmd www-data


6.- Compiling Nagios:

A.- CONFIGURE:
root@server:/var/www/nagios# ./configure --with-command-group=nagcmd
checking for a BSD-compatible install... /usr/bin/install -c checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no ... ... config.status: creating t-tap/Makefile config.status: creating include/config.h config.status: creating include/snprintf.h config.status: creating include/cgiutils.h Creating sample config files in sample-config/ ... *** Configuration summary for nagios 3.1.2 06-23-2009 ***: General Options: -------------------------
Nagios executable: nagios

Nagios user/group: nagios,nagios

Command user/group: nagios,nagcmd
Embedded Perl: no
Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/conf.d
Mail program: /bin/mail Host
OS: linux-gnu
Web Interface Options: ------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/sbin/traceroute

Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.

B.- MAKE ALL:

root@server:/var/www/nagios# make all
*** Compile finished ***
If the main program and CGIs compiled without any errors, you can continue with installing Nagios as follows (type 'make' without any arguments for a list of all possible options):
make install - This installs the main program, CGIs, and HTML files
make install-init - This installs the init script in /etc/init.d
make install-commandmode
- This installs and configures permissions on the directory for holding the external command file
make install-config - This installs *SAMPLE* config files in /usr/local/nagios/etc You'll have to modify these sample files before you can use Nagios. Read the HTML documentation for more info on doing this. Pay particular attention to the docs on object configuration files, as they determine what/how things get monitored! make install-webconf - This installs the Apache config file for the Nagios web interface


C.- MAKE INSTALL, INSTALL-INIT, INSTALL-CONFIG, INSTALL-COMMAND-MODE:

root@server:/var/www/nagios# make install
*** Main program, CGIs and HTML files installed ***

root@server:/var/www/nagios# make install-init

/usr/bin/install -c -m 755 -d -o root -g root /etc/init.d /usr/bin/install -c -m 755 -o root -g root daemon-init /etc/init.d/nagios *** Init script installed ***

root@server:/var/www/nagios# make install-config
*** Config files installed *** Remember, these are *SAMPLE* config files. You'll need to read the documentation for more information on how to actually define services, hosts, etc. to fit your particular needs.

root@server:/var/www/nagios# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw chmod g+s /usr/local/nagios/var/rw *** External command directory configured ***


7.- EDIT Contact e-Mail:
root@server:/var/www/nagios# vim /usr/local/nagios/etc/objects/contacts.cfg

Change e-mail like:
email wmunguiam@My-email-contact.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

8.- Configure Web interface and create web user:

root@server:/var/www/nagios# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf
*** Nagios/Apache conf file installed ***

Web User Account:
root@server:/var/www/nagios# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: ABC
Re-type new password: ABC
Adding password for user nagiosadmin

9.- Restar Apache Service
root@server:/var/www/nagios# /etc/init.d/apache2 reload
* Reloading web server config apache2 [ OK ]

10.- Install Pluging
[Steps in the next post]

11.- Active Mail Sender
root@server:/var/www/nagios# sudo apt-get install mailx postfix
root@server:/var/www/nagios# sudo vim /usr/local/nagios/etc/objects/commands.cfg
Change following lines: (add "/usr" )

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
and restart nagios service:
root@server:/var/www/nagios# sudo /etc/init.d/nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.



2 comments:

  1. Can anyone recommend the top performing Patch Management program for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central network policy enforcement
    ? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

    ReplyDelete
  2. Thanks for posting these instructions which I followed without error, owever when logging in on webpage it shows Nagios 3.2.3 when I used Nagios 3.5.0. How can I check for actual installed and running version?

    ReplyDelete