linux环境安装nagiosgraph将nagios的性能数据绘制成动态图表?
需求描述:
在安裝完成nagios之后,比如有監控磁盤負載信息的,連接數的,進程數的,可以通過安裝nagiosgraph軟件,
將nagios的性能數據繪制成圖表,可以看到一段時間內數據的變化
環境說明:
操作系統版本:RedHat_6.6_x64
安裝過程:
1.下載,上傳nagiosgraph軟件
下載地址: https://sourceforge.net/projects/nagiosgraph/files/
軟件版本:nagiosgraph-1.5.2.tar.gz
[root@testvm02 ~]# cd /opt/softwares/;ls -l nagiosgrap* -rw-r--r--. 1 root root 329978 Jul 31 14:12 nagiosgraph-1.5.2.tar.gz2.解壓軟件,執行預安裝檢查
[root@testvm02 softwares]# tar zxf nagiosgraph-1.5.2.tar.gz [root@testvm02 softwares]# cd nagiosgraph-1.5.2 [root@testvm02 nagiosgraph-1.5.2]# ./install.pl --check-prereq checking required PERL modulesCarp...1.11CGI... ***FAIL*** #針對這個報錯,安裝perl-CGIData::Dumper...2.124Digest::MD5...2.39File::Basename...2.77File::Find...1.14MIME::Base64...3.08POSIX...1.17RRDs... ***FAIL*** #針對這個錯誤安裝rrdtool,并且rrdtool,安裝rrdtool-perlTime::HiRes... ***FAIL*** #針對這個報錯,安裝perl-Time-HiRes checking optional PERL modulesGD... ***FAIL*** #針對這個錯誤安裝perl-GDNagios::Config... ***FAIL*** #針對這個錯誤安裝perl-Nagios-Object checking nagios installationfound nagios exectuable at /usr/local/nagios/bin/nagiosfound nagios init script at /etc/init.d/nagios checking web server installationfound apache executable at /usr/sbin/httpdfound apache init script at /etc/init.d/httpd*** one or more problems were detected!3.安裝需要的軟件包
[root@testvm02 nagiosgraph-1.5.2]# yum install perl-CGI[root@testvm02 nagiosgraph-1.5.2]# yum install perl-Time-HiRes
[root@testvm02 softwares]# yum install rrdtool
[root@testvm02 softwares]# rpm -Uvh rrdtool-1.3.8-10.el6.x86_64.rpm #這個軟件需要手動下載
warning: rrdtool-1.3.8-10.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...??????????????? ########################################### [100%]
?? 1:rrdtool??????????????? ########################################### [100%]
[root@testvm02 softwares]# rpm -Uvh rrdtool-perl-1.3.8-10.el6.x86_64.rpm #這個軟件需要手動下載
warning: rrdtool-perl-1.3.8-10.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...??????????????? ########################################### [100%]
?? 1:rrdtool-perl?????????? ########################################### [100%]
[root@testvm02 softwares]# rpm -ivh perl-Nagios-Object-0.21.12-1.el6.rf.noarch.rpm #這個軟件需要手動下載
warning: perl-Nagios-Object-0.21.12-1.el6.rf.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...??????????????? ########################################### [100%]
?? 1:perl-Nagios-Object???? ########################################### [100%]
perl模塊下載地址:http://rpmfind.net/linux/RPM/index.html? (可以下載上面提到的軟件)
當出現以下的配置檢查結果,表示可以進行安裝
[root@testvm02 nagiosgraph-1.5.2]# ./install.pl --check-prereq checking required PERL modulesCarp...1.11CGI...3.51Data::Dumper...2.124Digest::MD5...2.39File::Basename...2.77File::Find...1.14MIME::Base64...3.08POSIX...1.17RRDs...1.3008Time::HiRes...1.9721 checking optional PERL modulesGD...2.44Nagios::Config...36 checking nagios installationfound nagios exectuable at /usr/local/nagios/bin/nagiosfound nagios init script at /etc/init.d/nagios checking web server installationfound apache executable at /usr/sbin/httpdfound apache init script at /etc/init.d/httpd4.安裝nagiosgraph軟件
[root@testvm02 nagiosgraph-1.5.2]# ./install.pl備注:一路回車就可以了.
[root@testvm02 nagiosgraph-1.5.2]# ./install.pl checking required PERL modulesCarp...1.11CGI...3.51Data::Dumper...2.124Digest::MD5...2.39File::Basename...2.77File::Find...1.14MIME::Base64...3.08POSIX...1.17RRDs...1.3008Time::HiRes...1.9721 checking optional PERL modulesGD...2.44Nagios::Config...36 checking nagios installationfound nagios exectuable at /usr/local/nagios/bin/nagiosfound nagios init script at /etc/init.d/nagios checking web server installationfound apache executable at /usr/sbin/httpdfound apache init script at /etc/init.d/httpd Destination directory (prefix)? [/usr/local/nagiosgraph] Location of configuration files (etc-dir)? [/usr/local/nagiosgraph/etc] Location of executables? [/usr/local/nagiosgraph/bin] Location of CGI scripts? [/usr/local/nagiosgraph/cgi] Location of documentation (doc-dir)? [/usr/local/nagiosgraph/doc] Location of examples? [/usr/local/nagiosgraph/examples] Location of CSS and JavaScript files? [/usr/local/nagiosgraph/share] Location of utilities? [/usr/local/nagiosgraph/util] Location of state files (var-dir)? [/usr/local/nagiosgraph/var] Location of RRD files? [/usr/local/nagiosgraph/var/rrd] Location of log files (log-dir)? [/usr/local/nagiosgraph/var/log] Path of log file? [/usr/local/nagiosgraph/var/log/nagiosgraph.log] Path of CGI log file? [/usr/local/nagiosgraph/var/log/nagiosgraph-cgi.log] Base URL? [/nagiosgraph] URL of CGI scripts? [/nagiosgraph/cgi-bin] URL of CSS file? [/nagiosgraph/nagiosgraph.css] URL of JavaScript file? [/nagiosgraph/nagiosgraph.js] URL of Nagios CGI scripts? [/nagios/cgi-bin] Path of Nagios performance data file? [/tmp/perfdata.log] username or userid of Nagios user? [nagios] username or userid of web server user? [apache] Modify the Nagios configuration? [n] Modify the Apache configuration? [n] configuration:ng_prefix /usr/local/nagiosgraphng_etc_dir /usr/local/nagiosgraph/etcng_bin_dir /usr/local/nagiosgraph/binng_cgi_dir /usr/local/nagiosgraph/cging_doc_dir /usr/local/nagiosgraph/docng_examples_dir /usr/local/nagiosgraph/examplesng_www_dir /usr/local/nagiosgraph/shareng_util_dir /usr/local/nagiosgraph/utilng_var_dir /usr/local/nagiosgraph/varng_rrd_dir /usr/local/nagiosgraph/var/rrdng_log_dir /usr/local/nagiosgraph/var/logng_log_file /usr/local/nagiosgraph/var/log/nagiosgraph.logng_cgilog_file /usr/local/nagiosgraph/var/log/nagiosgraph-cgi.logng_url /nagiosgraphng_cgi_url /nagiosgraph/cgi-binng_css_url /nagiosgraph/nagiosgraph.cssng_js_url /nagiosgraph/nagiosgraph.jsnagios_cgi_url /nagios/cgi-binnagios_perfdata_file /tmp/perfdata.lognagios_user nagioswww_user apachemodify_nagios_config nnagios_config_file nagios_commands_file modify_apache_config napache_config_dir apache_config_file Continue with this configuration? [y] mkdir /usr/local/nagiosgraph mkdir /usr/local/nagiosgraph/etc copy etc/access.conf to /usr/local/nagiosgraph/etc/access.conf copy etc/hostdb.conf to /usr/local/nagiosgraph/etc/hostdb.conf copy etc/servdb.conf to /usr/local/nagiosgraph/etc/servdb.conf copy etc/nagiosgraph.conf to /usr/local/nagiosgraph/etc/nagiosgraph.conf copy etc/nagiosgraph_es.conf to /usr/local/nagiosgraph/etc/nagiosgraph_es.conf copy etc/nagiosgraph_de.conf to /usr/local/nagiosgraph/etc/nagiosgraph_de.conf copy etc/datasetdb.conf to /usr/local/nagiosgraph/etc/datasetdb.conf copy etc/rrdopts.conf to /usr/local/nagiosgraph/etc/rrdopts.conf copy etc/nagiosgraph_fr.conf to /usr/local/nagiosgraph/etc/nagiosgraph_fr.conf copy etc/labels.conf to /usr/local/nagiosgraph/etc/labels.conf copy etc/groupdb.conf to /usr/local/nagiosgraph/etc/groupdb.conf copy etc/map to /usr/local/nagiosgraph/etc/map copy etc/ngshared.pm to /usr/local/nagiosgraph/etc replace text in /usr/local/nagiosgraph/etc/nagiosgraph.conf move /usr/local/nagiosgraph/etc/nagiosgraph.conf-bak to /usr/local/nagiosgraph/etc/nagiosgraph.conf replace text in /usr/local/nagiosgraph/etc/nagiosgraph.conf move /usr/local/nagiosgraph/etc/nagiosgraph.conf-bak to /usr/local/nagiosgraph/etc/nagiosgraph.conf write stub to /usr/local/nagiosgraph/etc/nagiosgraph-nagios.cfg write stub to /usr/local/nagiosgraph/etc/nagiosgraph-commands.cfg write stub to /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf mkdir /usr/local/nagiosgraph/cgi copy cgi/testcolor.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/testcolor.cgi move /usr/local/nagiosgraph/cgi/testcolor.cgi-bak to /usr/local/nagiosgraph/cgi/testcolor.cgi chmod 755 on /usr/local/nagiosgraph/cgi/testcolor.cgi copy cgi/showservice.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/showservice.cgi move /usr/local/nagiosgraph/cgi/showservice.cgi-bak to /usr/local/nagiosgraph/cgi/showservice.cgi chmod 755 on /usr/local/nagiosgraph/cgi/showservice.cgi copy cgi/show.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/show.cgi move /usr/local/nagiosgraph/cgi/show.cgi-bak to /usr/local/nagiosgraph/cgi/show.cgi chmod 755 on /usr/local/nagiosgraph/cgi/show.cgi copy cgi/showgroup.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/showgroup.cgi move /usr/local/nagiosgraph/cgi/showgroup.cgi-bak to /usr/local/nagiosgraph/cgi/showgroup.cgi chmod 755 on /usr/local/nagiosgraph/cgi/showgroup.cgi copy cgi/showconfig.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/showconfig.cgi move /usr/local/nagiosgraph/cgi/showconfig.cgi-bak to /usr/local/nagiosgraph/cgi/showconfig.cgi chmod 755 on /usr/local/nagiosgraph/cgi/showconfig.cgi copy cgi/export.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/export.cgi move /usr/local/nagiosgraph/cgi/export.cgi-bak to /usr/local/nagiosgraph/cgi/export.cgi chmod 755 on /usr/local/nagiosgraph/cgi/export.cgi copy cgi/showgraph.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/showgraph.cgi move /usr/local/nagiosgraph/cgi/showgraph.cgi-bak to /usr/local/nagiosgraph/cgi/showgraph.cgi chmod 755 on /usr/local/nagiosgraph/cgi/showgraph.cgi copy cgi/showhost.cgi to /usr/local/nagiosgraph/cgi replace text in /usr/local/nagiosgraph/cgi/showhost.cgi move /usr/local/nagiosgraph/cgi/showhost.cgi-bak to /usr/local/nagiosgraph/cgi/showhost.cgi chmod 755 on /usr/local/nagiosgraph/cgi/showhost.cgi mkdir /usr/local/nagiosgraph/bin copy lib/insert.pl to /usr/local/nagiosgraph/bin replace text in /usr/local/nagiosgraph/bin/insert.pl move /usr/local/nagiosgraph/bin/insert.pl-bak to /usr/local/nagiosgraph/bin/insert.pl chmod 755 on /usr/local/nagiosgraph/bin/insert.pl mkdir /usr/local/nagiosgraph/share copy share/nagiosgraph.css to /usr/local/nagiosgraph/share/nagiosgraph.css copy share/nagiosgraph.js to /usr/local/nagiosgraph/share mkdir /usr/local/nagiosgraph/doc copy AUTHORS to /usr/local/nagiosgraph/doc copy CHANGELOG to /usr/local/nagiosgraph/doc copy INSTALL to /usr/local/nagiosgraph/doc copy README to /usr/local/nagiosgraph/doc copy TODO to /usr/local/nagiosgraph/doc mkdir /usr/local/nagiosgraph/examples copy examples/nagiosgraph-logrotate to /usr/local/nagiosgraph/examples copy examples/nagiosgraph-apache.conf to /usr/local/nagiosgraph/examples copy examples/map_mwall to /usr/local/nagiosgraph/examples copy examples/map_1_4_4 to /usr/local/nagiosgraph/examples copy examples/graphed-host.cfg to /usr/local/nagiosgraph/examples copy examples/map_1_4_3 to /usr/local/nagiosgraph/examples copy examples/nagiosgraph-nagios.cfg to /usr/local/nagiosgraph/examples copy examples/nagiosgraph.1.css to /usr/local/nagiosgraph/examples copy examples/nagiosgraph-commands.cfg to /usr/local/nagiosgraph/examples copy examples/map_minimal to /usr/local/nagiosgraph/examples copy examples/nagiosgraph.2.css to /usr/local/nagiosgraph/examples copy examples/insert.sh to /usr/local/nagiosgraph/examples copy examples/map_1_3 to /usr/local/nagiosgraph/examples copy examples/graphed-service.cfg to /usr/local/nagiosgraph/examples copy examples/map_examples to /usr/local/nagiosgraph/examples copy examples/map_1_4_5 to /usr/local/nagiosgraph/examples copy share/graph.gif to /usr/local/nagiosgraph/examples copy share/nagiosgraph.ssi to /usr/local/nagiosgraph/examples mkdir /usr/local/nagiosgraph/util copy utils/testentry.pl to /usr/local/nagiosgraph/util copy utils/flat2hier.pl to /usr/local/nagiosgraph/util chmod 755 on /usr/local/nagiosgraph/util/testentry.pl chmod 755 on /usr/local/nagiosgraph/util/flat2hier.pl mkdir /usr/local/nagiosgraph/var/rrd chmod 755 on /usr/local/nagiosgraph/var/rrd chown nagios,- on /usr/local/nagiosgraph/var/rrd mkdir /usr/local/nagiosgraph/var/log chmod 755 on /usr/local/nagiosgraph/var/log touching /usr/local/nagiosgraph/var/log/nagiosgraph.log chmod 644 on /usr/local/nagiosgraph/var/log/nagiosgraph.log chown nagios,- on /usr/local/nagiosgraph/var/log/nagiosgraph.log touching /usr/local/nagiosgraph/var/log/nagiosgraph-cgi.log chmod 644 on /usr/local/nagiosgraph/var/log/nagiosgraph-cgi.log chown apache,- on /usr/local/nagiosgraph/var/log/nagiosgraph-cgi.logTo complete the installation, do the following:* In the nagios configuration file (nagios.cfg),add these lines:# 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* In the nagios commands file (command.cfg),add these lines:# command to process nagios performance data for nagiosgraph define command {command_name process-service-perfdata-for-nagiosgraphcommand_line /usr/local/nagiosgraph/bin/insert.pl }* In the apache configuration file (httpd.conf),add this line:include /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf* Check the nagios configuration:/usr/local/nagios/bin/nagios -v /path/to/nagios.cfg* Restart nagios to start data collection:/etc/init.d/nagios restart* Restart apache to enable display of graphs:/etc/init.d/httpd restart* To enable graph links and mouseovers, see README sections:Displaying Per-Service and Per-Host Graph Icons and LinksDisplaying Graphs in Nagios Mouseovers5.配置nagiosgraph
5.1 在nagios.cfg中增加以下配置(nagios.cfg文件默認位置:/usr/local/nagios/etc)
# 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-nagiosgraph5.2 在nagios的命令文件commands.cfg(默認位置:/usr/local/nagios/etc/objects)中加入以下內容
# command to process nagios performance data for nagiosgraph define command {command_name process-service-perfdata-for-nagiosgraphcommand_line /usr/local/nagiosgraph/bin/insert.pl }5.3 在apache的配置文件httpd.conf(文件位置:/etc/httpd/conf)加入以下內容
/usr/local/nagios/bin/nagios -v /path/to/nagios.cfg5.4 檢查nagios配置,如果沒有問題,就表示增加的配置是正確,如果配置錯誤,會有提示
[root@testvm02 conf]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgNagios Core 4.4.1 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2018-06-25 License: GPLWebsite: https://www.nagios.org Reading configuration data...Read main config file okay...Read object config files okay...Running pre-flight check on configuration data...Checking objects...Checked 8 services.Checked 1 hosts.Checked 1 host groups.Checked 0 service groups.Checked 1 contacts.Checked 1 contact groups.Checked 25 commands.Checked 5 time periods.Checked 0 host escalations.Checked 0 service escalations. Checking for circular paths...Checked 1 hostsChecked 0 service dependenciesChecked 0 host dependenciesChecked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings...Total Warnings: 0 Total Errors: 0Things look okay - No serious problems were detected during the pre-flight check5.5 重啟nagios,啟動收集數據,重啟httpd來顯示圖表
[root@testvm02 conf]# service nagios restart Running configuration check... Stopping nagios: done. Starting nagios: Running configuration check... done. [root@testvm02 conf]# service httpd restart Stopping httpd: [ OK ] Starting httpd: httpd: apr_sockaddr_info_get() failed for testvm02 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName[ OK ]6.通過以下命令,查看nagiosgraph已經運行
http://192.168.53.25/nagiosgraph/cgi-bin/showconfig.cgi7.針對某些數據,可以看圖
http://192.168.53.25/nagiosgraph/cgi-bin/show.cgi選擇對應的服務就能夠查看圖表:
備注:這個是在特定的頁面進行特定服務的查看.
8.在nagios的template.cfg文件中增加nagiosgraph的實例信息
define service {name graphed-serviceaction_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$&period=week&rrdopts=-w+450+-jregister 0}?9.針對具體的服務加上圖表連接,將前面定義的graphed-service加入到具體的service定義中(以本地服務為例,localhost.cfg文件)
vi localhost.cfgdefine service {
??? use???????????????????? local-service,graphed-service?????????? ; Name of service template to use #在每一個的service的后面都加上graphed-service
??? host_name?????????????? localhost
??? service_description???? PING
??? check_command?????????? check_ping!100.0,20%!500.0,60%
}
?10.重啟nagios加載新的配置文件
service nagios restart11.查看nagios頁面的顯示,在Service字段后面有了一個圖片的連接,點擊可以連接到具體的服務產生的圖
12.可以更換這個圖片
mv /usr/local/nagios/share/images/action.gif /usr/local/nagios/share/images/action.gif-orig [root@testvm02 objects]# cd /opt/softwares/nagiosgraph-1.5.2[root@testvm02 nagiosgraph-1.5.2]# cp share/graph.gif /usr/local/nagios/share/images/action.gif
13.重新刷新頁面,圖標已經更換
到此,nagiosgraph已經安裝完成,其他的可以在根據使用需求,查看官方文檔.
?
文檔創建時間:2018年7月31日14:55:34
轉載于:https://www.cnblogs.com/chuanzhang053/p/9395884.html
總結
以上是生活随笔為你收集整理的linux环境安装nagiosgraph将nagios的性能数据绘制成动态图表?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用户表如何存放用户密码
- 下一篇: WEB 前端跨域解决方案