#!/bin/sh
ipfw add allow ip from any to any
fetch
fetch
#add user
pw adduser nagios -w random
#passwd nagios
#nagios-plugins-1.4.9.tar.gz
tar xzvf nagios-plugins-1.4.15.tar.gz
tar xzvf nrpe-2.12.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/nagios &&make &&make install
chown nagios:nagios /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios/libexec
cd ..
#nrpe-2.8.1.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
#ipfw
ipfw add allow tcp from 121.9.211.44 to me 5666
ipfw add allow tcp from me 5666 to 121.9.211.44
echo "ipfw add allow tcp from 121.9.211.44 to me 5666" >> /etc/ipfw.conf
echo "ipfw add allow tcp from me 5666 to 121.9.211.44" >>/etc/ipfw.conf
#mkdir -p /opt/nagios/etc
#mkdir -p /opt/nagios/bin
#cp sample-config/nrpe.cfg /opt/nagios/etc/
#cp src/nrpe /opt/nagios/bin/
#sed -i 's/127.0.0.1/127.0.0.1,121.9.13.195/' /usr/local/nagios/etc/nrpe.cfg
#sed -i 's/usr\/local/opt/g' /opt/nagios/etc/nrpe.cfg
sed -in-place -e 's/127.0.0.1/127.0.0.1,121.9.211.44/g' /usr/local/nagios/etc/nrpe.cfg
sed -in-place -e 's/hda1/da0s1f/g' /usr/local/nagios/etc/nrpe.cfg
#start
/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
ipfw delete `ipfw list | grep "allow ip from any to any" | awk '{print $1}'`
阅读(1238) | 评论(0) | 转发(0) |