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. Springboot1.5.9整合WebSocket

    一.WebSocket介绍 1.WebSocket是什么? WebSocket是协议,是HTML5开始提供的基于TCP(传输层)的一种新的网络协议, 它实现了浏览器与服务器全双工(full-duple ...

  2. The Preliminary Contest for ICPC Asia Nanjing 2019 D. Robots

    题意:给出一个DAG,一只机器人从1点出发,等概率地选择一条出边走或者停留在原点,机器人的第k次行动消耗能量是k(无论是走还是停留都算一次行动).问1到n的期望. 解法:因为行动消耗的能量跟行动次数有 ...

  3. elementui中table组件表头和内容不对齐的问题

    表头与内容没对齐 在样式里加入 .el-table th.gutter{ display: table-cell!important; } 终于舒服了

  4. 西电源ubuntu12

    deb http://linux.xidian.edu.cn/mirrors/ubuntu/ precise main restricted universe multiverse #deb-src ...

  5. 【leetcode】991. Broken Calculator

    题目如下: On a broken calculator that has a number showing on its display, we can perform two operations ...

  6. Linux的软件包管理

    此博客的环境任意. 主题Linux的软件包管理 一软件管理工具 1编译安装      2rpm包管理          3yum管理 二软件运行和编译 1ABI 应用程序的二进制接口 ABI:Appl ...

  7. [CSP-S模拟测试]:赤(red)(WQS二分+DP)

    题目传送门(内部题38) 输入格式 每个输入文件包含多组测试数据.选手应当处理到文件结束($EOF$) 每一组数据包括$3$行. 第$1$行包含三个正整数$n,a,b$,表示有$n$只猫,$gyz$有 ...

  8. appium 链接真机

    1. 安装驱动 说明:如果驱动装不上,可以使用第三方的工具去安装.(一般来说还是用第三方) 这里推荐锤子科技的HandShaker, 地址:http://www.smartisan.com/apps/ ...

  9. java并发编程笔记(三)——线程安全性

    java并发编程笔记(三)--线程安全性 线程安全性: ​ 当多个线程访问某个类时,不管运行时环境采用何种调度方式或者这些进程将如何交替执行,并且在主调代码中不需要任何额外的同步或协同,这个类都能表现 ...

  10. 81、Tensorflow实现LeNet-5模型,多层卷积层,识别mnist数据集

    ''' Created on 2017年4月22日 @author: weizhen ''' import os import tensorflow as tf import numpy as np ...