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. 创建Uboot 环境变量 bin 文件

    As we know, the bootloader stores its configuration into an area of the flash called the environment ...

  2. Nginx的应用之安装配置

    一.Nginx简述 Nginx是一个开源且高性能.可靠的Http Web服务.代理服务. 开源: 直接获取源代码 高性能: 支持海量并发 可靠: 服务稳定 我们为什么选择 Nginx服务 Nginx非 ...

  3. 笔记72 高级SSM整合

    遇到的问题: 1.进行spring mvc测试的时候报错 测试代码: package com.li.test; import com.github.pagehelper.PageInfo; impor ...

  4. 三步完成Source Insight 4.0 破解安装(转)

    转自:https://blog.csdn.net/biubiuibiu/article/details/78044232 三步完成Source Insight 4.0 破解安装   下载地址有更新,之 ...

  5. 【串线篇】概述SpringMvc和spring整合

    SpringMVC和Spring整合的目的:分工明确: SpringMVC的配置文件就来配置和网站转发逻辑以及网站功能有关的(视图解析器,文件上传解析器,支持ajax,xxx):springmvc.x ...

  6. 【leetcode】679. 24 Game

    题目如下: 解题思路:24点是非常经典的游戏了,因为本题数据量小,可以使用穷举法,把所有的可能结果都算出来.假设nums = [a,b,c,d],记f(n)表示用nums中n个数字进行运算可以得到的结 ...

  7. 【多线程】LinkedTransferQueue

    LinkedTransferQueue是JDK1.7才添加的阻塞队列,基于链表实现的FIFO无界阻塞队列,是ConcurrentLinkedQueue(循环CAS+volatile 实现的wait-f ...

  8. Python(二)

    函数Python的函数支持递归.默认参数值.可变参数,但不支持函数重载.为了增强代码的可读性,可以在函数后书写“文档字符串”(Documentation Strings,或者简称docstrings) ...

  9. mysql5.6配置-my

    # mkdir -p /home/mysql/3306/{data,binlog,logs} [client] port = socket=/tmp/my3306.sock [mysql] no-au ...

  10. mysql授权、删除用户和角色权限

    备份权限 GRANT USAGE ON *.* TO 'backup'@'172.16.0.157' IDENTIFIED BY PASSWORD '*38B4F16EADB1601E713D9F03 ...