nagios服务器端自动安装脚本

1、操作系统centos6.2 最小化安装

破公司非得弄个nagios自动化安装,以前倒是写过一个客户端的自动化安装,这回得写服务器的自动化安装了,额 由于附件大于2M 所以上传到下载中心了,没注意不小心要了4个豆。有豆的话可以直接下载,没有的话也没关系 我把脚本贴上来 就是需要下载一些软件包而已

下载地址 http://down.51cto.com/data/775915

[root@mail nagios]# vi nagios.sh
#!/bin/bash

#install xinetd
rpm -ivh  xinetd-2.3.14-33.el6.x86_64.rpm

#install bianyi huanjing
yum -y install zlib-devel openssl-devel libtermcap-devel libxml2-devel gcc-c++ libtool-ltdl-devel  curl-devel make gcc gd gd-devel mailx

#intsall apache
yum -y install httpd
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
sed -i 's/Listen 80/Listen 8181/g' /etc/httpd/conf/httpd.conf
sed -i 's/index.html/index.html index.php/g' /etc/httpd/conf/httpd.conf
cat nagios.conf >>/etc/httpd/conf/httpd.conf
service httpd start


#install php
yum -y install php php-devel
echo -e  "AddType application/x-httpd-php .php .phtml" >>/etc/httpd/conf/httpd.conf
@
"nagios.sh" 86L, 2599C
sed -i 's/127.0.0.1/$IP/g' /etc/xinetd.d/nrpe
echo -e "nrpe 5666/tcp #nrpe" >>/etc/services
service xinetd start

#config
cat command >>/usr/local/nagios/etc/objects/commands.cfg

#iptables -A INPUT -p tcp --dport 8181 -j ACCEPT
#iptables -A INPUT -p tcp --dport 5666 -j ACCEPT
#echo -e "-A INPUT -p tcp --dport 8181 -j ACCEPT"
#echo -e "-A INPUT -p tcp --dport 5666 -j ACCEPT"
mv /etc/sysconfig/iptables /etc/sysconfig/iptables.bak
mv iptables /etc/sysconfig/
chmod 600 /etc/sysconfig/iptables
service iptables restart

#create nagiosadmin
touch /usr/local/nagios/etc/htpasswd.users
chown -R nagios:nagios /usr/local/nagios
htpasswd  -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
service httpd restart

不多说了搞运维的基本上都能看懂上面的代码

因为原来机器的80端口被占用所以我用的是8181端口

http://192.168.X.X:8181/nagios/ 

你可能感兴趣的:(安装,服务器)