Nagios One-click installation Script V1.0 (client + server)

Source: Internet
Author: User

Server-side script:

#!//bin/bash#nagios One-click installation Script path= ' pwd ' Yum_user () {echo -e  "\033[32m start to install the Base support kit and add Users ... \033[0m" yum  -y install httpd gcc glibc glibc-common gd gd-devel if [  $? -ne 0 ]then   echo -e  "\033[31myum installation failed! \033[0m "  exit 1fiecho -e " \033[32mnagios dependent component Installation complete!\033[0m "/usr/sbin/useradd -m  nagios &&/usr/sbin/groupadd nagcmd/usr/sbin/usermod -a -G nagcmd  Nagios/usr/sbin/usermod -a -g nagcmd apacheif [ $? -ne 0 ]then    echo -e  "\033[31m Add user failed! \033[0m "  exit 2fiecho -e " \033[32mnagios user group configuration complete!\033[0m "}nagios_ins () {ECHO&NBSP;-E   "\033[32m start installing NAGIOS_CN program ... \033[0m" CD&NBSP;${PATH}/DOWNLOADTAR&NBSP;JXVF&NBSP;NAGIOS-CN-*.TAR.BZ2CD  nagios-cn-*./configure --with-command-group=nagcmdmake allmake installmake install-init   make install-configmake install-commandmodemake install-webconfif [  $? -ne 0 ]then   echo -e  "\033[31MNAGIOS_CN installation failed!\033[0m"    exit 3fiecho -e  "\033[32MNAGIOS_CN program installed successfully!\033[0m" echo -e  "\033[32m start setting Nagios_ CN program ... \033[0m "echo -en " \033[32m Please enter nagiosadmin user password: \033[0m "READ&NBSP;PASSWDHTPASSWD&NBSP;-CB  /usr/local/nagios/etc/htpasswd.users nagiosadmin ${passwd}service httpd restart  chkconfig --add httpd &&chkconfig httpd onchkconfig --add  Nagios &&chkconfig nagios on cat>>/root/.bashrc<<eofalias check_ nagios= '/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg ' EOFservice nagios  restart if [ $? -ne 0 ]then   echo -e  "\033[ 31MNAGIOS_CN Setup failed!\033[0m "  exit 3fiecho -e  "\033[32MNAGIOS_CN program setup succeeded!\033[0m"}nagios_plugins_ins () {echo -e  "\033[ 32m start installing the Nagios_plugins program ... \033[0m "CD&NBSP;${PATH}/DOWNLOADTAR&NBSP;ZXVF&NBSP;NAGIOS-PLUGINS-*.TAR.GZCD  nagios-plugins-*./configure --with-nagios-user=nagios --with-nagios-group=nagiosmake&& make install if [ $? -ne 0 ]then   echo -e  "\033[ 31mnagios_plugins installation Failed! \033[0m "  exit 2fiecho -e " \033[32mnagios_plugins program installed successfully!\033[0m "}nrpe_ins () {echo  -e  "\033[32m start installing Nagios_plugins program ... \033[0m" cd ${path}/downloadtar zxvf nrpe-*. tar.gzcd nrpe-*./configure --with-nagios-user=nagios --with-nagios-group=nagiosmake  Allmake install-pluginmake install-daemonmake install-daemon-configif [ $? -ne  0 ]then   echo -e  "\033[31mnrpe installation failed! \033[0m "  exit 2fiecho -e&nbSP; " \033[32mnrpe Program Installation Successful!\033[0m "echo -e " \033[32m start setting Nrpe program ... \033[0m "cat>>/usr/local/nagios/etc /objects/commands.cfg<<eofdefine command{   command_name     check_nrpe   command_line     $USER 1$/check_nrpe -h  $HOSTADDRESS $  -t 30 -c  $ARG 1$   }eof/usr/local/nagios/bin/nrpe -c /usr/local/ nagios/etc/nrpe.cfg -d cat >> /etc/rc.d/rc.local << eof               /usr/local/nagios/bin/nrpe -c  /usr/local/nagios/etc/nrpe.cfg -d     eofif [ $? -ne 0  ]then   echo -e  "\033[31mnrpe settings failed! \033[0m "  exit 2fiecho -e " \033[32mnrpe program setup succeeded!\033[0m "}echo -e " \033[ 33m start Installation nagios......\033[0m "echo -e " \033[32m\n\t (1) basic suite with userAdd \n\t (2) Install nagios-cn\n\t (3) Install nagios-plugins\n\t (4) Install nrpe\n\t (5) Exit program (exit) \033[0m "read -p " Please enter select: "  choicecase ${choice} in1)    yum_user;; 2)    nagios_ins;; 3)    nagios_plugins_ins;; 4)    nrpe_ins;; 5)     break;; *)    echo -e  "\033[31m you entered: $num, settings do not have this option, please re-enter  \033[0m"    break;; Esac

client script:

#!/bin/bashpath= ' pwd ' nagios_server= "192.168.1.1" Yum_user () {echo -e  "\033[32m start to install the Base support kit and add users ... \ 033[0m "yum -y install gcc  if [ $? -ne 0 ]then    echo -e  "\033[31myum installation failed! \033[0m "  exit 1fiecho -e " \033[32mnagios dependent component Installation complete!\033[0m "/usr/sbin/useradd -m  nagios if [ $? -ne 0 ]then   echo -e  "\033[ 31m Add user failed! \033[0m "  exit 2fiecho -e " \033[32mnagios User Configuration Complete!\033[0m "}nagios_plugins_ins () {echo  -e  "\033[32m start installing Nagios_plugins program ... \033[0m" cd ${path}tar zxvf nagios-plugins-*. Tar.gzcd nagios-plugins-*./configure --with-nagios-user=nagios --with-nagios-group=nagiosmake &&make install chown nagios.nagios /usr/local/nagios/chown -R  Nagios.nagios /usr/local/nagios/libexec/if [ $? -ne 0 ]then   echo -e  "\033[31mnagios_plugins installation failed! \033[0m "  exit 2fiecho -e " \033[32mnagios_plugins program installed successfully!\033[0m "}nrpe_ins () {echo  -e  "\033[32m start installing Nagios_plugins program ... \033[0m" CD&NBSP;${PATH}TAR&NBSP;ZXVF&NBSP;NRPE-*.TAR.GZCD  nrpe-*./configure --with-nagios-user=nagios --with-nagios-group=nagiosmake allmake  INSTALL-PLUGINMAKE&NBSP;INSTALL-DAEMONMAKE&NBSP;INSTALL-DAEMON-CONFIGIF&NBSP;[&NBSP;$?&NBSP;-NE&NBSP;0&NBSP;] then   echo -e  "\033[31mnrpe installation failed! \033[0m "  exit 2fiecho -e " \033[32mnrpe program installed successfully!\033[0m "echo -e " \033[ 32m start setting Nrpe program ... \033[0m "cat >> /etc/rc.d/rc.local << eof               >/usr/local/nagios/bin/nrpe -c  /usr/local/nagios/etc/nrpe.cfg -d     eofsed -i  ' [email protected ][email protected][emAil protected] '  /usr/local/nagios/etc/nrpe.cfg/usr/local/nagios/bin/nrpe -c /usr/local/ Nagios/etc/nrpe.cfg -d sleep 1/usr/local/nagios/libexec/check_nrpe -h ${nagios_server }if [ $? -ne 0 ]then   echo -e  "\033[31mnrpe Setup failed! \033[0m "  exit 2fiecho -e " \033[32mnrpe program setup succeeded!\033[0m "}echo -e " \033[ 33m start Installation nagios_client......\033[0m "echo -e " \033[32m\n\t (1) Base kit with user add \n\t (2) Install nagios-plugins\n\t (3) Install nrpe\n\t (4) Exit program (exit) \033[0m "read -p " Please enter select: " choicecase ${choice} in1)     yum_user;; 2)    nagios_plugins_ins;; 3)    nrpe_ins;; 4)     break;; *)    echo -e  "\033[31m you entered: $num, settings do not have this option, please re-enter  \033[0m"    break;; Esac


This article is from the "Give Me Three moles" blog, please be sure to keep this source http://wushuangjay.blog.51cto.com/3125450/1568555

Nagios One-click installation Script V1.0 (client + server)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.