CentOS7安装Nagios并配置出图详解


目录

  • 开始之前
    • 系统环境
    • 监控内容
    • 所需软件包
    • CentOS7重要变化
  • 配置开发环境
    • 同步时间
    • 关闭Selinux
    • 使用CRT上传软件包
    • 安装邮件服务
  • 监控主机安装
    • 常用到的命令
    • 安装nagios所需要的运行环境
    • 增加用户
    • 安装nagios
    • 配置权限
    • 安装插件
    • 安装nrpe
  • 远程主机安装
    • 常用到的命令
    • 配置运行环境
    • 安装nagios-plugin
    • 安装nrpe
    • 启动nrpe
    • 监控主机安装PNP
    • 配置开发环境
    • 安装pnp4nagios (版本号为0.6)
    • 配置pnp4nagios
    • 图表展示
  • 问题集合
    • 在首次配置了nagios监控端后,在浏览器输入地址后连接不上
    • 启动nrpe后却不能互相通信
    • 安装pnp4nagios后出现The requested URL /pnp4nagios/graph was not found on this server.
    • 出现“CHECK_NRPE: Error - Could not complete SSL handshake.”的错误
    • 执行 ./configure时报错:configure error cannot find ssl headers
    • 解压./configure 后,在nagios-4.0.8进行make all报错
    • 安装nrpe时执行.configure出错
    • 错误:perfdata directory "/usr/local/pnp4nagios/var/perfdata/" is empty

开始之前

声明:本文中的命令都经过了测试,但难免有所纰漏,如果你发现命令粘贴后运行有错,可能是由于符号的格式(尤其是破折号)导致的,此时你应该自己手打一遍命令。对于本文中发现的错误和建议,请发送邮件给我:
kylinlingh@foxmail.com,请在邮件主题里注明“关于nagios的问题(建议)”。

--------------------------------------分割线 --------------------------------------

在Ubuntu下配置Mrtg监控Nginx和服务器系统资源

使用 snmp+Mrtg 监控 Linux 系统

Mrtg服务器搭建(监控网络流量)

网络监控器Nagios全攻略

Nagios搭建与配置详解

Nginx环境下构建Nagios监控平台

在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2)

CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南

Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用

--------------------------------------分割线 --------------------------------------

系统环境

一共3台机器,全都按照CentOS7最小化模式安装系统

系统版本号

[root@localhost ~]# cat  /etc/RedHat-release

CentOS Linux release 7.0.1406 (Core)

监控主机

(一台)

IP地址:192.168.1.204

主机名称:nagios_server_204

远程主机

(两台)

IP地址:192.168.1.112

主机名称:nagios_slave_112

IP地址:192.168.1.113

主机名称:nagios_slave_113

分区情况

安装时使用默认分区(使用 df 命令来查看)

[root@localhost ~]# df -h

监控内容

要监控的服务

监控命令

cpu负载

(check_linux_state.pl -C)

当前用户登录数量

(check_users)

磁盘使用情况

(check_disk)

总进程数

(check_procs)

内存使用情况

(check_linux_stats.pl -M)

负载均衡

(check_load)

磁盘IO

(check_linux_stats.pl -I)

网络流量

(check_linux_stats.pl -N)

打开的文件数量

(check_linux_stats.pl -F)

socket连接数

(check_linux_stats.pl -S)

进程使用的内存和CPU

(check_linux_stats.pl -T)

指定的网站是否可连接

(check_http)

系统在线时长

(check_uptime)

所需软件包

监控主机

软件包

下载地址

nagios-4.0.8.tar.gz

请到我的github地址里下载:

https://github.com/Kylinlin/install_nagios_automatically/tree/master/nagios_tools_for_server

注明:我的github项目install_nagios_automatically是一个一键自动化安装nagios的项目(能运行,但还在完善中)

nagios-plugins-2.0.3.tar.gz

nrpe-2.15.tar.gz

pnp4nagios-0.6.25.tar.gz

Sys-Statistics-Linux-0.66.tar.gz

libxml2-2.7.1.tar.gz

远程主机

软件包

下载地址

nagios-plugins-2.0.3.tar.gz

请到我的github地址里下载:

https://github.com/Kylinlin/install_nagios_automatically/tree/master/nagios_tools_for_client

nrpe-2.15.tar.gz

Sys-Statistics-Linux-0.66.tar.gz

Centos7重要变化

Centos7相比较以前的Centos有一些涉及到常用命令的变化,如果不事先了解,会在使用命令的时候造成巨大的困扰

Centos7默认没有ifconfig和netstat两个命令了,ip addr命令代替了ifconfig,只要安装上net-tools包就可以继续使用ifconfig和netstat两个命令了

systemctl命令的出现(systemctl可以看作是service和chkconfig的组合),虽然仍然可以使用以前的命令,但是会重定向到新的命令中,下面以http服务为例

job

以前的系统

CentOS7

服务开机启动

chkconfig --level 3 httpd on

systemctl enable httpd.service

服务不开机启动

chkconfig --level 3 httpd off

systemctl disable httpd

服务状态

service httpd status

systemctl status httpd

所有服务的启动状态

chkconfig --list

systemctl

启动服务

service httpd start

systemctl start httpd.service

停止服务

service httpd stop

systemctl stop httpd.service

重启服务

service httpd restart

systemctl restart httpd.service

配置开发环境
同步时间
把监控系统里的所有机器都同步一次网络时间(非常重要)
[root@localhost ~]timedatectl  #该命令用来检查当前时间和时区
 
如果发现所有机器的时区不一致,此时就要使用命令
[root@localhost ~]timedatectl list-timezones  #该命令列出了所有的时区
[root@localhost ~]timedatectl set-timezone Asia/Shanghai #该命令把时区设置为上海
 
ntpdate time.nist.gov #该命令同步网络当前的时间
如果提示没有ntpdate命令,则安装ntp,并且配置系统自动更新时间
[root@localhost ~]# yum install ntp -y
[root@localhost ~]# /usr/sbin/ntpdate time.nist.gov
[root@localhost ~]# echo '#time sync'>>/var/spool/cron/root
[root@localhost ~]# echo '*/10**** /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1'>>/var/spool/cron/root
 
关闭Selinux
不关闭selinux可能会导致一些难以察觉的错误,为了保险起见,首先关闭selinux:
[root@localhost ~]vi /etc/selinux/config

重启机器
检查selinux是否关闭:
[root@localhost ~]getenforce #如果显示enforcing则没有关闭
 
使用SecureCRT上传软件包
我在这里使用的SSH连接工具是SecureCRT7.2,通过这个工具上传文件到Linux的步骤如下:
1.        首先在Linux中安装传送文件命令:
[root@localhost ~] yum install lrzsz -y
2.        然后在Linux中跳转到/usr/local/src目录下
[root@localhost ~] cd /usr/local/src
3.        运行CRT的传送文件命令

更多详情见请继续阅读下一页的精彩内容

  • 1
  • 2
  • 3
  • 4
  • 5
  • 下一页

相关内容