[Linux] Nagios ¸ð´ÏÅ͸µ °á°ú°ª ±×·¡ÇÁ »ý¼º (nagiosgraph)
http://ehostidc.co.kr/center/EH050402.php?no=141532&page=7&choose=tit¡¦ (308)https://blog.naver.com/goethe1/221642889788 (290)
1. 목적 : Nagios 모니터링은 모니터링과 모니터링 알람만 설정
해당 결과값을 그래프로 기록 되도록 추가 모듈 설치
2. 프로그램 설치
a. 프로그램 다운로드
[root@nagios opt]# yum -y install perl-GD php-gd rrdtool-perl rrdtool-php rrdtool perl-CGI perl-Time-HiRes
[root@nagios opt]# wget https://sourceforge.net/projects/nagiosgraph/files...
[root@nagios opt]# tar -zxvpf nagiosgraph-1.5.2.tar.gz
[root@nagios opt]# cd ./nagiosgraph-1.5.2
b. 프로그램 의존성 확인
[root@nagios nagiosgraph-1.5.2]# ./install.pl --check-prereq
checking required PERL modules
Carp...1.26
CGI...3.63
Data::Dumper...2.145
Digest::MD5... ***FAIL***
File::Basename...2.84
File::Find...1.20
MIME::Base64...3.13
POSIX...1.30
RRDs...1.4008
Time::HiRes...1.9725
checking optional PERL modules
GD...2.49
Nagios::Config... ***FAIL***
checking nagios installation
found nagios exectuable at /usr/sbin/nagios
checking web server installation
found apache executable at /usr/sbin/httpd*** one or more problems were detected!
c. 의존성 패키지 설치
[root@nagios nagiosgraph-1.5.2]# yum install perl-Digest-MD5 perl-Nagios-Plugin perl-CPAN
[root@nagios nagiosgraph-1.5.2]# perl -MCPAN -e shell
cpan[4]> install Module::Build
Running install for module "Module::Build"
Running make for L/LE/LEONT/Module-Build-0.4224.tar.gz
Fetching with HTTP::Tiny:
http://mirror.intergrid.com.au/cpan/authors/id/L/L...
Fetching with HTTP::Tiny:
http://mirror.intergrid.com.au/cpan/authors/id/L/L...
Checksum for /root/.cpan/sources/authors/id/L/LE/LEONT/Module-Build-0.4224.tar.gz ok
---- Unsatisfied dependencies detected during ----cpan[4]> install Nagios::Config
d. 프로그램 설치
[root@nagios01 nagiosgraph-1.5.2]# ./install.pl --layout overlay --prefix /usr/local/nagiosgraph
configuration:
ng_prefix /usr/local/nagiosgraph
ng_etc_dir /etc/nagios/nagiosgraph/
ng_bin_dir /usr/local/nagiosgraph/libexec
ng_cgi_dir /usr/local/nagiosgraph/sbin
ng_doc_dir /usr/local/nagiosgraph/docs/nagiosgraph
ng_examples_dir /usr/local/nagiosgraph/docs/nagiosgraph/examples
ng_www_dir /usr/local/nagiosgraph/share
ng_util_dir /usr/local/nagiosgraph/docs/nagiosgraph/util
ng_var_dir /var/nagios
ng_rrd_dir /var/nagios/rrd
ng_log_dir /var/nagios
ng_log_file /var/nagios/nagiosgraph.log
ng_cgilog_file /var/nagios/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_user nagios
www_user apache
modify_nagios_config n
nagios_config_file
nagios_commands_file
modify_apache_config y
apache_config_dir /etc/httpd/conf.d
apache_config_file
Continue with this configuration? [y] y
3. 환경설정 파일 수정
a. /etc/nagios/nagios.cfg 파일에 설정 추가
# 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-nagiosgraphb. /etc/nagios/objects/commands.cfg 설정 추가
# command to process nagios performance data for nagiosgraph
define command {
command_name process-service-perfdata-for-nagiosgraph
command_line /usr/local/nagiosgraph/libexec/insert.pl
}c. /etc/nagios/objects/templates.cfg
define service {
name graphed-service
action_url /nagios/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+-j
register 0
}d. client 호스트 파일에 해당 서비스 적용
- 그래프를 원하는 모든 서비스에 추가 필요
define service{
use generic-service,graphed-service ; Name of service template to use
host_name ehostidc.co.kr
service_description Current User
check_command check_nrpe!check_users!5!10
}e. httpd 설정
[root@nagios conf.d]# vi /etc/httpd/conf.d/nagios.conf
# enable nagiosgraph CGI scripts
ScriptAlias /nagiosgraph/cgi-bin "/usr/local/nagiosgraph/sbin/"
Options ExecCGI
AllowOverride None
= 2.3>
Require all granted
# Require host 127.0.0.1AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
Require valid-user
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
Require valid-user
# enable nagiosgraph CSS and JavaScript
Alias /nagiosgraph "/usr/local/nagiosgraph/share"
Options None
AllowOverride None
= 2.3>
Require all granted
# Require host 127.0.0.1AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
Require valid-user
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
Require valid-user
f. nagios 설정 파일 확인
[root@nagios nagios]# nagios -v /etc/nagios/nagios.cfg
4. 결과 확인