The installation process of Nagios service end under lamp is detailed

Source: Internet
Author: User
Tags mkdir install perl


Prerequisite: The lamp environment is built to complete

Remark: After Centos6.4, Centos6.5, Centos7.0 test trial!
Script:

#!/bin/bash
# Author:byrd
# version:1.0
# Site:www.t4x.org
# contact:root#t4x.org
#This Script for nagios-v3.5.1
Path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
Export PATH
Lang= "en_US. UTF-8 "
# Check If user is root
If [$UID!= "0"]; Then
echo "Error:you must is root to run the script, please use the root to install Nagios3.5.1"
Exit 1
Fi
Clear
echo "========================================================================="
echo "INSTALL nagios-v3.5.1"
echo "========================================================================="
Nagiossoft=http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.5.1/nagios-3.5.1.tar.gz
Nagiospls=http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
Nagiosnrpe=http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
nagiosnrpv=nrpe-2.15
nagiospve=nagios-plugins-2.0.3
nagiosver=nagios-3.5.1
Nagiosdir=/byrd/tools/nagios
[!-D $NagiosDir] && mkdir-p $NagiosDir
If [' cat/etc/selinux/config | grep selinux=disabled | wc-l '-eq 0];then
Sed-i S#selinux=enforcing#selinux=disabled#g/etc/selinux/config
Setenforce 0
Useradd Nagios
Groupadd Nagcmd
Usermod-a-G Nagcmd Nagios
Usermod-a-G nagcmd Daemon
Yum Install ntpdate vim wget-y
echo ' Export lc_all=c ' >>/etc/profile
Source/etc/profile
Echo ' */10 * * */usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1 ' >>/var/spool/cron/root
Ntpdate time.nist.gov
Fi
if [!-f $NagiosDir/$NagiosVer. tar.gz];then
CD $NagiosDir
wget $NagiosSoft
Tar zxf $NagiosVer. tar.gz
CD Nagios
./configure--with-command-group=nagcmd--with-httpd-conf=/usr/local/apache/conf/extra
Make all
Make install
Retval=$?
Make Install-init
Make Install-commandmode
Make Install-config
Make install-webconf
/usr/local/apache/bin/htpasswd-cb/usr/local/nagios/etc/htpasswd.users Nagiosadmin admin123
Sed-i ' S#include conf/extra/httpd-default.conf#include conf/extra/httpd-default.confninclude conf/extra/ Nagios.conf#g '/usr/local/apache/conf/httpd.conf
/usr/local/apache/bin/apachectl-k restart
/etc/init.d/nagios start
Else
CD $NagiosDir
Tar zxf $NagiosVer. tar.gz
CD Nagios
Make clean
./configure--with-command-group=nagcmd--with-httpd-conf=/usr/local/apache/conf/extra
Make all
Make install
Retval=$?
Make Install-init
Make Install-commandmode
Make Install-config
Make install-webconf
/usr/local/apache/bin/htpasswd-cb/usr/local/nagios/etc/htpasswd.users Nagiosadmin admin123
Sed-i ' S#include conf/extra/httpd-default.conf#include conf/extra/httpd-default.confninclude conf/extra/ Nagios.conf#g '/usr/local/apache/conf/httpd.conf
/usr/local/apache/bin/apachectl-k restart
/etc/init.d/nagios start
Fi
If [$RETVAL-eq 0];then
echo "Nagios 3.5.1 Install Successful"
Else
Exit 1
Fi
Clear
echo "========================================================================="
echo "INSTALL nagios-plugins-2.0.3"
echo "========================================================================="
if [!-f $NagiosDir/$NagiosPve. tar.gz];then
CD $NagiosDir
Yum Install Perl-devel-y
wget $NagiosPls
Tar zxf $NagiosPve. tar.gz
CD $NagiosPve
./configure--with-nagios-user=nagios--with-nagios-group=nagios--enable-perl-modules--with-mysql=/usr/local/ Mysql
Make && make install
Retvalpls=$?
Else
CD $NagiosDir
Yum Install Perl-devel-y
Tar zxf $NagiosPve. tar.gz
CD $NagiosPve
Make clean
./configure--with-nagios-user=nagios--with-nagios-group=nagios--enable-perl-modules--with-mysql=/usr/local/ Mysql
Make && make install
Retvalpls=$?
Fi
If [$RETVALPls-eq 0];then
echo "$NagiosPve INSTALL Successful"
Else
echo "$NagiosPve INSTALL FAILED"
Exit $RETVALPls
Fi
if [!-f $NagiosDir/$NagiosNrpV. tar.gz];then
CD $NagiosDir
wget $NagiosNrpe
Tar zxf $NagiosNrpV. tar.gz
CD $NagiosNrpV
./configure
Make all
Make Install-plugin
Make Install-daemon
Make Install-daemon-config
Else
CD $NagiosDir
Tar zxf $NagiosNrpV. tar.gz
CD $NagiosNrpV
Make clean
./configure
Make all
Make Install-plugin
Make Install-daemon
Make Install-daemon-config
Fi
if [-f/usr/local/nagios/libexec/check_nrpe];then
echo "$NagiosNrpV INSTALL Successful"
Else
echo "$NagiosNrpV INSTALL FAILED"
Echo 1
Fi
Process:

[Root@nagios-server ~]# Uname-a
Linux nagios-server 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 00:31:26 UTC 2013 x86_64 x86_64 x86_64 gnu/linux
[Root@nagios-server ~]# Echo ' export lc_all=c ' >>/etc/profile
[Root@nagios-server ~]# Source/etc/profile
[Root@nagios-server ~]# Echo $LC _all
C
[Root@nagios-server ~]# Getenforce
Enforcing
[Root@nagios-server ~]# sed-i S#selinux=enforcing#selinux=disabled#g/etc/selinux/config
[Root@nagios-server ~]# Setenforce 0
[Root@nagios-server ~]# Cat/etc/selinux/config | grep selinux=
# selinux= can take one of these three values:
Selinux=disabled
[Root@nagios-server ~]# Yum Install ntpdate-y
[Root@nagios-server ~]# echo ' */10 * * */usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1 ' >>/var/spool/c Ron/root
[Root@nagios-server ~]# ntpdate time.nist.gov
[Root@nagios-server ~]# Mkdir/byrd/tools/nagios-p
[Root@nagios-server nagios]# cd/byrd/tools/nagios/
[Root@nagios-server nagios]# Yum Install wget-y
[Root@nagios-server nagios]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.5.1/nagios-3.5.1.tar.gz
[Root@nagios-server nagios]# tar zxf nagios-3.5.1.tar.gz
[Root@nagios-server nagios]# CD Nagios
[Root@nagios-server nagios]# Useradd Nagios
[Root@nagios-server nagios]# Groupadd Nagcmd
[Root@nagios-server nagios]# usermod-a-G nagcmd Nagios
[Root@nagios-server nagios]# usermod-a-G nagcmd Daemon
[Root@nagios-server nagios]# id-n-G Nagios
Nagios Nagcmd
[Root@nagios-server nagios]# id-n-G daemon
Daemon Bin ADM LP Nagcmd
[Root@nagios-server nagios]#./configure--with-command-group=nagcmd--with-httpd-conf=/usr/local/apache/conf/ Extra
[Root@nagios-server nagios]# make all
[Root@nagios-server nagios]# make install
[Root@nagios-server nagios]# make Install-init
[Root@nagios-server nagios]# make Install-commandmode
[Root@nagios-server nagios]# make Install-config
[Root@nagios-server nagios]# make install-webconf
[Root@nagios-server nagios]#/usr/local/apache/bin/htpasswd-cb/usr/local/nagios/etc/htpasswd.users Nagiosadmin Admin123
[Root@nagios-server nagios]# sed-i ' s#include conf/extra/httpd-default.conf#include conf/extra/ Httpd-default.confninclude conf/extra/nagios.conf#g '/usr/local/apache/conf/httpd.conf
[Root@nagios-server nagios]#/usr/local/apache/bin/apachectl-k Restart
[Root@nagios-server nagios]#/etc/init.d/nagios Checkconfig
[Root@nagios-server nagios]#/etc/init.d/nagios start
[Root@nagios-server nagios]# CD ...
[Root@nagios-server nagios]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
[Root@nagios-server nagios]# tar zxf nagios-plugins-2.0.3.tar.gz
[Root@nagios-server nagios]# CD nagios-plugins-2.0.3
[Root@nagios-server nagios-plugins-2.0.3]#./configure--with-nagios-user=nagios--with-nagios-group=nagios-- Enable-perl-modules--with-mysql=/usr/local/mysql
[Root@nagios-server nagios-plugins-2.0.3]# yum-y Install Perl-devel Perl-cpan
[Root@nagios-server nagios-plugins-2.0.3]# make && make install
[Root@nagios-server nagios-plugins-2.0.3]# CD ...
[Root@nagios-server nagios]# ll/usr/local/nagios/libexec/| Wc-l
61
[Root@nagios-server nagios]# pwd
/byrd/tools/nagios
[Root@nagios-server nagios]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
[Root@nagios-server nagios]# tar zxf nrpe-2.15.tar.gz
[Root@nagios-server nagios]# CD nrpe-2.15
[Root@nagios-server nrpe-2.15]#./configure
[Root@nagios-server nrpe-2.15]# make all
[Root@nagios-server nrpe-2.15]# make Install-plugin
[Root@nagios-server nrpe-2.15]# make Install-daemon
[Root@nagios-server nrpe-2.15]# make Install-daemon-config
Note:

[Root@nagios-server ~]#/etc/init.d/nagios start
Starting Nagios:done.
[Root@nagios-server ~]#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
Software:
nrpe:http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/
nagios:http://sourceforge.net/projects/nagios/
other:http://www.nagios.org/download/addons/

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.