Centos7上yum安装nagios

简介:

本次安装未加入客户端,就是配置本机成为监控对象

一、nagios简介

    Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

   Nagios 可以监控的功能有:

1
2
3
4
5
6
7
8
9
10
11
1、监控网络服务(SMTP、POP3、HTTP、NNTP、PING等); 
2、监控主机资源(处理器负荷、磁盘利用率等);
3、简单地插件设计使得用户可以方便地扩展自己服务的检测方法;
4、并行服务检查机制;
5、具备定义网络分层结构的能力,用 "parent" 主机定义来表达网络主机间的关系,
    这种关系可被用来发现和明晰主机宕机或不可达状态;
6、当服务或主机问题产生与解决时将告警发送给联系人(通过EMail、短信、用户定义方式);
7、具备定义事件句柄功能,它可以在主机或服务的事件发生时获取更多问题定位;
8、自动的日志回滚;
9、可以支持并实现对主机的冗余监控;
10、可选的WEB界面用于查看当前的网络状态、通知和故障历史、日志文件等。

二、安装Nagios基础支持套件和添加用户


1).创建nagios用户和用户组(先进行该步骤,不然编译nagios时会报错)

1
2
# useradd -s /sbin/nologin nagios

# mkdir /usr/local/nagios# chown -R nagios.nagios /usr/local/nagios

2).安装httpd和php

1
2
# yum install httpd*    ##安装Web服务器Apache相关服务,nagios提供了web监控界面,通过web                             界面可以看到被监控主机运行状态
# yum install php*      ##安装PHP相关服务

三、安装Nagios

1
2
3
                 yum -y  install  nagios  nagios-plugins   nagios-snmp-plugins
                chkconfig --add   nagios   
                chkconfig nagios on

1)添加管理账号nagcmd,并将apache,nagios都加入nagcmd用户组;将apache加入nagios用户组,并且更改nagios目录属主属组。

1
2
3
4
5
useradd  -s  /sbin/nologin    nagcmd
usermod   -G    nagcmd nagios
usermod   -G    nagcmd apache
usermod   -G    nagios    apache
chown      -R    nagios.nagcmd   /usr/share/nagios/html/ *

2)这里我们的php是直接安装的php;这里php与httpd是通过模块的方式连接

1
yum -y  install  httpd php*

  1)这里还是需要对/etc/httpd/conf.d/nagios.conf进行一下编辑,根据系统版本进行更改,我这里是CentOS7-2,列出配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file.  Customize the paths, etc. as
# needed to fit your system.
 
ScriptAlias  /nagios/cgi-bin/  "/usr/lib64/nagios/cgi-bin/"
 
<Directory  "/usr/lib64/nagios/cgi-bin/" >
#  SSLRequireSSL
    Options ExecCGI
    AllowOverride None
 
    AuthName  "Nagios Access"
    AuthType Basic
    AuthUserFile  /etc/nagios/passwd
     require valid-user
    <IfModule mod_authz_core.c>
       # Apache 2.4
       <RequireAll>
       #   Require all granted
          # Require local
          Require valid-user
       < /RequireAll >
    < /IfModule >
    <IfModule !mod_authz_core.c>
       # Apache 2.2
      # Order allow,deny
      # Allow from all
       #  Order deny,allow
       #  Deny from all
       #  Allow from 127.0.0.1
       Require valid-user
    < /IfModule >
< /Directory >
 
Alias  /nagios  "/usr/share/nagios/html"
#proxyrequests off 
#proxypassmatch ^/(.*\.php)$  fcgi://127.0.0.1:9000/usr/share/nagios/html/$1
<Directory  "/usr/share/nagios/html" >
#  SSLRequireSSL
    Options None
    AllowOverride None
 
    AuthName  "Nagios Access"
    AuthType Basic
    AuthUserFile  /etc/nagios/passwd
    require valid-user
    <IfModule mod_authz_core.c>
       # Apache 2.4
       <RequireAll>
       #   Require all granted
          # Require local
          Require valid-user
       < /RequireAll >
    < /IfModule >
    <IfModule !mod_authz_core.c>
       # Apache 2.2
      # Order allow,deny
      # Allow from all
       #  Order deny,allow
       #  Deny from all
       #  Allow from 127.0.0.1
       Require valid-user
    < /IfModule >
< /Directory >


3).关闭SELinux和防火墙:

a、临时关闭(不用重启机器):

1
2
# setenforce 0                       ##设置SELinux 成为permissive模式  (关闭SELinux)
# setenforce 1                       ##设置SELinux 成为enforcing模式     (开启SELinux)

b、修改配置文件需要重启机器:

1
# vi /etc/selinux/config


4).验证程序是否配置正确

1
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

5)这里创建登录用户

1
htpasswd -c  -m   /etc/nagios/passwd      sjf       (Enter输入密码)

6).启用服务并进入nagios

1
2
3
# systemctl start httpd.service
# systemctl start snmpd.service
# systemctl start nagios.service

wKiom1gvEiqx-URTAALGW8HQfOs546.png-wh_50


四、这里的安装就完成了

  由于时间有限,这里就不演示图形界面pnp4nagios插件的演示了,这个有机会可以给大家展示nagios的使用。



 本文转自 sjfbjs 51CTO博客,原文链接:http://blog.51cto.com/11886896/1874599


相关文章
|
14天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
32 0
|
14天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
47 0
|
15小时前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
4 0
|
2天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
12 1
|
5天前
|
应用服务中间件 nginx
yum 安装报错 No package nginx available Error:Nothing to do
yum 安装报错 No package nginx available Error:Nothing to do
16 1
|
8天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
45 2
|
14天前
|
缓存 Linux
linux centos7 挂载本地iso yum源
linux centos7 挂载本地iso yum源
64 0
|
14天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
26 0
|
14天前
|
分布式计算 Hadoop Java
centos 部署Hadoop-3.0-高性能集群(一)安装
centos 部署Hadoop-3.0-高性能集群(一)安装
15 0
|
14天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
68 0