nagios 使用源码包自动部署脚本
2010-09-06 11:07
633 查看
把这个脚本和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-[0-9]*.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 ] then echo error -please use super user. exit 2 fi check_status () { if [ $? -ne 0 ] then clear echo $1 [fail] exit 2 else echo $1 [OK] fi } check_need_package () { echo -------- Step1 : Check the relevant package installation situation. echo `rpm -qa $NEED_PACKAGE |sed 's/-[0-9]*\..*//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 <<eof nagios install ----------------------------------------------------------------------------------------------------------------- User:$USER Select the choice you want install Date:$MYDATE ----------------------------------------------------------------------------------------------------------------- 1) install nagios 2) install nagios-plugins q) exit programe ----------------------------------------------------------------------------------------------------------------- eof } portal () { clear server read info case $info in 1) clear check_need_package if ! id nagios >& /dev/null then useradd -m nagios groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache fi if [ ! -f $NAGIOS ] then echo "Nagios source package not found." exit 2 else tar -zxf $NAGIOS -C /tmp cd /tmp/nagios-[0-9]* clear echo Step2 : Configure and compile the source code for your system ,please wait..... sleep 5 ./configure --with-command-group=nagcmd fi if [ $? -eq 0 ] then echo -------- Configure Successful. fi clear echo Step3 : Make and install everything ,please wait..... sleep 5 make all check_status "make all" make install check_status "make install" make install-init check_status "make install-init" make install-config check_status "make install-config" make install-commandmode check_status "make install-commandmode" make install-webconf check_status "make install-webconf" if [ $? -eq 0 ] then clear echo Nagios make install Successful. fi clear echo set nagios web access password,username is nagiosadmin. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin cd ~ rm -rf /tmp/install_nagios rm -rf /tmp/nagios-[0-9]* clear if ! sestatus |awk '{print $3}' |grep disabled >& /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 [OK] chkconfig nagios on && echo nagios set [OK] 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
相关文章推荐
- rsyslog客户端自动部署脚本,经测试使用正常
- 通过ssh主机互信打通内、外网,使用shell脚本自动部署测试环境
- 使用vb脚本让电脑自动加入域源码
- 使用Kickstart安装脚本全自动快速部署CentOS 6.0
- 服务器环境之6:使用maven自动部署到tomcat及编写sh一键部署脚本
- 自动下载源码_并编译_打包_部署_重启服务的Shell脚本
- 使用shell脚本自动部署(发布,重起)maven(java)项目
- 使用Kickstat安装脚本全自动部署Centos
- 使用shell自动安装部署Nagios
- 使用ant脚本编译web工程并自动部署到tomcat
- Nconf点生成Nagios配置文件的同时自动执行脚本
- 使用bat脚本部署hexo到coding和github
- jenkins里面使用批处理命令进行自动部署
- BIEE 12c使用runcat.sh脚本部署catalog并移除BIConsumer角色
- 使用脚本,自动跳过丢失归档的恢复--------MODIFY SEQ
- Hibernate使用自定义脚本替换注解或者xml文件中的自动生成表结构
- 在nagios中使用nrpe自定义脚本
- 自动监控oracle 表空间使用量的脚本
- 使用shell脚本搭建源码LAMP环境
- bat写的自动部署脚本