- 下载nagiosgraph文件到Nagios监控服务器上
# wget http://sourceforge.net/projects/nagiosgraph/files/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz
- 解压文件,并进入解压目录
# tar zxvf nagiosgraph-1.5.2.tar.gz
# cd nagiosgraph-1.5.2
- 通过其自带的perl安装脚本先检测nagiosgraph所依赖的应用程序是否已经安装
# ./install.pl --check-prereq
checking required PERL modules
Carp...1.11
CGI... ***FAIL***
Data::Dumper...2.124
Digest::MD5...2.39
File::Basename...2.77
File::Find...1.14
MIME::Base64...3.08
POSIX...1.17
RRDs... ***FAIL***
Time::HiRes... ***FAIL***
checking optional PERL modules
GD... ***FAIL***
Nagios::Config... ***FAIL***
checking nagios installation
found nagios exectuable at /usr/local/nagios/bin/nagios
found nagios init script at /etc/init.d/nagios
checking web server installation
found apache executable at /usr/sbin/httpd
found apache init script at /etc/init.d/httpd
*** one or more problems were detected!
安装缺少的perl模块
# yum -y install perl-GD php-gd rrdtool-perl rrdtool-php rrdtool perl-CGI perl-Time-HiRes perl-CPAN perl-Module-Build
通过cpan安装Nagios::Config
# cpan
# cpan> install Nagios:Config
重新运行依赖检测确认没有 FAIL 4. 继续安装nagiosgraph
# ./install.pl --install
在安装过程中会有很多安装提示,大多情况下你只需要选择默认值。 个人建议最后两项modify_nagios_config和modify_apache_config选择y,这会帮助你自动完成如下事项: - 自动在apache服务器配置目录/etc/httpd/conf.d/中加入如下配置文件nagiosgraph.conf
# enable nagiosgraph CGI scripts
ScriptAlias /nagiosgraph/cgi-bin "/usr/local/nagiosgraph/cgi"
<Directory "/usr/local/nagiosgraph/cgi">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# AuthName "Nagios Access"
# AuthType Basic
# AuthUserFile NAGIOS_ETC_DIR/htpasswd.users
# Require valid-user
</Directory>
# enable nagiosgraph CSS and JavaScript
Alias /nagiosgraph "/usr/local/nagiosgraph/share"
<Directory "/usr/local/nagiosgraph/share">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
- 自动修改nagios的配置文件nagios.conf,加入如下关于perfdata的设置,这些设置是关于如何处理性能数据的:
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
- 自动个性nagios的命令配置文件/usr/local/nagios/etc/objects/commands.cfg,加入如下命令:
# begin nagiosgraph configuration
# 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
}
# end nagiosgraph configuration
该命令正是上面nagios配置文件指定处理性能数据所用的命令。 5. 在你的nagios配置文件中添加一个service模板,并在你需要使用图形的service上应用
define service {
name graphed-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
register 0
}
use generic-service
# ==>
use generic-service,graphed-service
- 也可以为Host指定action_url,为Host应用图形
action_url $HOSTNAME$
- 最后将在nagios下创建common-header.ssh来为图表启用javascript的mouseover事件处理
cp -a /usr/local/nagiosgraph/examples/nagiosgraph.ssi /usr/local/nagios/share/ssicommon-header.ssi
- 最后,验证nagios配置正确性,并重新nagios与apache服务
# /usr/sbin/apachectl configtest
# /usr/sbin/apachectl restart
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# /etc/init.d/nagios restart
访问nagios的web页面,验收成果
http://<Your Nagioshost>/nagiosgraph/cgi-bin/showconfig.cgi
http://<Your Nagioshost>/nagiosgraph/cgi-bin/showhost.cgi?host=<Your Host Name>
参考文档 Centos6.x/RHEL6.x–Apache/Nagios4.x–Install nagiosgraph plugin Steps to configure Nagiosgraph with Nagios Core nagiosgraph-graphs-in-nagios