声明
作者:昨夜星辰
博客:http://yestreenstars.blog.51cto.com/
本文由本人创作,如需转载,请注明出处,谢谢合作!
目的
一键自动化安装nagios客户端。
环境
OS: CentOS 6.2 32
nagios-plugins: 2.0.3
nrpe: 2.15
配置
#!/bin/bash # Script Name: One-key Automatic Install Nagios Client # Author: yestreenstars # Create Time: 2014-08-08 nagios_server_IP="192.168.1.88" # Change this to your nagios server‘s IP. echo -n "--Install related software..." yum -y install wget openssl openssl-devel > /dev/null 2>&1 && echo "Completed!" echo -n "--Install nagios-plugins..." useradd -M -s /sbin/nologin nagios wget -P /tmp http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz > /dev/null 2>&1 || (echo "Failure!" && exit) tar xzf /tmp/nagios-plugins-2.0.3.tar.gz -C /usr/src/ cd /usr/src/nagios-plugins-2.0.3/ (./configure && make && make install) > /dev/null 2>&1 && echo "Completed!" echo -n "--Installing nrpe..." wget -P /tmp http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz > /dev/null 2>&1 || (echo "Failure!" && exit) tar xzf /tmp/nrpe-2.15.tar.gz -C /usr/src/ cd /usr/src/nrpe-2.15/ ( ./configure && make all && make install-plugin && make install-daemon && make install-daemon-config ) > /dev/null 2>&1 && echo "Completed!" chown -R nagios:nagios /usr/local/nagios/ echo -n "--Setting NRPE..." sed -i ‘/^allowed_hosts=/s/$/,‘"$nagios_server_IP"‘/‘ /usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local iptables -I INPUT -p tcp --dport 5666 -j ACCEPT service iptables save > /dev/null 2>&1 && echo "Completed!"
一键自动化安装nagios客户端
时间: 2024-10-11 09:46:24