Open main menu

CDOT Wiki β

Changes

How to Setup and configure Nagios

6,529 bytes added, 17:13, 14 November 2010
no edit summary
* Monitor Nagios clients
 
'''2.2 Prerequisites'''
 
During portions of the installation you will need to have root access to your machine.
 
<pre>
Note: root password is **********
</pre>
 
Make sure you've installed the following packages on your Fedora 13 installation before continuing.
* Apache
* PHP
* GCC compiler
* GD development libraries
 
<pre>
Note: you have to be root to install the following packages.
</pre>
 
<code>yum install httpd php</code>
<code>yum install gcc glibc glibc-common</code>
 
<code>yum install gd gd-devel</code>
 
'''2.3 Create Account Information'''
 
1. While you still have root privilages from a previous step, create a new nagios user account and give it a password.
 
<code>useradd -m nagios</code>
<code>passwd senecaCdot</code>
 
2. Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
 
<code>groupadd nagcmd</code>
 
<code>usermod -a -G nagcmd nagios</code>
 
<code>usermod -a -G nagcmd apache</code>
 
'''2.4 Download Nagios and the Plugins'''
 
1. Create a directory for storing the downloads.
 
<code>mkdir ~/nagios/downloads</code>
 
<code>cd ~/nagios/downloads</code>
 
Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions).
 
<code>wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz </code>
 
<code>wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz </code>
 
 
'''2.5 Compile and Install Nagios'''
 
1. Extract the Nagios source code tarball.
 
<code>cd ~/nagios/downloads</code>
 
<code>tar xzf nagios-3.2.3.tar.gz</code>
 
<code>cd nagios-3.2.3 </code>
 
2. Run the Nagios configure script, passing the name of the group you created earlier, using the following command:
 
<code>./configure --with-command-group=nagcmd </code>
 
3. Compile the Nagios source code.
 
<code>make all</code>
 
4. Install binaries, init script, sample config files and set permissions on the external command directory.
 
<pre>Note: you have to be root to issue the following commands.</pre>
 
<code>make install </code>
 
<code>make install-init </code>
 
<code>make install-config </code>
 
<code>make install-commandmode</code>
 
<pre>Note: DO NOT start Nagios yet</pre>
 
'''2.6 Customize Configuration'''
 
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.
 
<code>vi /usr/local/nagios/etc/objects/contacts.cfg </code>
 
<pre>Note: this will be changed to Chris Tyler’s email.</pre>
 
'''2.7 Configure the Web Interface'''
 
1. Install the Nagios web config file in the Apache conf.d directory.
 
<code>cd /home/nagios/downloads/nagios-3.2.3</code>
 
<pre>Note: you have to be root to issue the following command. </pre>
 
<code>make install-webconf</code>
 
2. Create a nagiosadmin account for logging into the Nagios web interface.
 
<code>htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin </code>
 
Type the password: **********
 
3. Restart Apache to make the new settings take effect.
<code>service httpd restart</code>
 
'''2.8 Compile and Install the Nagios Plugins'''
 
1. Extract the Nagios plugins source code tarball.
 
<code>cd ~/downloads</code>
 
<code>tar xzf nagios-plugins-1.4.15.tar.gz </code>
 
<code>cd nagios-plugins-1.4.15 </code>
 
2. Compile and install the plugins.
 
<code>./configure --with-nagios-user=nagios --with-nagios-group=nagios </code>
 
<code>make</code>
<pre>Note: you have to be root to issue make install command.</pre>
 
<code>make install</code>
 
'''2.9 Start Nagios'''
 
1. Add Nagios to the list of system services and have it automatically start when the system boots.
 
<code>chkconfig --add nagios </code>
 
<code>chkconfig nagios on </code>
 
2. Verify the sample Nagios configuration files.
 
<code>/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg </code>
<pre>You have to have no warnings or errors:
 
Total Warnings: 0
Total Errors: 0</pre>
 
3. If there are no errors, start Nagios. If you got errors, please check nagios.cfg file in step 2, and try it again.
<code>service nagios start </code>
 
'''2.10 Modify SELinux Settings'''
 
Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.
 
1. See if SELinux is in Enforcing mode.
 
<code>getenforce </code>
 
2. Put SELinux into Permissive mode.
 
<code>setenforce 0 </code>
 
3. To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot.
Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:
 
<code>chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ </code>
 
<code>chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ </code>
 
'''2.11 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. For a password that you configured please refere to the section 2.7, step 2.
<code>http://localhost/nagios/ </code>
 
Click on the "Service Detail" navigational bar 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.
 
'''2.12 Open Port 5666 on Firewall'''
 
Make sure your machine's firewall rules are configured to allow access to the web server if you want to access the Nagios interface remotely.
 
1. Create a rule for iptables.
 
<code>iptables -I INPUT -p tcp -m tcp ---dport 5666 -j ACCEPT </code>
 
2. Save the new iptables rule so it will survive machine reboots.
 
<code>service iptables save</code>
 
'''2.13 You're Done'''
 
Congratulations! You sucessfully installed Nagios. Your journey into monitoring is just beginning. You have just completed the basic configuration of the Nagios Server. You'll no doubt want to monitor more than just your local machine, so keep reading and you will find how to configure the client machine with some modifications on Nagios server.
If you did everything as per specifications, the following page will be displayed upon initial access of the Nagios Server GUI:
1
edit