An automated installation of Nagios services

Source: Internet
Author: User

Statement

The Stars last night

Blog:http://yestreenstars.blog.51cto.com/

This article by oneself creation, if need reprint, please indicate source, thank cooperation!

Objective

Automate the installation of Nagios services with one click.

Environment

Os:centos 6.2 32

nagios:4.0.7

nagios-plugins:2.0.3

nrpe:2.15

Configuration

#!/bin/bash# script name: one-key automatic install nagios service#  author: yestreenstars# create time: 2014-08-05echo -n  "Closing SELinux  and modifying /etc/selinux/config ... "setenforce 0 > /dev/null 2> &1sed -i  '/^selinux=/s/=.*/=disabled/'  /etc/selinux/configecho  ' completed! ' echo -n  "Configuring iptables firewall ..." iptables -fiptables -xiptables -a  INPUT -m state --state RELATED,ESTABLISHED -j ACCEPTiptables -A  Input -m state --state new -m tcp -p tcp --dport 22 -j  acceptiptables -a input -m state --state new -m tcp -p  tcp --dport 80 -j ACCEPTiptables -A INPUT -p icmp -j  acceptiptables -a input -i lo -j acceptiptables -p input dropiptables -p forward  dropservice iptables save > /dev/null 2>&1echo  "Completed!" echo -n  "Adding nagios user ..." useradd -s /sbin/nologin nagios & & echo  "completed!" echo -n  "Installing related software ..." yum -y install gcc gd  gd-devel glibc glibc-common httpd openssl openssl-devel php make  net-snmp wget > /dev/null 2>&1 && echo  "Completed!" echo -n  "Downloading nagios, nagios-plugins and nrpe ..." (wget -P /tmp  http://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.7/nagios-4.0.7.tar.gz & &wget -P /tmp http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz & &wget -p /tmp http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz)  >  /dev/null 2>&1 && echo  "completed!"  | |   (echo  "failure!"  && exit) echo -n  "Installing nagios ..." tar xzf /tmp/ nagios-4.0.7.tar.gz -c /usr/src/cd /usr/src/nagios-4.0.7/(./configure &&make  all &&make install &&make install-init &&make  install-commandmode &&make install-config &&make install-webconf)   > /dev/null 2>&1 && echo  "completed!" echo -n  "Installing nagios-plugins ..." tar xzf /tmp/nagios-plugins-2.0.3.tar.gz - C /USR/SRC/CD /USR/SRC/NAGIOS-PLUGINS-2.0.3/(./configure && make &&  make install)  > /dev/null 2>&1 && echo  "completed!" echo -n  "Installing nrpe ..." tar xzf /tmp/nrpe-2.15.tar.gz -c /usr/src/cd  /USR/SRC/NRPE-2.15/(./configure &&make all &&make install-plugin  &&make install-daemon &&make install-daemon-config)  > /dev/ null 2>&1 && echo  "completed!" chown -r nagios:nagios /usr/local/nagios/echo -n  "starting httpd and  Nagios service ... "(Service httpd start && service nagios start)  > /dev/null 2>&1 && echo  "completed!" echo -n  "Adding httpd and nagios service to run on startup ... "chkconfig httpd onchkconfig --add nagioschkconfig nagios onecho " completed! "

After running the above script, you need to manually run the following command to set the password for the administrator user:

Htpasswd-c/usr/local/nagios/etc/htpasswd.users Nagiosadmin

The client is accessed via http://service-side Ip/nagios.

This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1536028

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.