Nagios 4.2.0发布 - 在RHEL / CentOS 7.x / 6.x / 5.x和Fedora 24-19上安装

Nagios是一个真棒开源监控工具,它为您提供了更全面的监测环境中始终保持关注您的所有机器 / 网络 ,你是否在你的数据中心或只是你的小实验室。

随着Nagios的 ,你可以在一个窗口上远程监控您的远程主机和他们的服务。 它显示了警告 表示 ,如果出现错误在你的服务器上 ,最终帮助我们防患于未然检测一些问题。 它可以帮助我们减少停机时间业务损失

近日,Nagios的发布了其最新版本的Nagios 4.2.0Nagios的插件2.1.2的最新的稳定版本上2016年8月1日。

本文旨在指导你如何从RHEL 7.x版/ 6.x中/ 5.x的 ,CentOS 7.x版/ 6.x中/ 5.x中源(tar包)安装最新的Nagios的4.2.0容易说明和Fedora 24-19分布。 30分钟内,你会监视你的本地机器上,没有任何先进的安装过程只有基本的安装,将工作100%,对大多数今天的Linux服务器。

请注意 :安装说明是在这里显示的是基于CentOS 7.2的Linux发行版编写的。

安装Nagios 4.2.0和Nagios插件2.1.2

如果您正确地遵循这些说明,您将得到以下信息。

  1. Nagios的和其插件会在/ usr /本地/ nagios的目录下安装。
  2. Nagios将被配置为监视本地计算机的一些服务( 磁盘使用 ,CPU负载当前用户总过程等)
  3. Nagios的网络界面将可在http://本地主机/ nagios的

第1步:安装必需的依赖关系

我们需要与源代码安装Nagios的4.2.0之前,安装Apache,PHP和像GCC,glibc ,glibc的常见GD库和它的开发库某些库。 而这样做的,我们可以用yum默认安装程序包。

[root@youcl]# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp
-------------- On Fedora 22+ Onwards -------------- 
[root@youcl]# dnf install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp

第2步:创建Nagios用户和组

创建一个新的nagios用户和nagcmd组帐户,并设置密码

[root@youcl]# useradd nagios
[root@youcl]# groupadd nagcmd

接下来,添加两个nagios用户和apache用户到nagcmd组。

[root@youcl]# usermod -G nagcmd nagios
[root@youcl]# usermod -G nagcmd apache

第3步:下载Nagios Core 4.2.0和Nagios Plugin 2.1.2

Nagios的安装以及所有未来的下载创建一个目录。

[root@youcl]# mkdir /root/nagios
[root@youcl]# cd /root/nagios

立即下载最新的Nagios的核心4.2.0Nagios的插件2.1.2包装用的wget命令

[root@youcl nagios~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz
[root@youcl nagios~]# wget https://www.nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz

第4步:提取Nagios Core及其插件

我们需要解压下载的软件包tar命令如下。

[root@youcl nagios~]# tar -xvf nagios-4.2.0.tar.gz
[root@youcl nagios~]# tar -xvf nagios-plugins-2.1.2.tar.gz

当使用tar命令提取这些tarball时,该目录中将出现两个新文件夹。

[root@youcl nagios ~]# ls -l
total 13528
drwxrwxr-x. 18 root root     4096 Aug 20  2015 nagios-4.2.0
-rw-r--r--.  1 root root 11142182 Aug 20  2015 nagios-4.2.0.tar.gz
drwxr-xr-x. 15 root root     4096 Aug  1 21:58 nagios-plugins-2.1.2
-rw-r--r--.  1 root root  2695301 Aug  1 21:58 nagios-plugins-2.1.2.tar.gz

配置Nagios Core

现在,我们首先将配置Nagios的核心和做的,所以我们需要去Nagios的目录并运行配置文件,如果一切顺利,它会显示在最后为样本输出的输出。 请看下面。

[root@youcl nagios~]# cd nagios-4.2.0
[root@youcl nagios-4.2.0 ]# ./configure --with-command-group=nagcmd
示例输出:
Creating sample config files in sample-config/ ...
*** Configuration summary for nagios 4.2.0 08-01-2016 ***:
General Options:
-------------------------
Nagios executable:  nagios
Nagios user/group:  nagios,nagios
Command user/group:  nagios,nagcmd
Event Broker:  yes
Install ${prefix}:  /usr/local/nagios
Install ${includedir}:  /usr/local/nagios/include/nagios
Lock file:  ${prefix}/var/nagios.lock
Check result directory:  ${prefix}/var/spool/checkresults
Init directory:  /etc/rc.d/init.d
Apache conf.d directory:  /etc/httpd/conf.d
Mail program:  /bin/mail
Host OS:  linux-gnu
IOBroker Method:  epoll
Web Interface Options:
------------------------
HTML URL:  http://localhost/nagios/
CGI URL:  http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):  /usr/bin/traceroute
Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

现在,配置后,我们需要编译安装所有与make命令的二进制文件和make install命令将安装所有在你的机器需要的库,我们可以进一步进行。

[root@youcl nagios-4.0.1 ]# make all
[root@youcl nagios-4.0.1 ]# make install
示例输出:
*** Exfoliation theme installed ***
NOTE: Use 'make install-classicui' to revert to classic Nagios theme
make[1]: Leaving directory '/root/nagios/nagios-4.2.0'
make install-basic
make[1]: Entering directory '/root/nagios/nagios-4.2.0'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/archives
/usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/spool/checkresults
chmod g+s /usr/local/nagios/var/spool/checkresults
*** Main program, CGIs and HTML files installed ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs sample config files in /usr/local/nagios/etc
make[1]: Leaving directory '/root/nagios/nagios-4.2.0'

以下命令将安装初始化脚本的Nagios。

[root@youcl nagios-4.0.1 ]# make install-init

为了使命令行nagios的工作,我们需要安装命令模式

[root@youcl nagios-4.0.1 ]# make install-commandmode

接下来,安装nagios示例文件,请运行以下命令。

[root@youcl nagios-4.0.1 ]# make install-config
示例输出:
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg
*** Config files installed ***
Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

第5步:自定义Nagios配置

打开与您所选择的编辑器的“contacts.cfg”文件,并设置与nagiosadmin接触定义为接收电子邮件警报的电子邮件地址

# vi /usr/local/nagios/etc/objects/contacts.cfg
示例输出
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
define contact{
contact_name                    nagiosadmin             ; Short name of user
use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
alias                           Nagios Admin            ; Full name of user
email                           [email protected]     ; *** CHANGE THIS TO YOUR EMAIL ADDRESS ****
}

第6步:为Nagios安装和配置Web Interface

我们完成了后端中的所有配置,现在我们将使用以下命令配置Nagios的Web Interface。 下面的命令将配置Web界面的Nagios和网络管理员的用户将创建“nagiosadmin”。

[root@youcl nagios-4.0.1 ]# make install-webconf

在此步骤中,我们将创建为“nagiosadmin”的密码。 执行此命令后,请两次提供密码 ,并保持它记住,因为当你在Nagios的Web界面登录此密码将被使用。

[root@youcl nagios-4.0.1]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

重新启动Apache使新的设置生效。

[root@youcl ]# service httpd start               [On RHEL/CentOS 6/5 and Fedora]
[root@youcl ]# systemctl start httpd.service     [On RHEL/CentOS 7 and Fedora 19 Onwards]

第7步:编译并安装Nagios插件

我们在/根下载Nagios的插件/ nagios的 ,去那里配置和安装,如下指示。

[root@youcl nagios]# cd /root/nagios
[root@youcl nagios]# cd nagios-plugins-2.1.2/
[root@youcl nagios]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@youcl nagios]# make
[root@youcl nagios]# make install

第8步:验证Nagios配置文件

现在,我们都与Nagios配置和时间来验证它,这样做,请插入下面的命令完成。 如果一切顺利,它将显示类似于以下输出。

[root@youcl nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
示例输出
Nagios Core 4.2.0
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-01-2016
License: GPL
Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors:   0
Things look okay - No serious problems were detected during the pre-flight check

第9步:将Nagios服务添加到系统启动

为了使各重启Nagios的工作,我们需要添加的Nagios的httpdchkconfig的systemctl命令。

在RHEL / CentOS 6/5和Fedora上
[root@youcl ]# chkconfig --add nagios
[root@youcl ]# chkconfig --level 35 nagios on
[root@youcl ]# chkconfig --add httpd
[root@youcl ]# chkconfig --level 35 httpd on
在RHEL / CentOS 7和Fedora 19-24上
[root@youcl ]# systemctl enable nagios
[root@youcl ]# systemctl enable httpd

Nagios的重新启动,使新的设置生效。

[root@youcl ]# service nagios start              [On RHEL/CentOS 6/5 and Fedora]
[root@youcl ]# systemctl start nagios.service    [On RHEL/CentOS 7 and Fedora 19-24]

第10步:登录Nagios Web界面

您的Nagios是做好准备工作,请在浏览器中打开它的“http://你的服务器,IP地址/ nagios的 ”或“HTTP:// FQDN / nagios的 ”,并提供用户名“nagiosadmin”密码

Nagios Web仪表板

Nagios Core 4.2.0在CentOS 7.2上运行

主机视图

Nagios主机视图

Nagios概述

Nagios监控概述

服务视图

Nagios Hos服务监控

过程视图

Nagios核心进程信息

恭喜! 您已经成功地安装和配置的Nagios插件 你刚刚开始你的监视旅程。

将Nagios 3.x升级到Nagios 4.2.0

如果您已经在运行的Nagios的旧版本 ,你可以随时升级 要做到这一点,你只需要下载它的最新tar存档,并配置它如下所示。

[root@youcl ]# service nagios stop
[root@youcl ]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz
[root@youcl ]# tar -zxvf nagios-4.2.0.tar.gz
[root@youcl ]# cd nagios-4.2.0
[root@youcl ]# ./configure
[root@youcl ]# make all
[root@youcl ]# make install
[root@youcl ]# service nagios start

以上就是现在,在我即将发表的文章中,我将告诉你如何到Linux,Windows打印机交换机设备添加到Nagios的监控服务器。 如果您在安装时有任何问题,请通过评论与我们联系。 直到那时敬请关注,并连接到youcl,不要忘了喜欢和我们分享向周围扩散。

阅读:

  1. 如何将Linux主机添加到Nagios监控服务器
  2. 如何将Windows主机添加到Nagios监控服务器
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏