NAGIOS install script?


Hmmm… I came across this on my scratch pad… Not sure if I ever used this or not, I def wrote it because of the lame comments all over the place although I really don’t remember doing so…  I have been using NAGIOS XI as a pre-built vm lately so I may have used this for my initial final build as I recall building this thing many many times. LOL. I would give this a try on a test box first… LOL

Upon inspection.. ya this won’t really work as it requires the NAGIOS packages to be on the system first… oh wait no… wrong again… this is on a Debian system… it should work… LOL maybe I will test this myself now that I am actually looking at it… Strange that it is on Debian though… I mainly use centOS.  This must have been my MINT phase, I think 7.0.

nagios-server nagios_ALL_deps # cat Nagios_install.bash
#!/bin/bash
# This is the complete list of all dependencies for Nagios
# This must be run to get a basic Nagios install up and running
#
# Initial Message about user interaction requirement
#
echo “********* WARNING *** WARNING *** WARNING *********”
sleep 1
echo “********* WARNING *** WARNING *** WARNING *********”
sleep 1
echo “********* WARNING *** WARNING *** WARNING *********”
sleep 1
echo “This is an interactive script… You need to watch ”
echo “what is happeneing and make the appropriate entries…”
sleep 5
echo “OK then… here we go…”
sleep 3
#
# Basic account/group configuration
#
/usr/sbin/useradd -m -s /bin/bash -p ‘$6$S9e9UYYH$fCW5Jbqm7IX07IgzD4DiMsC3Py2JgDBu3jJ5nM5ppGac.W.ly6lgQEzFVbHS3ecpJvvSpACS65pvr8p9un7Hi.’ nagios
/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd www-data
#
# Tell the user the nagios users password
#
echo “The password for the nagios user is: nagios ”
sleep 3
echo “Moving along…”
sleep 3
#
# Make a dir for installation
#
mkdir -p /opt/nagios_ALL_deps/Nagios_downloads
#
# Change to the new install dir
#
cd /opt/nagios_ALL_deps/Nagios_downloads
#
# Grab all deps
# Some of these, namely postfix & mailx, will require user input during install
#
aptitude install gcc libcgi-perl librrds-perl libgd2-dev libgd2-xpm-dev snmp snmpd nmap libgd-gd2-perl libnet-snmp-perl mysql-server postfix mailx php5 apache2 libapache2-mod-php5 libapache2-mod-perl2 build-essential
#
# nagios3 is the aptitude package
#
# Grab the plugins
# the nagios3 called above includes all plugins
#
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
#
#
tar xzf nagios-3.2.0.tar.gz
cd nagios-3.2.0
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
#
# Interaction required here
#
echo “We are opening the /usr/local/nagios/etc/objects/contacts.cfg file for editing ”
sleep 1
echo “Change the email address associated with the nagiosadmin contact definition to the ”
echo “address you’d like to use for receiving alerts. The host name is a good choice here”
sleep 2
#
# 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
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 reload
#
#Compile and install the plugins.
#
cd /opt/nagios_ALL_deps/Nagios_downloads
tar xzvf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
#
# Start Nagios
# Configure Nagios to automatically start when the system boots.
#
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
#
# Verify the sample Nagios configuration files.
#
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#
# If there are no errors, start Nagios.
#
/etc/init.d/nagios start

echo “We are opening the /usr/local/nagios/etc/objects/commands.cfg file for editing ”
sleep 1
echo “change any ‘/bin/mail’ references to ‘/usr/bin/mail’ ”
echo “and then we will re-start Nagios and be finished !!”
sleep 2
#
# Configure mail: change any ‘/bin/mail’ references to ‘/usr/bin/mail’
#
vi /usr/local/nagios/etc/objects/commands.cfg
/etc/init.d/nagios restart
#
# Chkconfig nagios
#
chkconfig –add nagios
chkconfig nagios on
#
# Closing message
echo “This concludes the installation of Nagios ”
echo “Now navigate to http://localhost/nagios or”
echo “use the hosts IP address from a remote location”
# END SCRIPT

Advertisements

, , , , , , , , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: