Sunday, 13 October 2013

Centos 6/RHEL install Nagios

Nagios is a powerful monitoring system that enables you to identify and resolve infrastructure problems before they affect critical processes.

Designed with scalability and flexibility in mind, Nagios gives you the peace of mind that comes from knowing your business processes won't be affected by unknown outages.

Nagios is a powerful tool that provides you with instant awareness of your organization's mission-critical IT infrastructure. It allows you to detect and repair problems and mitigate future issues before they affect end-users and customers.

By using Nagios, you can:

  • Plan for infrastructure upgrades before outdated systems cause failures
  • Respond to issues at the first sign of a problem
  • Automatically fix problems when they are detected
  • Coordinate technical team responses
  • Ensure your organization's SLAs are being met
  • Ensure IT infrastructure outages have a minimal effect on your organization's bottom line
  • Monitor your entire infrastructure and business processes 

    To use Nagios, first make the necessary alterations to your network configuration file. 

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add the following to the configuration file, fill the X’s to your IP configuration:

Save and close the file, then restart the network service.

# service network restart
Now install the nagios related packages

# yum install httpd php gcc glibc glibc-common gd gd-devel openssl-devel wget perl make
Create the nagios user and set the password

# /usr/sbin/useradd -m nagios
# passwd nagios

Create the nagios group, nagcmd, which will allow external commands to be submitted through the web interface. 
Then add the nagios user and apache user to the group
# /usr/sbin/groupadd nagcmd

# /usr/sbin/usermod -a -G nagcmd nagios

# /usr/sbin/usermod -a -G nagcmd apache

Create a temp directory to place the nagios downloads

# mkdir ~/downloads cd ~/downloads

Download nagios

# wget  
Extract the nagios tar ball

# cd nagios
Run the nagios script passing the nagcmd group

# ./configure --with-command-group=nagcmd
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/rc.d/init.d Apache conf.d directory: /etc/httpd/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/

Compile the nagios source code

# make all

Install the binaries, init script, sample configs, and set permissions on external command directory

# make install

# make install-init

# make install-config

# make install-commandmode
The sample config files have been installed in the /usr/local/nagios/etc directory. 
Edit the /usr/local/nagios/etc/objects/contacts.cfg file 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
Configure the web interface

# make install-webconf
Create the nagiosadmin account for logging into the web interface

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Httpd

# service httpd restart
Download the plugins 
# tar xzf nagios-plugin (tab)

# cd nagios-plugins (tab)
Compile and install the plugins

# ./configure --with-nagios-user=nagios –with-nagios-group=nagios

# make

# make install
Add nagios to the system services and have it start when system boots

# chkconfig --add nagios

# chkconfig nagios on
Verify the nagios configuration files

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

# service nagios start
Find out if you have SELinux in Enforced mode


Run the following commands to run the CGIs under SELinux enforcing/targeted mode

chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
Log into the nagios web interface

Username will be nagiosadmin unless you specified different, plus the password you have set. 
You can also add numerous extras from Nagios Exchange.

If you try to access the web interface remotely and the page doesn’t load, check to see if you have IPTABLES enabled

service iptables status
If you don’t see entries for port 80 and/or 443, then it is being denied.

Allow http and https services through IPTABLES:

vi /etc/sysconfig/iptables
Add the following entries:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

No comments:

Post a Comment