nagios客户端一键安装-创新互联

         nagios 客户端一键安装安装

创新互联是专业的阳曲网站建设公司,阳曲接单;提供成都做网站、网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行阳曲网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

  此脚本为个人线上生产环境使用,不一定适合大众,脚本写的也很一般。希望大家多提意见。

1  这是改过之后的脚本,nrpe是放在xinetd里面启动的. 让nrpe的信息独立存放(本处放空文件了),snmpd的日志也独立存放。都不在写入系统messages。

#!/bin/bash
#Date: 2013/12/6
useradd nagios
cd /usr/local/src
wget http://10.100.0.11/nagios-c.tar.gz
tar zxvf nagios-c.tar.gz
tar zxvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure
make
make install
chown nagios:nagios /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios/libexec
cd ../
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
sed -i "s@allowed_hosts=127.0.0.1@allowed_hosts=127.0.0.1,10.100.0.11@" /usr/local/nagios/etc/nrpe.cfg
sed -i '/disable/i\        log_type        = file /dev/null' /etc/xinetd.d/nrpe
sed -i 's#127.0.0.1#10.100.0.11#' /etc/xinetd.d/nrpe
chkconfig xinetd on
service xinetd restart
netstat -an | grep 5666
if [ $? -eq 0 ];then
  echo -e "$R nrpe is start $E"
else
  echo -e "$R nrpe is not start!!!!!!! $E"
fi
echo -e "$R######################install snmpd ################################## $E"
rpm -qa | grep net-snmp
if [ $? -eq 0 ];then
   echo -e "$R net-snmp install ok! $E"
   sed -i 's#OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"#OPTIONS="-LS0-6d -Lf /var/log/snmpd.log -p /var/run/snmpd.pid"#' /etc/init.d/snmpd
   sed -i 's#access  notConfigGroup ""      any       noauth    exact  systemview none none#access  notConfigGroup ""      any       noauth    exact  all none none#' /etc/snmp/snmpd.conf
   sed -i 's#\#view all    included  .1                               80#view all    included  .1                               80#' /etc/snmp/snmpd.conf
   sed -i 's#com2sec notConfigUser  default       public#com2sec notConfigUser  10.100.0.11       100che#' /etc/snmp/snmpd.conf
else
   echo -e "$R snmpd is not install $E"
fi
service snmpd restart
chkconfig snmpd on
ps -ef | grep -v grep | grep snmpd
if [ $? -eq 0 ];then
   echo -e "$R snmpd is ok! $E "
else
   echo -e "$R snmpd is error $E"
fi

2  传统脚本,所有信息都是按照基本方式来的:

useradd nagios
cd /usr/local/src
#wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
#wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
#wget http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
wget http://10.100.0.11/nagios-c.tar.gz
tar zxvf nagios-c.tar.gz
tar zxvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure
make
make install
chown nagios:nagios /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios/libexec
cd ../
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
sed -i 's@allowed_hosts=127.0.0.1@allowed_hosts=127.0.0.1,10.100.0.11@' /usr/local/nagios/etc/nrpe.cfg
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
#check /etc/rc.local in nrpe process:
grep "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" /etc/rc.local
if  [ $? -eq 0 ];then
    echo "nrpe existing , not Don't need to write."
else
    echo " nrpe is not install ,but already write /etc/rc/local file. "
    echo "###this is nagios client BY:renzhenxing date:$(date +%F)" >> /etc/rc.local
    echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local
fi
netstat -an | grep -v "grep" | grep 5666
if [ $? -eq 0 ];then
  echo "nrpe is start "
else
  echo "nrpe is not start!!!!!!!"
fi

至此完成

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站题目:nagios客户端一键安装-创新互联
文章地址:http://myzitong.com/article/ccoesp.html