Nagios Nagiosgraph配置

默北 NagiosNagios Nagiosgraph配置已关闭评论18,4044字数 2626阅读8分45秒阅读模式

nagios监控是一种常用的监控软件,同时,有个很大的缺点,就是没法展现旧的历史数据,服务状态趋势,言简意赅的说,就是缺少绘图。

nagios相关资料参见本博客上的内容:https://www.ttlsa.com/?s=nagios文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

原理:文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

使用service_perfdata_file_processing_command指令,将nagios监控到的每个服务数据,传递给 /usr/local/nagiosgraph/bin/insert.pl脚本处理,生产rrd文件。文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

下面来说说Nagiosgraph的配置:文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

1. 获取组件文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

# wget http://downloads.sourceforge.net/project/nagiosgraph/nagiosgraph/1.4.4/nagiosgraph-1.4.4.tar.gz
# tar -xzf nagiosgraph-1.4.4.tar.gz
# cd nagiosgraph-1.4.4

2. 检测环境要求文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

# ./install.pl --check-prereq
checking required PERL modules
  Carp...1.04
  CGI...3.15
  Data::Dumper...2.121_08
  File::Basename...2.74
  File::Find...1.10
  MIME::Base64...3.07
  POSIX...1.09
  RRDs...1.2027
  Time::HiRes...1.9717
checking optional PERL modules
  GD...2.35
checking nagios installation
  found nagios at /usr/local/nagios/bin/nagios
checking web server installation
  found apache at /usr/sbin/httpd

缺少哪些perl模块,就安装那些模块,同时还要注意版本的要求。文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

3.  安装文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

./install.pl --install

一路按回车键。文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

4. 编辑nagios.cfg文件文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

在nagios.conf文件下,添加以下内容文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

# process nagios performance data using nagiosgraph
process_performance_data=1
service_perfdata_file=/tmp/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph

5.  编辑commands.cfg文件文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

添加以下内容文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

#########################################
#
#  nagiosgraph
#
# command to process nagios performance data for nagiosgraph
define command {
        command_name    process-service-perfdata-for-nagiosgraph
        command_line    /usr/local/nagiosgraph/bin/insert.pl
}

6. 修改httpd.conf文件文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

添加以下内容文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

Include /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf

7. 重新启动服务文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

# /etc/init.d/httpd restart
# /etc/init.d/nagios restart

8.  查看nagiosgraph配置信息文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

在浏览器输入:http://10.0.100.125/nagiosgraph/cgi-bin/showconfig.cgi网址查看。文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

nagios文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

9. 定义动作URL文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/

修改templates.cfg文件,添加以下内容:

define service {
        name nagiosgraph
        action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
        register 0
}

10. 添加你需要的绘图

默认情况下,启用Performance Data的服务都会绘图。

nagios

实例如下:

define service {
    use                 MongoDB,nagiosgraph
    hostgroup_name          MongoDB_Servers
    service_description     Mongo Memory Usage
    check_command           check_mongodb!12345!''!''!memory!130!260
      servicegroups           Mongodbservices
}

添加完,会有个下面的图标

nagios

11. 效果如下

nagios

12.  每个服务项都会有个rrd文件

在/usr/local/nagiosgraph/var/rrd目录下的各自主机子目录下

nagios

对于无法生成Performance Data数据,将无法绘图,出现nagiosgraph no data available信息,查看nagiosgraph.log出现下面信息:

322207-Tue Apr 8 17:18:36 2014 insert.pl warn output/perfdata not recognized:
322279:hostname:X.X.X.X
322299-servicedesc:Mongo Free Connections
322334-output:OK - 6 percent (52 of 819 connections) used
322385-perfdata:

perfdata为空,这就需要我们自己去对output信息进行解析了。通过/usr/local/nagiosgraph/etc/map这个文件,来定义正则表达式来处理,该文件是个perl脚本,来将output信息映射到perfdata。

map如何自定义正则表达式下节再说,请关注。

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 21/04/2014 09:47:34
  • 转载请务必保留本文链接:https://www.ttlsa.com/nagios/nagios-nagiosgraph-configure/