[客户端]批量部署监控客户端,多机分发

环境:CENTOS 5.5 x64

IP:10.0.0.12
====================
# for cacti
yum install net-snmp -y
配置/etc/snmp/snmpd.conf
/etc/init.d/snmpd start

echo "/etc/init.d/snmpd start"  >>/etc/rc.local

################################################
#for  nagios
#创建nagios需要的用户及组
/usr/sbin/adduser nagios -M

cd /root/tools
wget http://cdnetworks-kr-2.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/elain/apps/nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
--enable-redhat-pthread-workaround
make
make install
cd ..

wget http://cdnetworks-kr-2.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --prefix=/elain/apps/nagios --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-ssl --with-ssl-lib
make
make install
make install-xinetd
make install-daemon-config
cd ..

vi /elain/apps/nagios/etc/nrpe.cfg
修改:
allowed_hosts=127.0.0.1,10.0.0.0/24

chown -R nagios.nagios /elain/apps/nagios

/elain/apps/nagios/bin/nrpe -c /elain/apps/nagios/etc/nrpe.cfg -d
echo "/elain/apps/nagios/bin/nrpe -c /elain/apps/nagios/etc/nrpe.cfg -d" >>/etc/rc.local

#重启nagios nrpe组合命令
pkill nrpe && /elain/apps/nagios/bin/nrpe -c /elain/apps/nagios/etc/nrpe.cfg -d

cd /elain/apps
tar zcvf nagios.tar.gz nagios/
mv nagios.tar.gz /root/bak
cd


多机分发,快速部署
在IP为25上,分发到IP 为28上,其它服务器依次类推

scp /root/bak/nagios.tar.gz 10.0.0.28:/elain/apps/
scp /etc/snmp/snmpd.conf 10.0.0.28:/etc/snmp/snmpd.conf.ok

#登录到28上,若做了批量远程执行命令,刚无需登录此服务器,
ssh 10.0.0.28
/usr/sbin/adduser nagios -M
cd /elain/apps
tar zxvf nagios.tar.gz
rm -rf  nagios.tar.gz

/elain/apps/nagios/bin/nrpe -c /elain/apps/nagios/etc/nrpe.cfg -d
echo "/elain/apps/nagios/bin/nrpe -c /elain/apps/nagios/etc/nrpe.cfg -d" >>/etc/rc.local

# for cacti
yum install net-snmp -y
mv /etc/snmp/snmpd.conf.ok /etc/snmp/snmpd.conf
/etc/init.d/snmpd start

echo "/etc/init.d/snmpd start"  >>/etc/rc.local

在这里只是提供给大家一个思路,欢迎大家一起交流敏捷运维!