Nagios Automated Script for CentOS


#!/bin/bash

Installing Basic Packages
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

Downloading Nagios Sources
cd /tmp
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.1.tar.gz
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
echo

Adding users
echo
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
echo

Unpacking Sources
echo
tar zxvf nagios-4.0.1.tar.gz
tar zxvf nagios-plugins-1.5.tar.gz
echo

Configuring & Making Nagios Core
echo
cd nagios-4.0.1
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
echo

Copying Files
echo
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
echo

Starting Services
echo
/etc/init.d/nagios start
/etc/init.d/httpd start
/etc/init.d/httpd restart
echo
echo
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
echo

Configuring & Making Nagios Plugins
echo
cd /tmp/nagios-plugins-1.5
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
echo

Configuring Startup Services
echo
chkconfig –add nagios
chkconfig –level 35 nagios on
chkconfig –add httpd
chkconfig –level 35 httpd on
echo

Installation Completed
http://IP-Address/nagios

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s