一键安装nagios
此脚本仅仅适用于centos 6.4 x86_64,yum安装的httpd和php,这里的安装过程以后我会整理一份手工安装版本的 需要源码安装的 请期待后面的更新。
nagios的报警之强大目前还没有别的软件可以比肩,也是运维人员必须要掌握的一个软件。包括nagios脚本的开发,各种应用的监控。这里先给新手朋友一个如何安装nagios的思路.
直接上脚本
#!/bin/bash
#Date: 2013/12/6
#BY:renzhenxing
#install nagios-server or nagios-plugs
read -p "Please input your nagiosadmin's password:" a
selinux=`grep SELINUX=enforcing /etc/selinux/config | awk -F "=" '{print $2}'`
if [ "$selinux" == "enforcing" ]
then
echo "your system Selinux not shut down,"
exit 1
fi
yum install -y wget gcc gcc++ gcc* bc net-snmp net-snmp-utils net-snmp-libs libpng libpng-devel libjpeg libjpeg-devel openssl098e gd* gd2* openssl-devel* openssl*
cd /usr/local/src
if [ -f nagios-4.0.1.tar.gz ]
then
echo ".........................................nagios.tar.gz..................is OK!!!"
else
echo "nagios.tar.gz.............................is not ok!!!..................download"
wget http://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.1/nagios-4.0.1.tar.gz
fi
if [ -f nagios-plugins-1.5.tar.gz ]
then
echo "............................................nagios-plugs .................is ok!!!"
else
echo "nagios-plugins-1.5.tar.gz....................is not ok !!!! ..............download"
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
fi
if [ -f nrpe-2.15.tar.gz ]
then
echo "............................................nrpe-2.15.tar.gz.................is ok!!!"
else
echo "..................................nrpe-2.15.tar.gz...is not ok!!!............download"
wget http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
fi
###add install nagios ID:
useradd -m nagios
echo "nagios" | passwd --stdin nagios
###add install gid:
groupadd nagcmd
###daemon 为apache运行账号:
usermod -a -G nagcmd daemon
###install nagios-4.0.1.tar.gz
tar -zxf nagios-4.0.1.tar.gz && cd nagios-4.0.1
./configure --with-command-group=nagcmd --with-gd-lib=/usr/local/libgd/lib/ --with-gd-inc=/usr/local/libgd/include/
make all
make install
make install-init
make install-config
make install-commandmode
cd ../
cat >>/etc/httpd/conf/httpd.conf |