Rabu, 18 Februari 2009

HOW TO INSTALL UBUNTU 7.10 NAGIOS 2.11 CENTREON 1.4.2.4

Nagios and Centreon are the perfect Network System Monitoring Solution. Oreon has became a reference as a Nagios Frontend. The Centreon/Nagios couple is used by a wide range of users, from novices to skilled users, even if they didn't knew Nagios before.



INSTALL OS


1.Install Ubuntu Desktop 7.10
2.Remove OpenOffice (optional)
3.Enable VNC Server, System > Admin > Logon > Remote Logon

Install SSHD
# apt-get install openssh-server

Install Compilers and Libraries (may ask the Ubuntu CD)
# apt-get install libc6-dev g++ gcc
# apt-get install libgd2-xpm libgd2-xpm-dev libjpeg62-dev libgd-tools
Install Zlib, Libpng Required by LibGD and then LibGD
# wget http://www.gzip.org/zlib/zlib-1.2.3.tar.gz
# wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.25.tar.gz
# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz

Install Apache
# apt-get install apache

+------------------+
| INSTALL NAGIOS |
+------------------+
# groupadd nagios
# adduser nagios
# passwd nagios
Check if Nagios User is created
# grep nagios /etc/passwd
# grep "^User" /etc/apache2/apache2.conf
Add Webserver user (www-data/apache) and Nagios user (nagios)
# usermod -G nagios nagios
# usermod -G www-data,nagios www-data
Check if the users are the members of the group by
# grep nagios /etc/group
# mkdir /usr/local/nagios

# apt-get install build-essential
# apt-get install libgd2-dev (dosent always find)

# wget http://downloads.sourceforge.net/nagios/nagios-2.11.tar.gz?modtime=1205331081&big_mirror=0
# md5sum nagios-2.11.tar.gz |grep "058c1f4829de748b42da1b584cccc941"
# ./configure --enable-embedded-perl --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagios

Create a Symbolic Link to Perl
# ln -s /usr/lib/libperl.so.5.8.8 libperl.so
Install Nagios
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# ls -l /usr/local/nagios
You should see five different subdirectories.

SETTING THE WEBSERVER
Set the password for the Web Access
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
edit the apache2.conf
# vim /etc/apache2/apache2.conf
COPY AND PASTE:
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

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

Alias /nagios /usr/local/nagios/share

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


Edit cgi.cfg to allow nagiosadmin user
# vim /usr/local/nagios/etc/cgi.cfg
authorized_for_system_information=nagiosadmin

Restart Apache and Nagios
# /etc/init.d/apache2 restart
# /etc/init.d/nagios restart


+--------------------------+
| INSTALL NAGIOS PLUGINS |
+--------------------------+

->Install OpenSSL (optional)
# wget http://www.openssl.org/source/openssl-0.9.7m.tar.gz
# tar -zxvf openssl-0.9.7m.tar.gz
# cd openssl-0.9.7m.tar.gz
# mkdir /etc/openssl
# ./config --openssldir=/etc/openssl

# wget http://downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.11.tar.gz?modtime=1197587122&big_mirror=0
# ./configure --with-openssl=/etc/openssl --enable-perl-modules --prefix=/usr/local/nagios --with-nagios-user=nagios
# make all
# make install
Check if the plugins are here
# ls -l /usr/local/nagios/libexec
Give nagios:nagios permission
# chown nagios:nagios /usr/local/nagios/libexec


+-------------------------------+
| INSTALL OREON WEB INTERFACE |
+-------------------------------+

Install MySQL
# apt-get install mysql-server
Install php5
# apt-get install php5
# apt-get install php-db php-date
# apt-get install php5-gd php5-mysql php5-snmp php5-ldap
# apt-get install php-mail php-mail-mime php-net-smtp php-net-socket
# apt-get install php5-xmlrpc
Install PostFix
# apt-get install postfix
Install SendMail
# apt-get install sendmail
RRDtool
# apt-get install rrdtool librrds-perl
Perl Libs
# apt-get install libconfig-inifiles-perl
Snmp
# apt-get install snmp snmpd libnet-snmp-perl

Upgrade PEAR
# pear upgrade pear
# pear install -o -f --alldeps DB_DataObject DB_DataObject_FormBuilder MDB2 Numbers_Roman \
Numbers_Words HTML_Common HTML_QuickForm2 HTML_QuickForm_advmultiselect HTML_Table Auth_SASL \
HTTP Image_Canvas Image_Color Image_Graph Image_GraphViz Net_Traceroute Net_Ping Validate XML_RPC
# pear install -o -f --alldeps SOAP

Get Oreon (at this time latest is 1.4.2.4 03/03/2008 , 2 should be on its way.
# wget http://download.oreon-project.org/index.php?id=74
# md5sum centreon-1.4.2.4.tar.gz | grep "3c8cdaaf92bd8600e42e1278902222cc"
# bash install.sh

All defaults OK, but these:
Where is installed RRD perl modules [RRDs.pm] ? /usr/lib/perl5/
Where is mail binary ? /usr/sbin/sendmail

Setup the Permissions
# chown www-data:nagios -R /usr/local/nagios/libexec/
# chmod 775 -R /usr/local/nagios/libexec/

Start Configuration
http:///oreon/install/setup.php

Oreon Installation is DONE:
http:///oreon/


+----------+
| APPENDIX |
+----------+
*Common Linux Instalation:
# tar -zxvf gd-2.0.35.tar.gz
# cd gd-2.0.35
# ./configure
# make
# make install

**SETUP SAMBA ROOTSHARE:
Note: This will give COMPLETE RW access to you linux server,
I do not recomend this in production but for testing only!
# apt-get install samba
# /usr/bin/smbpasswd root
Copy And Paste this Config
# vim /etc/samba/smb.conf
[global]
workgroup = OSX
realm = OSX
server string = %h server
interfaces = eth0
obey pam restrictions = Yes
passdb backend = tdbsam
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
panic action = /usr/share/samba/panic-action %d
[ShareRoot]
comment = Root
path = /
username = root
valid users = %S, root
force user = root
read only = No
create mask = 0700
directory mask = 0700
guest ok = Yes
# /etc/init.d/samba restart
In windows cmd:
# net use p: \\IP\ShareRoot /user:root

***ALLOW MYSQL REMOTE ACCESS:
MySQL5 - connect from Remote
1. download Navicat 8 (or others MYSQL Win Clients)
2. Login via SSH
Edit /etc/mysql/my.cnf with bind-address = 192.168.X.X (localhost IP)
# vim /etc/mysql/my.cnf
# mysql -u root -p mysql
use oreon
GRANT ALL ON ods.* TO root@'192.168.X.X' IDENTIFIED BY 'PASSWORD';
use ods
GRANT ALL ON ods.* TO root@'192.168.X.X' IDENTIFIED BY 'PASSWORD';
# /etc/init.d/mysql restart
Run Navicat to browse MySQL DB

****GRAPH USING OREON ODS
make sure to start ods
# /etc/init.d/ods start
Oreon Web Interface - > create a service template > Data Treatment > Process Perf Data (On)
Configure ODS
Oreon Web Interface - > Options > CentreonDataStorage > Config
Be sure that you have the .rrd files created
# find / -name *.rrd

*****Make Nagios Pretty ( Nuvola Style )
First Backup /usr/local/nagios/share/*..html and all stylesheets directory.
# cd /usr/local/nagios/share
# wget http://www.xoroz.com/files/nagiosstyle.zip
# unzip nagiosstyle.zip
Set the permissions
# chown nagios:nagios *.*
# chown nagios:nagios -R side
# chown nagios:nagios -R stylesheet
Edit the config.js with your correct cgi-bin
# /etc/init.d/apache2 restart

*******More cool cmds
Get an overview of all hosts (new cmd with nagios 2.11)
# /usr/local/nagios/bin/nagiostats /usr/local/nagios/etc/nagios.cfg -v NUMHOSTS

********Autostart Daemon Ubuntu
# /usr/sbin/update-rc.d mysql defaults

Installing on Debian-Based Distributions (Debian, Ubuntu)

Add the OpenNMS Repository to Your sources.list

First, you need to tell apt-get how to find OpenNMS. Add the following contents to your /etc/apt/sources.lists file:

 deb http://debian.opennms.org stable main
deb-src http://debian.opennms.org stable main

(If you wish the latest development version of OpenNMS, which may include features not available in the current stable release, use unstable instead of stable.)

 deb http://debian.opennms.org unstable main
deb-src http://debian.opennms.org unstable main

Add the OpenNMS PGP Key to APT

The official OpenNMS packages are signed with a GPG / PGP key. The fingerprint for the official release key is:

 22EE DDA6 8698 B02F B2EC  50B7 062B 8A68 4C4C BBD9

You will need to tell APT about the key:

 wget -O - http://debian.opennms.org/OPENNMS-GPG-KEY | sudo apt-key add -

On Debian 4.0 (etch) and Ubuntu 7.10 (gutsy) or newer

As Sun Java has been put under the GPL it's sufficient to type "apt-get install opennms" since Debian 4.0 (etch) or Ubuntu 7.10 (gutsy); the dependencies will be fulfilled automatically.

On older Debian and Ubuntu releases

Installing on older Debian or Ubuntu releases involves additional steps to get a Sun Java 5 or Java 6 JDK. Instructions are available online, but if possible, save yourself the trouble and use a newer release that includes Sun Java in the default repositories.

Configure OpenNMS

First, for the purposes of convenience, we are going to set the $OPENNMS_HOME environment variable before running any commands.

 export OPENNMS_HOME=/usr/share/opennms

(If you are not using a bourne-compatible shell, you may need to use different syntax.)


Configure Your Database

OpenNMS needs to be able to connect to PostgreSQL as the "postgres" user (by default) over a TCP/IP connection.

RedHat-based systems
/etc/init.d/postgresql start
/sbin/service postgresql start
pg_hba.conf and postgresql.conf are in /var/lib/pgsql/data
Debian-based systems
/etc/init.d/postgresql-X.X start
pg_hba.conf and postgresql.conf are in /etc/postgresql/X.X/main
Mac OS X (Fink)
/sw/bin/pgsql.sh start

Edit pg_hba.conf to Allow postgres to Authenticate

To allow the "postgres" user to connect, you will need to edit your database's pg_hba.conf file, which is usually created on installation or the first startup of PostgreSQL, depending on your distribution: By default, it will have something like this at the bottom:

 local   all         all                               ident sameuser
host all all 127.0.0.1/32 ident sameuser
host all all ::1/128 ident sameuser

You will need to change "ident sameuser" to "trust":

 local   all         all                               trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust

Edit postgresql.conf to Allow TCP/IP Connections

You may also need to change the postgresql.conf to allow TCP/IP connections, if it cannot do so already. On older PostgreSQL versions, this is enabled with the flag:

 tcpip_socket = true

On newer PostgreSQL versions, this is enabled with:

 # you can use "*" to listen on all addresses
listen_addresses = 'localhost'

Restart the Database

Once you've made these changes, you need to restart your database.

Create the opennms Database

If not done, use "sudo -u postgres createdb -U postgres -E UNICODE opennms" to create the database in postgres.

Insert the IPLIKE Stored Procedure in the Database

If this is your first time installing OpenNMS or iplike, you should make sure that iplike is configured in your database. First you need to install the iplike package from OpenNMS package repositories.

For RPM-based distributions using YUM:

 yum install iplike

For DEB-based distributions using APT (use suffix pgsql74, pgsql81, pgsql82, or pgsql83 according to the version of PostgreSQL on your system):

 apt-get install iplike-pgsql83

If the OpenNMS database is already configured, you are good to go. If not, you have to issue manually:

 install_iplike.sh

Tell OpenNMS Where to Find Java

OpenNMS needs to know where to find Java to be able to start up. To tell it how to do so, you run $OPENNMS_HOME/bin/runjava like so:

 $OPENNMS_HOME/bin/runjava -s

This will search $JAVA_HOME and other common locations for your JDK. If you wish to use a specific JDK, you can run it with the -S flag instead:

 $OPENNMS_HOME/bin/runjava -S /usr/java/jdk1.5.0_12/bin/java

Add the JAVA_HOME in /etc/default/opennms

 JAVA_HOME=/usr

Initialize OpenNMS and the Database

Next, you need to run the OpenNMS installer, which will initialize the OpenNMS database, and do some other basic setup. Upon upgrade, you should run this command again to make sure your database schema and other things required at startup are up-to-date.

In most cases, you can just run:

 $OPENNMS_HOME/bin/install -dis

Sometimes you may need to tell OpenNMS where to find libjicmp.so; in that case, you can use the -l option (OpenNMS 1.3.5 and higher):

 # i386 example
$OPENNMS_HOME/bin/install -dis -l /usr/lib/jni:/usr/lib
# x86_64 example
$OPENNMS_HOME/bin/install -dis -l /usr/lib64/jni:/usr/lib64

Start OpenNMS

You should have a basic OpenNMS installation ready now, so start it up:

 sudo /etc/init.d/opennms start

As of OpenNMS 1.3.7, by default, the web UI will come up using the embedded Jetty servlet container, on port 8980. Open your browser and point it at:

 http://yourhost:8980/opennms/

the user name and password are both "admin" to start.

Discover Your Network

Finding Hosts

First, OpenNMS needs to know which devices (or, "nodes") you want it to discover. To discover nodes, OpenNMS does a ping sweep on IP address ranges that you configure it to discover. If an IP address that OpenNMS is not already managing responds to a discovery ping, then OpenNMS will begin scanning that IP address for services, create a new node in its database, and begin monitoring the node's interfaces and services. A new install of OpenNMS will not perform any discovery until you add one or more address ranges to the discovery configuration. You do this by logging into the web UI as the admin user and navigating to the Admin menu and then clicking on 'Configure Discovery' under the Operations section.

In the Include Ranges section of the Home / Admin / Discovery / Modify Configuration page, click on the 'Add New' button. In the window that pops up, enter the beginning and ending IP addresses for the range that you wish to include for discovery. The default values for Retries and Timeout are usually appropriate. Click the 'Add' button, and the popup window will close and the new range will show up in the Include Ranges section. Click the 'Save and Restart Discovery' button to apply your changes. Discovery of the newly added range will begin within a few seconds; the ping requests and service scans are spread out over time to avoid flooding your network, so it will take some time for all nodes in your newly added range to be scanned and discovered.

For more detailed information on discovery configuration, including how to add IP addresses manually to the discovery configuration file, see Discovery.

Get Notifications When Problems Occur

To get started, we need to configure the main admin user to have a valid e-mail address.

  1. Log in as admin to the web UI
  2. Go to Admin in the menu bar
  3. Under the Operations section, set the Notification Status radio button to On and click the Update button
  4. Under the OpenNMS System section, go to Configure Users, Groups and Roles and then Configure Users
  5. click the icon under "Modify" for the admin user
  6. set the Email address, and click the Finish button

This should get OpenNMS configured to send the default notifications to the administrator e-mail address.

Notifications are extremely flexible and can be configured to do complex escalations, scheduled outages, and user management. Detailed instructions are available in the Notification Configuration How-To.