#!/bin/bash
#Nagios Core and Plugins Installation Script
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd apache
tar zxvf nagios-4.4.5.tar.gz
tar zxvf nagios-plugins-2.3.3.tar.gz
cd nagios-4.4.5
./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
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
/etc/init.d/httpd start
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cd /tmp/nagios-plugins-2.3.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --add httpd
chkconfig --level 35 httpd on
#Open browser to http://<server.ip>/nagios
