생산 준비가 된 Naemon 모니터링 서버를 설치하는 방법
이 페이지에서
- 네몬 서버 설치
- 노드 모니터링을 위한 모니터링 클라이언트 설치\n
- 192.168.1.21 - nrpe 클라이언트 - centos 6
- 192.168.1.182 - nrpe 클라이언트 - 우분투
- 192.168.1.75 - nscp 클라이언트 - Windows 서버 2012R2
- 192.168.1.21 - nrpe 클라이언트 - centos 6
- 192.168.1.182 - nrpe 클라이언트 - 우분투
- Naemon 서버에서 구성
- pnp4nagios 구성
Naemon은 네트워크와 애플리케이션의 상태를 명확하게 보여주면서 빠르고 안정적이며 혁신적인 것을 목표로 하는 새로운 모니터링 제품군입니다. 이것은 nagios 서버를 대체하고 매우 안정적이며 thruk라는 놀라운 대시보드를 사용합니다. naemon 설정은 매우 쉽고 inbuild에서 실시간 상태입니다. 이 튜토리얼에서는 그래프용 pnp4nagios와 함께 프로덕션 환경에서 naemon을 설치하고 구성하는 방법을 보여드리겠습니다. Naemon은 매우 안정적입니다. 대규모 환경에서 구성을 유지하는 방법을 보여 드리겠습니다.
이 자습서에서는 4개의 서버를 사용합니다.
- 192.168.1.170 - Naemon 서버 - centos 7
- 192.168.1.21 - nrpe 클라이언트 - centos 6
- 192.168.1.182 - nrpe 클라이언트 - 우분투
- 192.168.1.75 - nscp 클라이언트 - Windows 서버 2012R2
네몬 서버 설치
저는 최소 설치, SELinux 비활성화 및 방화벽 활성화로 CentOS 7 호스트를 사용하고 있습니다.
[ ~]# sestatus SELinux status: disabled [ ~]#
저장소 설치:
[ ~]# yum -y install https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpm
epel 저장소 활성화:
yum -y install epel-release
Naemon 패키지 설치:
[ ~]# yum install naemon*
Naemon은 동일한 Nagios 플러그인과 nrpe를 사용하여 호스트를 모니터링합니다. 이제 설치하겠습니다.
[ ~]# yum install nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe -y
방화벽 규칙을 추가합니다.
[ ~]# firewall-cmd --add-service=http --permanent success [ ~]# firewall-cmd --add-service=https --permanent success [ ~]# firewall-cmd --reload success [ ~]# firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: eno16777736 sources: services: dhcpv6-client http https ssh ports: protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules: [ ~]#
pnp4nagios 설치.
yum install gcc-c++ rrdtool perl-Time-HiRes perl-rrdtool php-gd php php-cli wget
pnp4nagios를 다운로드합니다.
[ ~]# wget https://svwh.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.25.tar.gz [ ~]# tar -zxvf pnp4nagios-0.6.25.tar.gz [ ~]# cd pnp4nagios-0.6.25/ [ pnp4nagios-0.6.25]# ./configure --with-nagios-user=naemon --with-nagios-group=naemon [ pnp4nagios-0.6.25]# make all [ pnp4nagios-0.6.25]# make fullinstall [ pnp4nagios-0.6.25]# make install-webconf [ pnp4nagios-0.6.25]# make install-config [ pnp4nagios-0.6.25]# make install-init
서비스를 다시 시작하고 활성화합니다.
[ ~]# systemctl enable httpd && systemctl restart httpd [ ~]# systemctl enable naemon && systemctl restart naemon [ ~]# systemctl enable thruk && systemctl restart thruk [ ~]# systemctl enable npcd && systemctl restart npcd
http://192.168.1.170/thruk에서 URL에 액세스할 수 있어야 합니다.
기본 사용자 이름은 thrukadmin이고 암호는 thrukadmin입니다.
thrukadmin 암호를 변경하려면 다음을 실행하십시오.
[ ~]# htpasswd /etc/thruk/htpasswd thrukadmin
노드 모니터링을 위한 모니터링 클라이언트 설치
Linux 호스트 모니터링을 위한 nrpe 클라이언트 설치
192.168.1.21 - nrpe 클라이언트 - centos 6
Nagios 플러그인 및 nrpe 클라이언트 설치:
[ ~]# yum install nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe -y
nrpe.cfg를 백업하십시오.
[ ~]# cp /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.bkp
nrpe.conf 파일의 내용을 아래 내용으로 바꿉니다.
[ ~]# cat /etc/nagios/nrpe.cfg log_facility=daemon pid_file=/var/run/nrpe/nrpe.pid nrpe_user=nrpe nrpe_group=nrpe allowed_hosts=127.0.0.1,192.168.1.170 dont_blame_nrpe=1 debug=0 command_timeout=60 connection_timeout=300 include_dir=/etc/nrpe.d/ [ ~]#
allowed_host 아래에 여기에 naemon 서버 ipaddress를 추가합니다. 192.168.1.170입니다.
이제 nrpe 서비스를 다시 시작해야 합니다.
[ ~]# service nrpe restart [ ~]# chkconfig nrpe on
192.168.1.182 - nrpe 클라이언트 - 우분투
:~# apt-get install nagios-nrpe-server nagios-plugins -y
nrpe.cfg를 백업하십시오.
[ ~]# cp /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.bkp
nrpe.conf 파일의 내용을 아래 내용으로 바꿉니다.
:~# cat /etc/nagios/nrpe.cfg log_facility=daemon pid_file=/var/run/nagios/nrpe.pid nrpe_user=nagios nrpe_group=nagios allowed_hosts=127.0.0.1,192.168.1.170 dont_blame_nrpe=1 debug=0 command_timeout=60 connection_timeout=300 include_dir=/etc/nagios/nrpe.d/ :~#
이제 nrpe 서비스를 다시 시작해야 합니다.
:~# systemctl restart nagios-nrpe-server.service :~# systemctl enable nagios-nrpe-server.service
Windows에 Nscp 설치
192.168.1.75 - nscp 클라이언트 - Windows 서버 2012R2
다음 웹 사이트에서 nscp를 다운로드합니다.
다운로드가 완료되면 설치 스크린샷을 따르십시오.
일반을 선택하십시오.
완료 선택:
기본 경로를 선택합니다.
이제 허용된 호스트에서 naemon 호스트를 추가하십시오. 여기 설정에서는 192.168.1.170입니다.
복잡한 암호를 입력했는지 확인하십시오. 이 예에서는 암호를 "howtoforge"로 사용했습니다. 다음으로 nsclient 및 nrpe 활성화를 확인합니다.
설치가 완료되면 서비스가 실행되고 있는지 확인하십시오.
이제 naemon 호스트에서 유효성을 검사하여 도달할 수 있는지 확인합니다.
연결을 확인하기 위해 Naemon Server에서 nrpe 및 nscp를 검증합니다.
[ ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.182 NRPE v2.15 [ ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.21 NRPE v2.15 [ ~]#
[ ~]# /usr/lib64/nagios/plugins/check_nt -H 192.168.1.75 -p 12489 -v CLIENTVERSION -s 'howtoforge' NSClient++ 0.5.0.62 2016-09-14 [ ~]#
서버 모니터링
이 자습서에서는 서버 성능을 모니터링합니다.
프로덕션 환경에서는 호스트 활성 확인과 함께 CPU, 메모리 및 하드 디스크 사용률을 모니터링해야 합니다.
nrpe conf /etc/nrpe.d/base.cfg에 다음 줄 추가
192.168.1.21 - nrpe 클라이언트 - centos 6
[ ~]# cat /etc/nrpe.d/base.cfg command[check_disks]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ command[check_disk]=/usr/lib64/nagios/plugins/check_disk -X nfs -X cifs -X none -X tmpfs -w $ARG1$ -c $ARG2$ command[memory]=/usr/lib64/nagios/plugins/check_memory -w $ARG1$ -c $ARG2$ command[load]=/usr/lib64/nagios/plugins/check_load -w $ARG1$ -c $ARG2$ command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ command[check_procs_c]=/usr/lib64/nagios/plugins/check_procs -c $ARG1$ -C $ARG2$ command[check_procs_a]=/usr/lib64/nagios/plugins/check_procs -c $ARG1$ -a $ARG2$
파일을 저장하고 다시 시작한 다음 nrpe를 다시 시작하십시오.
[ ~]# /etc/init.d/nrpe restart Shutting down nrpe: [FAILED] Starting nrpe: [ OK ] [ ~]#
메모리 플러그인은 기본 플러그인으로 사용할 수 없습니다. 아래 플러그인을 사용하겠습니다.
[ ~]# cd /usr/lib64/nagios/plugins/ [ plugins]# vim check_memory
아래 내용을 추가합니다.
#! /usr/bin/perl -w ##Included Perf data #The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute #copies of the plugins under the terms of the GNU General Public License. # use strict; use Getopt::Long; my ($opt_f, $opt_h, $opt_c, $opt_w); my ($result, $message, $ram_percent); my $PROGNAME="check_memory"; $opt_f = ""; Getopt::Long::Configure('bundling'); GetOptions( "h" => \$opt_h, "help" => \$opt_h, "c=s" => \$opt_c, "Warning_Percentage" => \$opt_c, "w=s" => \$opt_w, "Critical_Percentage" => \$opt_w, ); if ($opt_h) { &print_help(); exit 0; } $opt_w = shift unless ($opt_w); $opt_c = shift unless ($opt_c); if (! $opt_c && ! $opt_w) { print "Warning and Critical must be specified\n"; exit 3; } if ($opt_c <= $opt_w){ print "Critical must be greater than Warning CRITICAL: $opt_c WARNING: $opt_w\n"; exit 3; } $result = 'OK'; open(FREE_M, "free -m|"); while (my $line =
){ if ($line =~ /^Mem/){ my ($junk,$total_mem,$used_mem,$free_mem,$shared_mem,$buffered_mem,$cached_mem)=split(/\s+/,$line); $ram_percent=int(($total_mem-($free_mem+$cached_mem+$buffered_mem))/$total_mem*100*100)/100; } } close(FREE_M); if ($ram_percent > $opt_c){ print "Memory usage is: CRITICAL: ${ram_percent}% used | used=$ram_percent;$opt_w;$opt_c\n"; exit 2; }elsif ($ram_percent > $opt_w) { print "Memory usage is: WARNING: ${ram_percent}% used | used=$ram_percent;$opt_w;$opt_c\n"; exit 1; } else{ print "Memory usage is: $result: ${ram_percent}% used | used=$ram_percent;$opt_w;$opt_c\n"; exit 0; } sub print_usage () { print "Usage:\n"; print " $PROGNAME -f \n"; print " $PROGNAME -c \n"; print " $PROGNAME -w \n"; print " $PROGNAME [-h | --help]\n"; print " $PROGNAME [-V | --version]\n"; } sub print_help () { print << EOF; $PROGNAME v1.0.01 The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute copies of the plugins under the terms of the GNU General Public License. EOF &print_usage(); print "\n"; exit 3; } 다운로드 링크 check_memory 플러그인
파일에 대한 실행 권한을 부여해야 합니다.
[ plugins]# chmod 755 check_memory
nrpe conf /etc/nagios/nrpe.d/base.cfg에 다음 줄 추가
192.168.1.182 - nrpe 클라이언트 - 우분투
여기서 파일 경로는 다릅니다.
플러그인 폴더는 lib64가 아니라 lib입니다.
:~# cat /etc/nagios/nrpe.d/base.cfg command[check_disks]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ command[check_disk]=/usr/lib/nagios/plugins/check_disk -X nfs -X cifs -X none -X tmpfs -w $ARG1$ -c $ARG2$ command[memory]=/usr/lib/nagios/plugins/check_memory -w $ARG1$ -c $ARG2$ command[load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$ command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ command[check_procs_c]=/usr/lib/nagios/plugins/check_procs -c $ARG1$ -C $ARG2$ command[check_procs_a]=/usr/lib/nagios/plugins/check_procs -c $ARG1$ -a $ARG2$
/usr/lib/nagios/plugins에 동일한 check_memory 스크립트를 추가합니다.
:~# vim /usr/lib/nagios/plugins/check_memory :~# chmod 755 /usr/lib/nagios/plugins/check_memory :~# systemctl restart nagios-nrpe-server.service :~#
Naemon 서버에서 구성
naemon 사용자로 로그인:
[ ~]# su - naemon Last login: Thu Mar 9 17:11:39 CET 2017 on pts/0 -sh-4.2$
/etc/naemon/naemon.cfg에서 관리자 메일 변경
........ ........ ........ ........
이제 /etc/naemon/conf.d에서 확인을 수행하도록 사용자 지정 명령을 구성합니다.
아래 내용으로 custom_commands.cfg라는 사용자 정의 명령을 생성합니다.
$ vim /etc/naemon/conf.d/custom_commands.cfg
## Host Alive check ## # command 'check_icmp Host Alive' define command{ command_name host_alive command_line $USER1$/check_icmp -H $HOSTADDRESS$ -n 1 -w 3000.00,80% -c 5000.00,100% } ### Service Command ## # command 'check_nrpe_disks' define command{ command_name check_nrpe_disks command_line $USER1$/check_nrpe -t 55 -u -H $HOSTADDRESS$ -c check_disks -a $ARG1$ $ARG2$ $ARG3$ } # command 'nrpe' define command{ command_name nrpe command_line $USER1$/check_nrpe -t 55 -u -H $HOSTADDRESS$ -c $ARG1$ } # NRPE With Arguements define command{ command_name check_nrpe_a command_line $USER1$/check_nrpe -t 55 -u -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ $ARG3$ $ARG4$ } ##################################### # Windows NSClient++ Checks # command 'check_nt' define command{ command_name nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ -s $USER4$ }
안전을 위해 nscp 클라이언트 암호를 /etc/naemon/resource.cfg에 저장합니다.
........... ........... $USER4$=howtoforge ........... ............
이제 호스트 구성을 정의해야 합니다.
linux.cfg라는 파일을 만듭니다.
$ vim /etc/naemon/conf.d/linux.cfg
define host { host_name centos6.sunil.cc alias Centos address 192.168.1.21 use linux-server hostgroups linux-servers } define host { host_name ubuntu.sunil.cc alias Ubuntu address 192.168.1.182 use linux-server hostgroups linux-servers }
Windows 호스트에 대해서도 동일한 작업을 수행합니다.
$ vim /etc/naemon/conf.d/windows.cfg
define host { host_name ad.sunil.cc alias My Windows Server address 192.168.1.75 use windows-server } define hostgroup { hostgroup_name windows-servers alias Windows Servers }
이제 서비스 구성을 정의해야 합니다.
$ vim linux_services.cfg
define service { service_description Disks Status hostgroup_name linux-servers use generic-service check_command check_nrpe_a!check_disk!15%!5% } define service{ use generic-service hostgroup_name linux-servers service_description Load Average check_command check_nrpe_a!load!30,25,20!45,40,35 } define service{ use generic-service hostgroup_name linux-servers service_description Memory Usage check_command check_nrpe_a!memory!80!90 }
Windows의 경우 유사한 구성을 만듭니다.
$ vim window_services.cfg
define service{ use generic-service hostgroup_name windows-servers service_description Disk - C: check_command nt!USEDDISKSPACE!-l c -w 80 -c 90 } define service{ use generic-service hostgroup_name windows-servers service_description Load Average check_command nt!CPULOAD!-l 60,90,95 } define service{ use generic-service hostgroup_name windows-servers service_description Memory Usage check_command nt!MEMUSE!-w 90 -c 95 }
이제 연락처 이메일 주소를 변경하겠습니다.
$ vim contacts.cfg
define contact { contact_name naemonadmin ; Short name of user alias Naemon Admin ; Full name of user use generic-contact ; Inherit default values from generic-contact template (defined above) email ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }
이제 필요하지 않은 불필요한 구성을 제거합니다.
$ mv switch.cfg switch.cfg.bkp
$ mv printer.cfg printer.cfg.bkp
구성의 유효성을 검사합니다.
$ naemon -v /etc/naemon/naemon.cfg Naemon Core 1.0.6-pkg Copyright (c) 2013-present Naemon Core Development Team and Community Contributors Copyright (c) 2009-2013 Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad License: GPL Website: http://www.naemon.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 20 services. Checked 4 hosts. Checked 1 contacts. Checked 2 host groups. Checked 0 service groups. Checked 1 contact groups. Checked 29 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 4 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check -sh-4.2$
루트로 로그인하고 naemon 서비스를 다시 시작하십시오.
[ conf.d]# systemctl restart naemon [ conf.d]# systemctl status naemon ? naemon.service - Naemon Monitoring Daemon Loaded: loaded (/usr/lib/systemd/system/naemon.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2017-03-09 19:14:36 CET; 7s ago Docs: http://naemon.org/documentation Process: 5112 ExecStart=/usr/bin/naemon --daemon /etc/naemon/naemon.cfg (code=exited, status=0/SUCCESS) Process: 5110 ExecStartPre=/usr/bin/chown -R naemon:naemon /var/run/naemon/ (code=exited, status=0/SUCCESS) Process: 5108 ExecStartPre=/usr/bin/mkdir /var/run/naemon (code=exited, status=1/FAILURE) Main PID: 5114 (naemon) CGroup: /system.slice/naemon.service ??5114 /usr/bin/naemon --daemon /etc/naemon/naemon.cfg ??5115 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh ??5116 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh ??5117 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh ??5118 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh ??5119 /usr/bin/naemon --daemon /etc/naemon/naemon.cfg Mar 09 19:14:36 naemon.sunil.cc systemd[1]: Starting Naemon Monitoring Daemon... Mar 09 19:14:36 naemon.sunil.cc systemd[1]: Failed to read PID from file /var/run/naemon/naemon.pid: Invalid argument Mar 09 19:14:36 naemon.sunil.cc systemd[1]: Started Naemon Monitoring Daemon. [ conf.d]#
대시보드에 로그인하면 서비스가 실행되고 있는 것을 볼 수 있습니다.
Ubuntu 호스트에 대한 서비스가 실패하는 것을 볼 수 있습니다.
It is seen that nrpe package compiled for ubuntu had enable arguments disabled for security vulnerabily and that is the reason it is failing
인수를 활성화하고 naemon에서 튜닝을 관리하려면 패키지를 다시 컴파일해야 합니다.
아래 링크는 다시 컴파일하는 방법을 보여줍니다. 또한 이 사이트에서 활성화 인수로 이미 컴파일된 패키지를 찾을 수 있습니다. 이 튜토리얼에서는 이 미리 컴파일된 패키지를 사용할 것입니다.
https://www.claudiokuenzler.com/blog/626/nrpe-debian-jessie-command-ags-arguments-not-working-error
:~# wget https://www.claudiokuenzler.com/downloads/nrpe/nagios-nrpe-server_2.15-1ubuntu2_amd64.xenial.deb
패키지를 설치합니다.
:~# dpkg -i nagios-nrpe-server_2.15-1ubuntu2_amd64.xenial.deb (Reading database ... 79576 files and directories currently installed.) Preparing to unpack nagios-nrpe-server_2.15-1ubuntu2_amd64.xenial.deb ... Unpacking nagios-nrpe-server (2.15-1ubuntu2) over (2.15-1ubuntu1) ... Setting up nagios-nrpe-server (2.15-1ubuntu2) ... Processing triggers for systemd (229-4ubuntu16) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for man-db (2.7.5-1) ... :~#
NRPE를 다시 시작합니다.
:~# systemctl restart nagios-nrpe-server.service
이제 우리는 naemon을 사용하여 모든 호스트를 모니터링하고 있습니다.
pnp4nagios 구성
성능 그래프를 위해 pnp4nagios를 구성해야 합니다.
이제 스루크 대시보드와 동일한 인증 방법을 사용하겠습니다. 먼저 파일을 백업하고 다음 행을 변경합니다.
[ conf.d]# cd /etc/httpd/conf.d/ [ conf.d]# cp pnp4nagios.conf pnp4nagios.conf.bkp [ share]# cat /etc/httpd/conf.d/pnp4nagios.conf # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER Alias /pnp4nagios "/usr/local/pnp4nagios/share" <Directory "/usr/local/pnp4nagios/share"> AllowOverride None Order allow,deny Allow from all # # Use the same value as defined in nagios.conf # AuthName "Thruk Access" AuthType Basic AuthUserFile /etc/thruk/htpasswd Require valid-user
# Turn on URL rewriting RewriteEngine On Options symLinksIfOwnerMatch # Installation directory RewriteBase /pnp4nagios/ # Protect application and system files from being viewed RewriteRule "^(?:application|modules|system)/" - [F] # Allow any files or directories that exist to be displayed directly RewriteCond "%{REQUEST_FILENAME}" !-f RewriteCond "%{REQUEST_FILENAME}" !-d # Rewrite all other URLs to index.php/URL RewriteRule "^.*$" "index.php/$0" [PT] [ share]# [ conf.d]# systemctl restart httpd.service이제 구성 페이지를 변경해야 합니다.
[ share]# cd /usr/local/pnp4nagios/share/ [ share]# mv install.php install.php.txt
이제 pnp4nagios에 대한 구성 파일을 변경해야 합니다.
구성 파일에서 nagios를 naemon으로 변경합니다.
[ conf.d]# vi /usr/local/pnp4nagios/etc/config_local.php ............................ ................................ $conf['nagios_base'] = "/naemon/cgi-bin"; .................................. ............................
0에서 1까지의 성능 데이터를 활성화합니다.
[ conf.d]# vi /etc/naemon/naemon.cfg ..................... ..................... process_performance_data=1 ...................... ......................
naemon.conf의 맨 아래에 아래 행을 추가하십시오.
[ conf.d]# vi /etc/naemon/naemon.cfg
# # service performance data # service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$ service_perfdata_file_mode=a service_perfdata_file_processing_interval=15 service_perfdata_file_processing_command=process-service-perfdata-file # # # host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$ host_perfdata_file_mode=a host_perfdata_file_processing_interval=15 host_perfdata_file_processing_command=process-host-perfdata-file
이제 custom_commands.conf에 아래 줄을 추가해야 합니다.
[ conf.d]# vim /etc/naemon/conf.d/custom_commands.cfg
define command{ command_name process-service-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$ } define command{ command_name process-host-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$ }
이제 호스트 성능 및 서비스 성능 그래프에 대한 템플릿을 만듭니다.
$ cd /etc/naemon/conf.d/templates/ $ cat pnp.cfg define host { name host-pnp process_perf_data 1 action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_ register 0 } define service { name service-pnp process_perf_data 1 action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ register 0 }
이제 필요한 서비스에 대한 성능 그래프에 액세스하려면 service.cfg 파일을 업데이트해야 합니다.
$ cat linux_services.cfg define service { service_description Disks Status hostgroup_name linux-servers use generic-service,service-pnp ; Name of service template to use check_command check_nrpe_a!check_disk!15%!5% } define service{ use generic-service,service-pnp hostgroup_name linux-servers service_description Load Average check_command check_nrpe_a!load!30,25,20!45,40,35 } define service{ use generic-service,service-pnp hostgroup_name linux-servers service_description Memory Usage check_command check_nrpe_a!memory!80!90 } $ cat window_services.cfg define service{ use generic-service,service-pnp hostgroup_name windows-servers service_description Disk - C: check_command nt!USEDDISKSPACE!-l c -w 80 -c 90 } define service{ use generic-service,service-pnp hostgroup_name windows-servers service_description Load Average check_command nt!CPULOAD!-l 60,90,95 } define service{ use generic-service,service-pnp hostgroup_name windows-servers service_description Memory Usage check_command nt!MEMUSE!-w 90 -c 95 }
호스트 그래프를 확인하기 위해서는 아래 파일에 포함시켜야 합니다.
$ cat linux.cfg define host { host_name centos6.sunil.cc alias Centos address 192.168.1.21 use linux-server,host-pnp hostgroups linux-servers } define host { host_name ubuntu.sunil.cc alias Ubuntu address 192.168.1.182 use linux-server,host-pnp hostgroups linux-servers } $ cat windows.cfg define host { host_name ad.sunil.cc alias My Windows Server address 192.168.1.75 use windows-server,host-pnp } define hostgroup { hostgroup_name windows-servers alias Windows Servers }
구성을 확인합니다.
$ naemon -v /etc/naemon/naemon.cfg Naemon Core 1.0.6-pkg Copyright (c) 2013-present Naemon Core Development Team and Community Contributors Copyright (c) 2009-2013 Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad License: GPL Website: http://www.naemon.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 20 services. Checked 4 hosts. Checked 1 contacts. Checked 2 host groups. Checked 0 service groups. Checked 1 contact groups. Checked 31 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 4 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
서비스를 다시 시작하십시오.
[ ~]# systemctl enable npcd npcd.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig npcd on [ ~]# systemctl restart npcd [ ~]# systemctl restart naemon