Pages

Tuesday, April 19, 2016

Bash Script For Installing Nagios 3.3.1

Note: Dependancies must be installed before you run script, otherwise it would through an error.

#####################Script Starts Here#######################
#!/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

#####################Script Ends Here#######################

No comments:

Post a Comment

Please give us suggestions.

Shell Script Code