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. 看不懂源码?先来恶补一波Object原型吧

    目录 Object Object属性 1.Object.prototype 2.Object.name Object方法 1.Object.assign() 2.Object.create() 3.O ...

  2. 如何判断一个List集合中是否有空值

    list.Any(v => string.IsNullOrWhiteSpace(v))

  3. Pandas之loc\iloc\ix

    ---------------------------------------------------------------------------------------------------- ...

  4. day12 python函数名的应用 闭包 迭代器

    day12 python   一.函数名的应用(是第一类对象)     函数名的命名规范和变量是一样的     函数名其实就是变量名 def func():     print('i am funct ...

  5. Linux中的系统服务_01

    Linux中的系统服务_01 1.linux中所有的内容都是以文件的形式存在,所以其服务也是以文件的形式存在/etc/init.d目中, 2.存在改/etc/init.d/目录里的文件,都可以通过命令 ...

  6. Concurrent - 多线程

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11426916.html Java中有几种方法可以实现一个线程? 继承Thread类(不支持多继承) 实 ...

  7. iview select下拉框的蜜汁小坑

    前言 最近使用iview的select下拉选择器,遇到一个很神奇的问题:选中下拉框里面的一个值,但是再去点下拉框的时候就只剩刚才选中的数据了.感觉应该是插件把刚才选中的数据当做的搜索条件,所以需要做的 ...

  8. 【集群】Redis集群设计原理

    Redis集群设计包括2部分:哈希Slot和节点主从 节点主从: 主从设计不算什么新鲜玩意,在数据库中我们也经常用主从来做读写分离,直接上图: 图上能看得到的信息: 1, 只有1个Master,可以有 ...

  9. Python基础教程(007)--Python的优缺点

    前言 了解Python的优点和缺点 知识点 优点 简单易学 免费,开源 面相对象 丰富的库 可扩展性 缺点 运行速度慢 国内市场较小 中文资料匮乏 总结: 明白Python的优点和缺点

  10. AcWing 241. 楼兰图腾 (树状数组)打卡

    题目:https://www.acwing.com/problem/content/description/243/ 题意:给你n个点,问你 V 和  ^的图腾有多少个 思路:比如V 其实就是找当前点 ...