centos7安装nagios

简介:

一、服务端配置:

  1. 安装软件:
    yum  -y  install  nagios  nagios-plugins  nagios-plugins-all  nagios-plugins-nrpe  nrpe
  2. 修改nagios主配置文件:vim /etc/nagios/nagios.cfg
    cfg_dir=/etc/nagios/conf.d  #确保其中有这行代码

    centos7安装nagios

  3. 修改cgi配置文件,添加用户:vim /etc/nagios/cgi.cfg
    authorized_for_system_information=nagiosadmin,lee
    authorized_for_configuration_information=nagiosadmin,lee
    authorized_for_system_commands=nagiosadmin,lee
    authorized_for_all_services=nagiosadmin,lee
    authorized_for_all_hosts=nagiosadmin,lee
    authorized_for_all_service_commands=nagiosadmin,lee
    authorized_for_all_host_commands=nagiosadmin,lee

    centos7安装nagios

  4. 修改命令配置文件command.cfg:vim /etc/nagios/objects/commands.cfg
    #添加
    define command{
    command_name  check_nrpe
    command_line  $USER1/check_nrpe  -H  $HOSTADDRESS  -c  $ARG1
    }

    centos7安装nagios

  5. 修改联系人配置文件:vim /etc/nagios/objects/contacts.cfg
    define contact{
        contact_name                    nagiosadmin     
    use             generic-contact     
        alias                           Nagios Admin        
        email                           complet@163.com
        }
    define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin
        }
  6. 添加远程主机的监控指令(可以用本地配置文件/etc/nagios/objects/localhost.cfg作为模板):
    cp -arf /etc/nagios/objects/localhost.cfg /etc/nagios/conf.d/lee.cfg
    vim /etc/nagios/conf.d/lee.cfg
    define host{
        use                     linux-server            
        host_name               lee
        alias                   lee
        address                 192.168.8.82
        }
    #去掉这组定义
    #define hostgroup{
    #        hostgroup_name  linux-servers 
    #        alias           Linux Servers 
    #        members         lee     
    #        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             PING
    check_command           check_ping!100.0,20%!500.0,60%
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             Root Partition
    check_command           check_local_disk!20%!10%!/
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             Current Users
    check_command           check_local_users!20!50
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             Total Processes
    check_command           check_local_procs!250!400!RSZDT
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             Current Load
    check_command           check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             Swap Usage
    check_command           check_local_swap!20!10
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             SSH
    check_command           check_ssh
    notifications_enabled       0
        }
    define service{
        use                             local-service         
        host_name                       lee
        service_description             HTTP
    check_command           check_http
    notifications_enabled       0
        }
  7. 检查配置文件语法:
    nagios -v /etc/nagios/nagios.cfg
  8. 修改nagios相关目录权限:
    chown  nagios.nagios  /etc/logrotate.d/nagios
    chmod  g+w  /etc/logrotate.d/nagios
    chown  -R  nagios.nagios  /etc/nagios
  9. 设置apache账户密码:
    htpasswd  -c  /etc/nagios/passwd  lee
  10. 启动服务:
    systemctl  start  httpd
    systemctl  start  nagios

    二、客户端配置:

  11. 安装软件:
    yum  -y  install  nagios-plugins  nagios-plugins-nrpe  nrpe
  12. 修改 nrpe 主配置文件:vim /etc/nagios/nrpe.cfg
    #添加服务端ip
    allowed_hosts=127.0.0.1,192.168.8.81

    centos7安装nagios

  13. 启动nrpe服务:
    systemctl  start  nrpe

    三、测试:
    centos7安装nagios

本文转自 bilinyee博客,原文链接:    http://blog.51cto.com/12173069/2070827     如需转载请自行联系原作者


相关文章
|
1月前
|
Linux 网络安全 数据安全/隐私保护
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
155 0
|
2月前
|
关系型数据库 MySQL Linux
centos7.0环境下安装MySql_8.0.12
centos7.0环境下安装MySql_8.0.12
|
1月前
|
存储 JavaScript Linux
Linux环境下安装nmp(Centos环境)保姆级教学 一步到位
Linux环境下安装nmp(Centos环境)保姆级教学 一步到位
|
2月前
|
关系型数据库 MySQL Linux
CentOS7环境下安装MySQL5.6
CentOS7环境下安装MySQL5.6
196 0
|
1天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
10 1
|
7天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
39 2
|
13天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
24 0
|
13天前
|
分布式计算 Hadoop Java
centos 部署Hadoop-3.0-高性能集群(一)安装
centos 部署Hadoop-3.0-高性能集群(一)安装
14 0
|
13天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
67 0
|
20天前
|
IDE Linux 开发工具
CentOS7.4+REDHAWK2.3.1安装教程——折腾篇
CentOS7.4+REDHAWK2.3.1安装教程——折腾篇
19 0