egjd 发表于 2013-9-13 09:35:57

nagios 图形化界面之三 (nagiosgraph)

如今,监控系统是琳琅满目,有Nagios、Cacti、Zabbix、Centreon、Munin等,也有系统集成如FAN等。个人在经过不同监控的安装测试后,还是比较倾向于Nagios的监控,简单命令;而且结合nagios和pnp4nagios等插件可以实现图表的功能。
    Nagios、Nagiosgraph 使用的是RRDtool工具来实现画图的。

1:安装依赖
            (1) .rrdtool安装rrdtool-1.4.5.tar.gz
            (2) .GD的perl模块
                     
         GD模块依赖于gd-devel等开发包。

2:解压安装nagiosgraph-1.4.4.tar.gz

         tarzxvf nagiosgraph-1.4.4.tar.gz
         cd   nagiosgraph-1.4.4
       以下都是在nagiosgraph-1.4.4目录下完成的,安装前检测安装环境

[root@localhostnagiosgraph-1.4.4]# perl install.pl--check-prereq
checking required PERL modules
Carp...1.20
CGI... ***FAIL***
Data::Dumper...2.130_02
File::Basename...2.82
File::Find...1.19
MIME::Base64...3.13
POSIX...1.24
RRDs...1.4004
Time::HiRes...1.972101
checking optional PERL modules
GD...***FAIL***
checking nagios installation
found nagios at /usr/local/nagios/bin/nagios
checking web server installation
found apache at /usr/sbin/httpd

*** one or more problems were detected!
以上是我的结果,错误是perl的cgi模块没有安装
使用yum 安装,如下
yum install perl-CGI
重新检验
perl install.pl --check-prereq
结果就正确了
安装
perl install.pl//安装命令
出现的结果如下,注意后面最好不要一路回车,自己多注意一下都是什么要求

checking required PERL modules
Carp...1.20
CGI...3.52
Data::Dumper...2.130_02
File::Basename...2.82
File::Find...1.19
MIME::Base64...3.13
POSIX...1.24
RRDs...1.4004
Time::HiRes...1.972101
checking optional PERL modules
GD...2.44
checking nagios installation
found nagios at /usr/local/nagios/bin/nagios
checking web server installation
found apache at /usr/sbin/httpd
Destination directory (prefix)? /usr/local/nagios/nagiosgraph//此处是nagiosgraph的目录,这个可以自己选择一下
Location of configuration files (etc-dir)?
Location of executables?
Location of CGI scripts?
Location of documentation (doc-dir)?
Location of examples?
Location of CSS and JavaScript files?
Location of utilities?
Location of state files (var-dir)?
Location of RRD files?
Location of log files (log-dir)?
Path of log file?
Path of CGI log file?
URL of CGI scripts?
URL of CSS file?
URL of JavaScript file?
Path of Nagios performance data file?
URL of Nagios CGI scripts?
username or userid of Nagios user? //此处注意你选择的用户
username or userid of web server user? nagios////此处注意你选择的用户

Modify the Nagios configuration?
Modify the Apache configuration?
configuration:
ng_layoutstandalone
ng_prefix/usr/local/nagios/nagiosgraph
ng_etc_dir/usr/local/nagios/nagiosgraph/etc
ng_bin_dir/usr/local/nagios/nagiosgraph/bin
ng_cgi_dir/usr/local/nagios/nagiosgraph/cgi
ng_doc_dir/usr/local/nagios/nagiosgraph/doc
ng_examples_dir/usr/local/nagios/nagiosgraph/examples
ng_www_dir/usr/local/nagios/nagiosgraph/share
ng_util_dir/usr/local/nagios/nagiosgraph/util
ng_var_dir/usr/local/nagios/nagiosgraph/var
ng_rrd_dir/usr/local/nagios/nagiosgraph/var/rrd
ng_log_dir/usr/local/nagios/nagiosgraph/var
ng_log_file/usr/local/nagios/nagiosgraph/var/nagiosgraph.log
ng_cgilog_file/usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log
ng_url/nagiosgraph
ng_cgi_url/nagiosgraph/cgi-bin
ng_css_url/nagiosgraph/nagiosgraph.css
ng_js_url/nagiosgraph/nagiosgraph.js
nagios_cgi_url/nagios/cgi-bin
nagios_perfdata_file /tmp/perfdata.log
nagios_usernagios
www_usernagios
modify_nagios_config n
nagios_config_file
nagios_commands_file
modify_apache_config n
apache_config_dir
apache_config_file
Continue with this configuration?
mkdir /usr/local/nagios/nagiosgraph
mkdir /usr/local/nagios/nagiosgraph/etc
copy etc/nagiosgraph.conf to/usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf
copy etc/access.conf to/usr/local/nagios/nagiosgraph/etc/access.conf
copy etc/nagiosgraph_fr.conf to/usr/local/nagios/nagiosgraph/etc/nagiosgraph_fr.conf
copy etc/servdb.conf to/usr/local/nagios/nagiosgraph/etc/servdb.conf
copy etc/nagiosgraph_es.conf to/usr/local/nagios/nagiosgraph/etc/nagiosgraph_es.conf
copy etc/hostdb.conf to/usr/local/nagios/nagiosgraph/etc/hostdb.conf
copy etc/groupdb.conf to/usr/local/nagios/nagiosgraph/etc/groupdb.conf
copy etc/nagiosgraph_de.conf to/usr/local/nagios/nagiosgraph/etc/nagiosgraph_de.conf
copy etc/datasetdb.conf to/usr/local/nagios/nagiosgraph/etc/datasetdb.conf
copy etc/labels.conf to/usr/local/nagios/nagiosgraph/etc/labels.conf
copy etc/rrdopts.conf to/usr/local/nagios/nagiosgraph/etc/rrdopts.conf
copy etc/map to/usr/local/nagios/nagiosgraph/etc/map
copy etc/ngshared.pm to/usr/local/nagios/nagiosgraph/etc
replace text in/usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf
move/usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf-bak to/usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf
replace text in/usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf
move/usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf-bak to /usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf
write stub to/usr/local/nagios/nagiosgraph/etc/nagiosgraph-nagios.cfg
write stub to/usr/local/nagios/nagiosgraph/etc/nagiosgraph-commands.cfg
write stub to/usr/local/nagios/nagiosgraph/etc/nagiosgraph-apache.conf
mkdir /usr/local/nagios/nagiosgraph/cgi
copy cgi/showhost.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/showhost.cgi
move/usr/local/nagios/nagiosgraph/cgi/showhost.cgi-bak to/usr/local/nagios/nagiosgraph/cgi/showhost.cgi
chmod 755 on/usr/local/nagios/nagiosgraph/cgi/showhost.cgi
copy cgi/showgroup.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/showgroup.cgi
move/usr/local/nagios/nagiosgraph/cgi/showgroup.cgi-bak to /usr/local/nagios/nagiosgraph/cgi/showgroup.cgi
chmod 755 on/usr/local/nagios/nagiosgraph/cgi/showgroup.cgi
copy cgi/testcolor.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/testcolor.cgi
move /usr/local/nagios/nagiosgraph/cgi/testcolor.cgi-bakto /usr/local/nagios/nagiosgraph/cgi/testcolor.cgi
chmod 755 on/usr/local/nagios/nagiosgraph/cgi/testcolor.cgi
copy cgi/showconfig.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/showconfig.cgi
move/usr/local/nagios/nagiosgraph/cgi/showconfig.cgi-bak to/usr/local/nagios/nagiosgraph/cgi/showconfig.cgi
chmod 755 on/usr/local/nagios/nagiosgraph/cgi/showconfig.cgi
copy cgi/show.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/show.cgi
move/usr/local/nagios/nagiosgraph/cgi/show.cgi-bak to/usr/local/nagios/nagiosgraph/cgi/show.cgi
chmod 755 on/usr/local/nagios/nagiosgraph/cgi/show.cgi
copy cgi/showgraph.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/showgraph.cgi
move/usr/local/nagios/nagiosgraph/cgi/showgraph.cgi-bak to/usr/local/nagios/nagiosgraph/cgi/showgraph.cgi
chmod 755 on/usr/local/nagios/nagiosgraph/cgi/showgraph.cgi
copy cgi/showservice.cgi to/usr/local/nagios/nagiosgraph/cgi
replace text in/usr/local/nagios/nagiosgraph/cgi/showservice.cgi
move/usr/local/nagios/nagiosgraph/cgi/showservice.cgi-bak to/usr/local/nagios/nagiosgraph/cgi/showservice.cgi
chmod 755 on /usr/local/nagios/nagiosgraph/cgi/showservice.cgi
mkdir /usr/local/nagios/nagiosgraph/bin
copy lib/insert.pl to/usr/local/nagios/nagiosgraph/bin
replace text in/usr/local/nagios/nagiosgraph/bin/insert.pl
move/usr/local/nagios/nagiosgraph/bin/insert.pl-bak to/usr/local/nagios/nagiosgraph/bin/insert.pl
chmod 755 on/usr/local/nagios/nagiosgraph/bin/insert.pl
mkdir /usr/local/nagios/nagiosgraph/share
copy share/nagiosgraph.css to/usr/local/nagios/nagiosgraph/share/nagiosgraph.css
copy share/nagiosgraph.js to/usr/local/nagios/nagiosgraph/share
mkdir /usr/local/nagios/nagiosgraph/doc
copy AUTHORS to/usr/local/nagios/nagiosgraph/doc
copy CHANGELOG to/usr/local/nagios/nagiosgraph/doc
copy INSTALL to/usr/local/nagios/nagiosgraph/doc
copy README to /usr/local/nagios/nagiosgraph/doc
copy TODO to/usr/local/nagios/nagiosgraph/doc
mkdir/usr/local/nagios/nagiosgraph/examples
copy examples/map_1_3 to/usr/local/nagios/nagiosgraph/examples
copy examples/nagiosgraph.1.css to/usr/local/nagios/nagiosgraph/examples
copy examples/nagiosgraph.2.css to/usr/local/nagios/nagiosgraph/examples
copy examples/nagiosgraph-logrotate to/usr/local/nagios/nagiosgraph/examples
copy examples/nagiosgraph-commands.cfg to/usr/local/nagios/nagiosgraph/examples
copy examples/map_1_4_4 to/usr/local/nagios/nagiosgraph/examples
copy examples/map_examples to/usr/local/nagios/nagiosgraph/examples
copy examples/map_mwall to/usr/local/nagios/nagiosgraph/examples
copy examples/map_1_4_3 to/usr/local/nagios/nagiosgraph/examples
copy examples/map_minimal to/usr/local/nagios/nagiosgraph/examples
copy examples/nagiosgraph-nagios.cfg to/usr/local/nagios/nagiosgraph/examples
copy examples/nagiosgraph-apache.conf to/usr/local/nagios/nagiosgraph/examples
copy share/graph.gif to /usr/local/nagios/nagiosgraph/examples
copy share/nagiosgraph.ssi to/usr/local/nagios/nagiosgraph/examples
mkdir /usr/local/nagios/nagiosgraph/util
copy utils/testentry.pl to/usr/local/nagios/nagiosgraph/util
copy utils/upgrade.pl to/usr/local/nagios/nagiosgraph/util
chmod 755 on/usr/local/nagios/nagiosgraph/util/testentry.pl
chmod 755 on/usr/local/nagios/nagiosgraph/util/upgrade.pl
mkdir /usr/local/nagios/nagiosgraph/var/rrd
chmod 755 on/usr/local/nagios/nagiosgraph/var/rrd
chown nagios,- on /usr/local/nagios/nagiosgraph/var/rrd
touching/usr/local/nagios/nagiosgraph/var/nagiosgraph.log
chmod 644 on/usr/local/nagios/nagiosgraph/var/nagiosgraph.log
chown nagios,- on/usr/local/nagios/nagiosgraph/var/nagiosgraph.log
touching /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log
chmod 644 on/usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log
chown nagios,- on/usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log


To complete theinstallation, do the following:

* In the nagios configuration file (e.g.nagios.cfg),
add these lines:

# process nagiosperformance 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
* In the nagios commands file (e.g.command.cfg),
add these lines:

# command to processnagios performance data for nagiosgraph
define command {
command_nameprocess-service-perfdata-for-nagiosgraph
command_line/usr/local/nagios/nagiosgraph/bin/insert.pl
}
* In the apache configuration file (e.g.httpd.conf),
add this line:

include/usr/local/nagios/nagiosgraph/etc/nagiosgraph-apache.conf
* Restart nagios to start data collection:

/etc/init.d/nagiosrestart
* Restart apache to enable display of graphs:

/etc/init.d/apacherestart

* To enable graph links and mouseovers, seeREADME sections:
Displaying Per-Service and Per-HostGraph Icons and Links
Displaying Graphs in Nagios Mouseovers
注意最后出现的这几行,这是对于以后nagiosgraph的配置信息
(1):在nagios的配置文件(nagios.cfg)中加入以下几行


# process nagiosperformance 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


(2):在nagios命令文件(command.cfg)中加入以下几行


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


(3):在apache配置文件httpd.conf中加入
include/usr/local/nagios/nagiosgraph/etc/nagiosgraph-apache.conf
注意include第一个字母大写

(4):重启nagio和httpd后登录nagiosgraph
http://localhost/nagiosgraph/cgi-bin/show.cgi
出现以下结果



可以先选择host然后点击update graphs 然后,在左上角再点击data for host……中的主机名称就可以了

(5):把nagiosgraph路径加到nagios系统内

在/usr/local/nagios/share/side.php加入如下内容Nagiosgraph
[*]Graphs
[*]Graphs by Host
[*]Graphs by Service
[*]Graphs by Group



其实就是nagiosweb 界面的reports栏加入了trends如下




心海恋歌 发表于 2013-9-15 02:58:39

俺从不写措字,但俺写通假字!

angela 发表于 2013-9-16 17:30:34

做爱做的事,交配交的人。

janneyabc 发表于 2013-9-19 10:48:22

微机原理闹危机,随机过程随机过,实变函数学十遍,汇编语言不会编!

鸬鹚洲 发表于 2013-9-24 18:18:20

恋爱就是无数个饭局,结婚就是一个饭局。

96818 发表于 2013-9-30 13:58:35

人生自古谁无死,啊个拉屎不用纸!

iyth888 发表于 2013-10-5 22:24:05

走自己的路,让别人打车去吧。
页: [1]
查看完整版本: nagios 图形化界面之三 (nagiosgraph)