Nagios是一套开源的监控系统,可监控你的系统和网络.
Nagios最新版本是Nagios Core 4.3.4,Nagios plugins 2.2.1.
目前支持RHEL 7.x/6.x/5.x, CentOS 7.x/6.x/5.x 等系统.本文以CentOS7为平台.

安装Nagios 4.3.4 and Nagios Plugin 2.2
假如你根据本手册正确安装后,你应该能找到以下信息:

nagios,plugin安装目录 /usr/local/nagios
默认监控本机服务(Disk Usage, CPU Load, Current Users, Total Processes)
可以通过浏览器访问 http://localhost/nagios
step1 安装依赖软件
安装需要apache,php,gcc等.
1
[root@host]# yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp
1
step2 创建nagios用户和用户组
创建nagios用户和组,并设置密码
1
[root@host] useradd nagios
[root@host] groupadd nagcmd
1
2
将nagios和apache加入 nagios组
1
[root@host]usermod -G nagcmd nagios
[root@host] usermod -G nagcmd apache
1
2
step3 下载nagios4.3,nagios plugin 2.2
创建一个nagios下载目录

[root@host]# mkdir /root/nagios
[root@host]# cd /root/nagios
1
2
适用wget 下载最新版本

[root@host]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
[root@host]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
1
2
step4 解压
[root@host nagios~]# tar -xvf nagios-4.3.4.tar.gz
[root@hostnagios~]# tar -xvf nagios-plugins-2.2.1.tar.gz
1
2
解压后有2个新的文件夹

[root@host nagios ~]# ls -l
drwxrwxr-x 18 root root 4096 Aug 24 17:43 nagios-4.3.4
drwxr-xr-x 15 root root 4096 Apr 19 12:04 nagios-plugins-2.2.1
1
2
3
配置Nagios
进入nagios目录,进行配置

[root@host nagios~]# cd nagios-4.3.4/
[root@host nagios-4.3.4 ]# ./configure --with-command-group=nagcmd
1
2
sample配置文件:

Creating sample config files in sample-config/ ...

*** Configuration summary for nagios 4.3.4 2017-08-24 ***:

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: /run/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: /usr/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.

编译,安装包

[root@host nagios-4.3.4 ]# make all
[root@host nagios-4.3.4 ]# make install

*** Exfoliation theme installed ***
NOTE: Use 'make install-classicui' to revert to classic Nagios theme

make[1]: Leaving directory `/root/nagios/nagios-4.3.4'
make install-basic
make[1]: Entering directory `/root/nagios/nagios-4.3.4'
/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.3.4'

安装初始化init脚本

[root@host nagios-4.3.4 ]# make install-init
1
安装命令行运行脚本

[root@host nagios-4.3.4 ]# make install-commandmode
1
安装样本脚本

[root@host nagios-4.3.4 ]# 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.

step 5 按自己需求配置
配置联系人

# 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 admin@tecmint.com ; *** CHANGE THIS TO YOUR EMAIL ADDRESS ****
}

step 6 安装配置web接口
配置web接口,首先会创建管理员账号 nagiosadmin,并要求输入管理密码

[root@host nagios-4.3.4 ]# make install-webconf

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

重启apache,使配置生效

[root@host ]# service httpd start 
[root@host ]# systemctl start httpd.service 
1
2
step7 编译安装nagios plugin
按如下命令运行

[root@host nagios]# cd /root/nagios
[root@host nagios]# cd nagios-plugins-2.2.1/
[root@host nagios]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@host nagios]# make
[root@hostt nagios]# make install

step8 验证nagios配置文件
已经完成所有安装,按一下命令验证配置文件

[root@host nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.3.4
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2017-08-24
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

step 9 将nagios加到系统服务中
[root@host ]# systemctl enable nagios
[root@host ]# systemctl enable httpd
[root@host]# systemctl start nagios.service 
1
2
3
Step 10: 适用浏览器访问nagios
在浏览器中输入 “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” ,并输入账号和密码.

host view

service view

补充一下,升级nagios3到nagios4
假如你是旧版本,你可以随时升级到最新版本,你可以下载最新版本,按以下命令升级.

[root@host ]# service nagios stop
[root@host ]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
[root@host ]# tar -zxvf nagios-4.3.4.tar.gz
[root@host ]# cd nagios-4.3.4
[root@host ]# ./configure
[root@host ]# make all
[root@host ]# make install
[root@host ]# service nagios start
--------------------- 
作者:CSDN1887 
来源:CSDN 
原文:https://blog.csdn.net/csdn1887/article/details/83022323

centos7 实测 nagios 安装的更多相关文章

  1. Centos7最小化安装之工作站设置

    Centos7最小化安装之工作站设置 实测在Vultr的VPS上正常可用 在Vultr上怎么看桌面 两种解决方法: 使用VNC远程连接 直接使用Vultr的view console功能 我使用的是第二 ...

  2. centos7.0 下安装jdk1.8

    centos7.0这里安装jdk1.8采用yum安装方式,非常简单. 1.查看yum库中jdk的版本 [root@localhost ~]# yum search java|grep jdk 2.选择 ...

  3. CentOS-7.0.中安装与配置Tomcat-7的方法

    安装说明 安装环境:CentOS-7.0.1406安装方式:源码安装 软件:apache-tomcat-7.0.29.tar.gz 下载地址:http://tomcat.apache.org/down ...

  4. Nagios安装部署和介绍(一)

    一.软件版本下载 Nagios版本下载地址: http://prdownloads.sourceforge.net/sourceforge/nagios/ http://sourceforge.net ...

  5. 在 virtualbox 的 centos7 虚拟机中安装增强工具

    在 virtualbox 的 centos7 虚拟机中安装增强工具 centos7 刚刚安装完成时,直接安装 virtualbox 增强工具会出错,需要先把 gcc / kernel-devel / ...

  6. centos7 最小化安装 无 ifconfig,netstat 的安装

    centos7 最小化安装 无 ifconfig,netstat 的安装 centos7 最小化安装之后,默认是没有 ifconfig,netstat命令的: 我们可以直接使用 yum -y inst ...

  7. nagios安装配置

     http://www.codeweblog.com/nagios%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/ 上线的服务器有时会被人攻击,导致服务不可用,今天安装配置了 ...

  8. Nagios 安装及微信短信提醒

    引言 Nagios 作为业界非常强大的一款开源监视系统. 监控网络服务(SMTP.POP3.HTTP.NNTP.PING 等): 监控主机资源(处理器负荷.磁盘利用率等): 简单地插件设计使得用户可以 ...

  9. 简易nagios安装

    这段时间一直在进行nagios安装的实验,进行了很多的实验,现在也就是将这些进行一些基础的记录. 本篇主要讲述的是进行nagios的简易安装,在安装完成之后,能够在web页面上看到本地的监控图像, n ...

随机推荐

  1. Vue小白篇 - Vue 的指令系统 (1) v-text、v-html

    v-text:相当于innerText v-html:相当于innerHTML <div id="box"> {{ msg }} <div v-text=&quo ...

  2. mac OS 安装 Homebrew及常用命令

    Homebrew  是由国外大神 Max Howell 开发的一款包管理工具,类似Debian的apt,他可以安装任何你想安装的东西. 安装方法 命令行输入 /usr/bin/ruby -e &quo ...

  3. tf.add_to_collection,tf.get_collection简介

    tf.add_to_collection:把变量放入一个集合,把很多变量变成一个列表 tf.get_collection:从一个结合中取出全部变量,是一个列表 tf.add_n:把一个列表的东西都依次 ...

  4. go语言从例子开始之Example18.struct结构体

    Go 的结构体 是各个字段字段的类型的集合.这在组织数据时非常有用 Example: package main import "fmt" type product struct{ ...

  5. map hashmap的使用

    package map; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Map的实现 ...

  6. mysql 存储引擎介绍2

    了解MYSQL的都知道,在MYSQL中建立任何一张数据表,在其数据目录对应的数据库目录下都有对应表的.frm文件,.frm文件是用来保存每个数据表的元数据(meta)信息,包括表结构的定义等,.frm ...

  7. PID算法知识点博文收藏记录

    https://blog.csdn.net/Uncle_GUO/article/details/51367764 https://blog.csdn.net/HandsomeHong/article/ ...

  8. Mysql中存储过程和函数的写法

    MySQL中,创建存储过程的基本形式如下: CREATE PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic ...] routine ...

  9. CPU的历史

    https://zhuanlan.zhihu.com/p/64537796 很多人都对电脑硬件有一点的了解,本人也算略懂一二,所以今天来为大家说说电脑的主要硬件之一––CPU(中央处理器). 那么我们 ...

  10. 基于jquery和bootstrap的下拉框左右选择功能

    实现如图选择的功能,可以用基于bootstrap的样式,结合jquery事件: <div class="row"> <div class="col-xs ...