如今,监控系统是琳琅满目,有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
tar zxvf nagiosgraph-1.4.4.tar.gz
cd nagiosgraph-1.4.4
以下都是在nagiosgraph-1.4.4目录下完成的,安装前检测安装环境
[[email protected]]# 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/nagiosgraph] /usr/local/nagios/nagiosgraph//此处是nagiosgraph的目录,这个可以自己选择一下
Location of configuration files (etc-dir)?[/usr/local/nagios/nagiosgraph/etc]
Location of executables?[/usr/local/nagios/nagiosgraph/bin]
Location of CGI scripts?[/usr/local/nagios/nagiosgraph/cgi]
Location of documentation (doc-dir)?[/usr/local/nagios/nagiosgraph/doc]
Location of examples?[/usr/local/nagios/nagiosgraph/examples]
Location of CSS and JavaScript files?[/usr/local/nagios/nagiosgraph/share]
Location of utilities?[/usr/local/nagios/nagiosgraph/util]
Location of state files (var-dir)?[/usr/local/nagios/nagiosgraph/var]
Location of RRD files?[/usr/local/nagios/nagiosgraph/var/rrd]
Location of log files (log-dir)?[/usr/local/nagios/nagiosgraph/var]
Path of log file?[/usr/local/nagios/nagiosgraph/var/nagiosgraph.log]
Path of CGI log file?[/usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log]
URL of CGI scripts? [/nagiosgraph/cgi-bin]
URL of CSS file?[/nagiosgraph/nagiosgraph.css]
URL of JavaScript file?[/nagiosgraph/nagiosgraph.js]
Path of Nagios performance data file?[/tmp/perfdata.log]
URL of Nagios CGI scripts?[/nagios/cgi-bin]
username or userid of Nagios user? [nagios]//此处注意你选择的用户
username or userid of web server user? [apache]nagios////此处注意你选择的用户
Modify the Nagios configuration? [n]
Modify the Apache configuration? [n]
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? [y]
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_path='/nagiosgraph/cgi-bin';?>
Nagiosgraph
echo$nagiosgraph_path;?>/show.cgi" target="echo$link_target;?>">Graphs
echo$nagiosgraph_path;?>/showhost.cgi" target="echo$link_target;?>">Graphs by Host
>
echo$nagiosgraph_path;?>/showservice.cgi" target="echo$link_target;?>">Graphs by Serv
ice
echo$nagiosgraph_path;?>/showgroup.cgi" target="echo$link_target;?>">Graphs by Group<
/a>
其实就是nagiosweb 界面的reports栏加入了trends如下