You will need to put in two passwords and say yes to packages for now.
Code: Select all
#!/bin/bash
# Script to install Nagios
downdir=~/nagdownloads
nag_usr=nagios
nag_grp=nagcmd
email=admin@test.com
if [ ! -d $downdir ]; then mkdir -p $downdir; fi
yum install wget httpd php perl
yum install make gcc glibc glibc-common gd gd-devel openssl openssl-devel
useradd -m $nag_usr
passwd $nag_usr
groupadd $nag_grp
usermod -a -G $nag_grp $nag_usr
usermod -a -G $nag_grp apache
wget -P ~/nagdownloads http://ncu.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
wget -P ~/nagdownloads http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
cd $downdir
tar -zxvf nagios-3.4.4.tar.gz
cd nagios
./configure --with-command-group=$nag_grp
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
cd ..
tar -zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=$nag_usr --with-nagios-group=$nag_grp
make
make install
chkconfig --add nagios
chkconfig nagios on
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
echo "<html><head></head><body>Place holder</body></html>" > /var/www/html/index.html
sed -i 's/-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT/-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT/' /etc/sysconfig/iptables
sed -i "s/nagios@localhost/$email/g" /usr/local/nagios/etc/objects/contacts.cfg
service iptables restart
service httpd restart
service nagios restart