温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Centos7上怎么用yum安装nagios

发布时间:2021-08-13 19:29:54 来源:亿速云 阅读:143 作者:chen 栏目:移动开发

这篇文章主要讲解了“Centos7上怎么用yum安装nagios”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“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

                yum -y install nagios  nagios-plugins   nagios-snmp-plugins
               chkconfig --add   nagios   
               chkconfig nagios on

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

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是通过模块的方式连接

yum -y install httpd php*

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

# 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)这里创建登录用户

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

Centos7上怎么用yum安装nagios

感谢各位的阅读,以上就是“Centos7上怎么用yum安装nagios”的内容了,经过本文的学习后,相信大家对Centos7上怎么用yum安装nagios这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI