Chinaunix首页 | 论坛 | 博客
  • 博客访问: 313176
  • 博文数量: 103
  • 博客积分: 1590
  • 博客等级: 上尉
  • 技术积分: 1075
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-02 10:17
文章分类

全部博文(103)

文章存档

2013年(32)

2012年(7)

2010年(64)

我的朋友

分类: LINUX

2010-02-19 22:05:27

来源:http://chinasuse.spaces.live.com/blog/cns!F13FF62822C209C1!393.entry

nagiosgraph的简单使用

nagios本身并不把系统的性能数据用图形的方式表现出来,它不像cacti,mrtg那么直观,但是实际中是对图形表示有需求的,所以两个办法,一个是你搭建个cacti来,或者在nagios里面集成一个图形界面

帮助nagios做图的第三方插件有很多,我这里使用的是nagiosgraph这个插件,下面我们看看怎么使用这个插件来画图

首先去 下载我们的软件包 nagiosgraph-0.9.0.tgz

#tar zxvf nagiosgraph-0.9.0.tgz

# cd nagiosgraph-0.9.0

#mkdir /usr/local/nagios/nagiosgraph 在nagios的安装目录先建立一个文件夹nagiosgraph放置nagiosgraph的相关文件

#cp nagiosgraph/* /usr/local/nagios/nagiosgraph/ 将nagiosgraph的配置文件以及脚本copy进来

#vim /usr/local/nagios/nagiosgraph/nagiosgraph.conf 配置文件修改相应的字段

# File:    $Id: nagiosgraph.conf,v 1.13 2007/02/15 13:09:48 vanidoso Stab $
# Author:  (c) Soren Dossing, 2005
# License: OSI Artistic License
#         

# Debug levels
# 0 = None
# 1 = Critical
# 2 = Error
# 3 = Warn
# 4 = Info
# 5 = Debug
debug = 52  这个字段是定义日志的debug级别的,建议设置高点刚开始,以后再设置回去

# Location of debug log file
logfile = /var/log/nagiosgraph.log   这个字段是nagiosgraph的脚本运行日志,手动建立并设置权限,直接设置成777省的麻烦

# Directory to store rrd database files
rrddir =  /usr/local/nagios/nagiosgraph/rrd 这个字段是nagiosgraph插件生成的性能图示文件,也要注意权限问题

# File containing regular expressions to identify service and perf data
mapfile = /usr/local/nagios/nagiosgraph/map 这个其实类似个模板文件用来从perfdata日志中匹配关键的性能数据,采集数据使用

# Color scheme for graphs. Choose a number between 1 and 8.
colorscheme = 1

# Heartbeat. In seconds, twice the size of servicecheck intervals
heartbeat = 600

# Location of performance data log file. Comment out it not used.
perflog = /usr/local/nagios/nagiosgraph/perfdata.log 这个是性能日志文件,很重要,注意权限,脚本从这里读取性能数据

# Stylesheet - added to head of show.cgi. Comment out if not used
stylesheet = /usr/local/nagios/nagiosgraph/nagiosgraph.css 这个就不说了 ,注意路径跟权限

# RRAs resolution (optional, don't touch if you don't know what you are doing)
#resolution = 17280 17520 32850 1095

# Organization of rrd files
# _ = single character separator for all files in same dir
# subdir = files in subdirectory structure with "___" separator
dbseparator = subdir

# Plot form (LINE1..LINE3, AREA, TICK)
plotas = LINE2

# Graphs to show in every page (day, week, month, quarter, year)
# time = day week month year

然后我们需要nagios知道nagiosgraph的存在,所以需要配置nagios.cfg来调用nagios来作图。

修改nagios.cfg添加如下字段

service_perfdata_file=/usr/local/nagios/nagiosgraph/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

并且将

process_performance_data=1 这个字段设置为1 设置为0表示不向perdata.log写性能采集数据

 

采集的数据图

阅读(3796) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~