Today we did a Linux hangout on Google+. During the hangout we discussed how to setup a Nagios core server on CentOS 6.2. Mike Weber shared his Nagios installation script and explained how it can install Nagios quite easily in about 3 minutes. This script is located down below the video on this page.
Special thanks to +Rich Gillin for hanging out live.
See upcoming Linux hangouts and a list of topics.
#!/bin/bash
# This script comes with no warranty ...use at own risk
# Copyright (C) 2010 Mike Weber
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#####################################################################
# The purpose of the script is to install Nagios and plugins using source.
# DESIGNED AND TESTED ON CENTOS 5.5
# Created September 21, 2010
# Modified November 26, 2010
# Modified March 14,2011
# Modified July 24, 2011 update to make compatible with CentOS 6
# Updated for Nagios 3.3.1 July 26 ,2011
# Tested on CentOS 6.2 Jan. 12, 2012
#####################################################################
# Script Must Run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
cd /usr/local/src
yum install -y wget
wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
yum install -y httpd php gcc glibc glibc-common gd gd-devel make mysql mysql-devel net-snmp
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
tar zxvf nagios-3.3.1.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all
make install; make install-init; make install-config; make install-commandmode; make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
cd ..
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
chkconfig --add nagios
chkconfig --level 3 nagios on
chkconfig --level 3 httpd on
exit 0


{ 4 comments… read them below or add one }
Thanks a lot for the instructions and the script,
The install went perfectly, after install I did a set of password to get in the system
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
I can login to nagios but if I click on hosts I get:
Internal Server Error
The server encountered an internal error or misconfiguration …….
In the Var log I get:
Feb 4 20:12:36 richard nagios: SERVICE ALERT: localhost;HTTP;WARNING;SOFT;1;HTTP WARNING: HTTP/1.1 403 Forbidden – 5237 bytes in 0.009 second response time
So i’m getting close I think,
In the presentation you mention NagiosVI if i’m right, is that recommended for a dummy user
Thanks
Richard
The issue with theHTTP/1.1 403 Forbidden is because you do not have a index.html file in /var/www/html. Just do:
touch /var/www/html/index.html
That will stop that error.
Thanks That solved it,
Unfortunatly I still get the following
[root@localhost bin]# ./nagios -v /usr/local/nagios/etc/cgi.cfg
Nagios Core 3.3.1
…….
Reading configuration data…
Error in configuration file ‘/usr/local/nagios/etc/cgi.cfg’ – Line 15 (UNKNOWN VARIABLE)
Error processing main config file!
Line 15 is main_config_file=/usr/local/nagios/etc/nagios.cfg
When I check this file no errors found :S
thanks Richard
r.tilman@ymail.com
Here is the problem, I think.
This is incorrect:
nagios -v /usr/local/nagios/etc/cgi.cfg
You should process the nagios.cfg file instead.
nagios -v /usr/local/nagios/etc/nagios.cfg
The error is telling you that you are processing the wrong file.