zoukankan      html  css  js  c++  java
  • nagios 安装

    #!/bin/sh
    ################################################
    #this scripts is created by oldboy
    #site:http://www.etiantian.org
    #blog:http://oldboy.blog.51cto.com
    ################################################
    NAGIOS_TOOLS_DIR=/home/oldboy/tools
    NAGIOS_INSTALL_DIR=/usr/local/nagios
    
    echo "------ step 1: config yum ------"
    cd /etc/yum.repos.d/
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    
    echo "------ step 2: config  profile------"
    echo 'export LC_ALL=C'>> /etc/profile
    source /etc/profile
    
    echo "------ step 3: stop iptables and selinux------"
    /etc/init.d/iptables stop
    /etc/init.d/iptables stop
    chkconfig iptables off
    setenforce 0
        if [ -f /etc/selinux/config ]; then
            sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
            setenforce 0
        fi
    echo "------ step 4: config time sync------"
    /usr/sbin/ntpdate pool.ntp.org
    echo '#time sync by oldboy at 2010-2-1'>>/var/spool/cron/root
    echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root
    crontab -l
    
    echo "------ step 5: install gcc and lamp env etc------"
    yum install gcc glibc glibc-common -y
    yum install gd gd-devel -y
    yum install httpd php php-gd -y
    yum install mysql* -y
    
    echo "------ step 6: add nagios  user and group------"
    /usr/sbin/useradd -m nagios
    #/usr/sbin/useradd apache
    /usr/sbin/groupadd nagcmd
    /usr/sbin/usermod -a -G nagcmd nagios
    /usr/sbin/usermod -a -G nagcmd apache
    
    echo "------ step 7: download and install nagios------"
    
    [ ! -f oldboy_training_nagios_soft.zip ] && exit 1
    
    unzip oldboy_training_nagios_soft.zip 
    
    tar xzf nagios-3.5.1.tar.gz
    
    cd nagios
    
    ./configure --with-command-group=nagcmd
    
    make all
    make install
    make install-init
    make install-config
    make install-commandmode
    make install-webconf
    cd ../
    
    echo "------ step 8: config web auth------"
    htpasswd -cb /usr/local/nagios/etc/htpasswd.users oldboy 123456
    
    echo "------ step 9: install nagios-plugins------"
    yum -y install perl-devel
    tar zxf nagios-plugins-1.4.16.tar.gz
    cd nagios-plugins-1.4.16
    ./configure --prefix=/usr/local/nagios  --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
    make && make install
    cd ../
    ls /usr/local/nagios/libexec/|wc -l
    
    echo "------ step 10: install nrpe------"
    tar zxvf nrpe-2.12.tar.gz
    cd nrpe-2.12
    ./configure 
    make all
    make install-plugin
    make install-daemon
    make install-daemon-config
    cd ..
    
    
    echo "------ step 11: startup service and check------"
    /etc/init.d/nagios start
    /etc/init.d/httpd start
    echo -----------
    lsof -i tcp:80
    echo ----------
    ps -ef|grep nagios
    echo "NAGIOS is successfully installed."
    echo ok
  • 相关阅读:
    【hdu 6214】Smallest Minimum Cut
    Spring Boot核心配置
    Spring Cloud是什么?
    Spring Boot开启的2种方式
    JVM运行时区域详解。
    史上最全Java多线程面试题及答案
    Git文件操作命令
    Git的安装配置
    Git SSH连接方式配置
    Intellij Idea乱码解决方案都在这里了
  • 原文地址:https://www.cnblogs.com/gaoyuechen/p/8686495.html
Copyright © 2011-2022 走看看