nagios 使用源码包自动部署脚本
把这个脚本和nagios安装源码包以及插件源码包放到一起,执行脚本就可以自动部署了,现在分为2部分,第一部分安装nagios ,第二部分安装nagios-plugins,安装之前会判断需要的软件包是否存在,如果有未安装的会提示你安装,yum安装就可以,关于yum仓库配置,我之前有发过一个脚本,执行那个脚本就可以,在第一部分安装的最后,会提示你输入密码,那个密码就是web访问的密码,登陆用户为nagiosadmin,安装完成后直接访问即可,后续会加入nrpe以及nsca 部分配置内容。[*]
[*]#install nagios
[*]#chenjian
[*]#2010-009-01
[*]
[*]export LANG=en_US.UTF-8
[*]
[*]NAGIOS=./nagios-*.tar.gz
[*]NAGIOS_PLIUGINS=./nagios-plugins-*.tar.gz
[*]NEED_PACKAGE="httpd gcc glibc glibc-common gd gd-devel php"
[*]MYDATE=`date +%Y-%m-%d`
[*]
[*]
[*]if [ $(id -u) -ne 0 ]
[*] thenecho error -please use super user.
[*] exit 2
[*]fi
[*]
[*]
[*]check_status () {
[*]if [ $? -ne 0 ]
[*]then clear
[*] echo $1
[*] exit 2
[*]else
[*] echo $1
[*]fi
[*]}
[*]
[*]
[*]check_need_package () {
[*]echo -------- Step1 : Check the relevant package installation situation.
[*]echo `rpm -qa $NEED_PACKAGE |sed 's/-*\..*//g'` > /tmp/install_nagios
[*]
[*]for i in$NEED_PACKAGE
[*] do `grep $i /tmp/install_nagios >& /dev/null`
[*] if [ $? -eq 0 ]
[*] then
[*] :
[*] else
[*] echo $i is not install.
[*] SITUATION=OK
[*] fi
[*]
[*]done
[*]
[*]if [ $SITUATION ]
[*] then exit 2
[*]fi
[*]}
[*]
[*]server () {
[*]cat & /dev/null
[*] then
[*] chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
[*] chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
[*]fi
[*]
[*]echo Set apache and nagios start at boot time.
[*]
[*]chkconfig httpd on && echo apache set
[*]chkconfig nagios on && echo nagios set
[*]
[*]
[*]service httpd start
[*]service nagios start
[*]
[*]echo -e "
[*]-------------------------------------------------------------------\n
[*]install nagios successful ,please use http://yourip/nagios access\n
[*] user: nagiosadmin password: ***(just set)
[*]-------------------------------------------------------------------"
[*]exit 0
[*]
[*];;
[*]
[*]
[*]2)
[*]clear
[*]check_need_package
[*]
[*]if [ ! -f $NAGIOS_PLIUGINS ]
[*] then echo "Nagios-pliugins source package not found."
[*] exit 2
[*]else
[*] tar -zxf $NAGIOS_PLIUGINS -C /tmp
[*] cd /tmp/nagios-plugins*
[*] clear
[*] echo Step2 : Configure and compile the source code for your system ,please wait.....
[*] sleep 5
[*] ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[*]fi
[*]
[*]if [ $? -eq 0 ]
[*]then echo -------- Configure Successful.
[*]
[*]fi
[*]
[*]clear
[*] echo Step3 : Make and install everything ,please wait.....
[*] sleep 5
[*] make
[*] check_status "make"
[*] make install
[*] check_status "make install"
[*]echo -e "
[*]-------------------------------------------------------------------\n
[*]install nagios plugins successful.\n
[*]-------------------------------------------------------------------"
[*]cd ~
[*]
[*]rm -rf /tmp/nagios-plugins*
[*]rm -rf /tmp/install_nagios
[*];;
[*]
[*]q)
[*]exit 0
[*];;
[*]*)
[*]portal
[*];;
[*]esac
[*]}
[*]
[*]main () {
[*]clear
[*]portal
[*]exit 0
[*]}
[*]
[*]main
页:
[1]