What is Nagios?,

Nagios is the most popular Opensource Network Monitoring tools, today i would like to share you the script how to install this tools on your linux Box to monitor your Network and applications: #!/bin/sh # Any Failing Command Will Cause The Script To Stop set -e # Treat Unset Variables As Errors set -u echo "***** Starting Nagios Quick-Install: " `date` echo "***** Installing pre-requisites" echo "***** Installing WGET so we could download the packages that we need" yum -y install wget echo "***** WGET has been installed" # Installing Packages For Centos echo "***** Installing very Important packages otherwise out Nagios wont work" yum -y install make make autoconf httpd php-snmp.i386 php-pear.noarch php-pear-File.noarch php-rrdtool.i386 php-xml.i386 php-mcrypt.i386 php-mysql.i386 php-ncurses.i386 php-devel.i386 php-gd.i386 php-jpgraph.noarch php-common yum -y install gcc g++ flex byacc yum -y install glibc glibc-common yum -y install gd gd-devel yum -y install perl # Adding user nagios echo "***** Setting up the environment" useradd -m nagios echo "YOUR_DESIRED_PASSWORD" |passwd --stdin nagios groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache # Getting Nagios Source Tarball with Plugins echo "***** Getting the Nagios Source and Plug-Ins" cd /usr/local/src wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz tar xzf nagios-3.0.6.tar.gz tar xzf nagios-plugins-1.4.13.tar.gz # Compiling and Nagios Installation echo "***** Installing Nagios" cd /usr/local/src/nagios-3.0.6 ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode make install-webconf # Setting up Password for Web authentification echo "***** Setting up htpasswd auth" htpasswd -nb nagiosadmin M0n1t0r > /usr/local/nagios/etc/htpasswd.users service httpd restart # Installing Nagios Plugins if fail do make clean echo "***** Setting up Nagios Plug-Ins" cd /usr/local/src/nagios-plugins-1.4.13 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install # Seting up SELinux echo "***** Fixing SELinux" chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ echo "***** Starting Nagios" chkconfig --add nagios chkconfig nagios on service nagios start service iptables stop # Installing Nagiosql3 for nagios Web administration fir we are going to backup our Current Nagios cd /usr/local tar cfv nagios.tar nagios cd /usr/local/nagios/share # Getting Nagiosql3 source tarball wget http://ovh.dl.sourceforge.net/sourceforge/nagiosql/nagiosql302.tar.gz tar xzf nagiosql302.tar.gz rm nagiosql302.tar.gz # Enabling installer touch /usr/local/nagios/share/nagiosql3/install/ENABLE_INSTALLER # Make sure to delete it after installation # Install pear install HTML_Template_IT mode pear install HTML_Template_IT # Changing Permission on NagioSQL chmod 777 /usr/local/nagios/share/nagiosql/config -R # Making necessary Folders for NagioSQL3 mkdir /usr/local/nagios/services mkdir /usr/local/nagios/hosts mkdir /usr/local/nagios/import mkdir -p /usr/local/nagios/backup/services mkdir /usr/local/nagios/backup/hosts # Setting Right Permission chmod 777 /usr/local/nagios/services -R chmod 777 /usr/local/nagios/hosts -R chmod 777 /usr/local/nagios/hosts -R chmod 777 /usr/local/nagios/backup/services -R chmod 777 /usr/local/nagios/import -R # Installing MySQL server for Database Nagiosql3 yum -y install mysql-server mysql-client service mysqld start # Settingup Root Password of MySQL mysqladmin -u root password "YOUR_DESIRED_PASSWORD" # echo "Now Go to http://`hostname`/nagios/nagiosql echo "***** Done: " `date`

feel free to comment and share if there error or problem with this scripts.