서버 모니터링 · 5 min read · Oct 18, 2025
Debian Squeeze에서 Icinga로 서버 모니터링 - 페이지 3
4 원격 서버(server2) Icinga에 추가하기
로컬호스트를 모니터링하는 것은 좋지만, 물론 모든 서버를 한 곳에서 모니터링할 수 있다면 더 좋을 것입니다. Icinga를 사용하면 가능하며, 이 장에서는 두 번째 Debian Squeeze 서버(server2.example.com)를 설정에 추가하는 방법을 설명합니다.
이를 위해 server2에 Nagios NRPE(Nagios Remote Plugin Executor) 서버를 설치하고, server1에 Nagios NRPE 플러그인을 설치해야 합니다. NRPE 서버는 server2에서 대기하며, server1은 NRPE 플러그인을 사용하여 연결하고 NRPE 서버가 server2에서 실행할 명령을 전달합니다. 결과는 server1로 다시 전달됩니다.
먼저 server1에 nagios-nrpe-plugin 패키지를 설치합니다:
server1:
apt-get install nagios-nrpe-pluginNagios 웹 관리 비밀번호: <– nagiosadmin_password
비밀번호 확인: <– nagiosadmin_password
이제 server2로 이동합니다:
server2:
nagios-nrpe-server 패키지를 설치합니다:
apt-get install nagios-nrpe-server작업 그룹/도메인 이름: <– WORKGROUP
이제 /etc/nagios/nrpe.cfg를 엽니다:
vi /etc/nagios/nrpe.cfgNRPE 서버가 server1( IP: 192.168.0.100 )의 연결을 허용하도록 구성해야 하므로, allowed_hosts 줄에 192.168.0.100을 추가합니다:
| [...] # ALLOWED HOST ADDRESSES # This is an optional comma-delimited list of IP address or hostnames # that are allowed to talk to the NRPE daemon. # # Note: The daemon only does rudimentary checking of the client's IP # address. I would highly recommend adding entries in your /etc/hosts.allow # file to allow only the specified host to connect to the port # you are running this daemon on. # # NOTE: This option is ignored if NRPE is running under either inetd or xinetd allowed_hosts=127.0.0.1,192.168.0.100 [...] |
(이 작업을 수행하지 않으면, server1에서 다음을 실행할 때 다음과 같은 오류가 발생합니다:
/usr/lib/nagios/plugins/check_nrpe -H 192.168.0.101server1에서:
root@server1:/etc/nagios-plugins/config# /usr/lib/nagios/plugins/check_nrpe -H 192.168.0.101
CHECK_NRPE: Error - Could not complete SSL handshake.
root@server1:/etc/nagios-plugins/config#)
또한, server1이 NRPE 서버에 명령 줄 인수를 전달할 수 있도록 허용해야 하므로, 같은 파일에서 dont_blame_nrpe를 1로 설정합니다:
| [...] # COMMAND ARGUMENT PROCESSING # This option determines whether or not the NRPE daemon will allow clients # to specify arguments to commands that are executed. This option only works # if the daemon was configured with the --enable-command-args configure script # option. # # * ENABLING THIS OPTION IS A SECURITY RISK! * # Read the SECURITY file for information on some of the security implications # of enabling this variable. # # Values: 0=do not allow arguments, 1=allow command arguments dont_blame_nrpe=1 [...] |
(이 작업을 수행하지 않으면, Icinga 웹 인터페이스에서 많은 원격 서비스 체크에 대해 다음과 같은 오류가 표시됩니다:
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.그리고 server2의 /var/log/syslog에서 다음과 같은 오류가 표시됩니다:
Aug 23 14:20:20 server2 nrpe[11496]: Error: Request contained command arguments, but argument option is not enabled!
Aug 23 14:20:20 server2 nrpe[11496]: Client request was invalid, bailing out...)
마지막으로, server2에서 실행하려는 각 서비스 체크에 대한 명령 정의를 추가해야 하며, 이미 정의되어 있지 않은 것입니다. 나는 server2에서 check_procs, check_all_disks 및 check_mysql_cmdlinecred 체크를 실행하고 싶습니다. 이들은 /etc/nagios/nrpe.cfg에 정의되어 있지 않으므로 지금 추가합니다(나는 check_users 및 check_load 체크도 실행하고 싶지만, 이들은 이미 정의되어 있습니다):
| [...] command[check_procs]=/usr/lib/nagios/plugins/check_procs -w 250 -c 400 command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w '20%' -c '10%' -e command[check_mysql_cmdlinecred]=/usr/lib/nagios/plugins/check_mysql -H localhost -u 'nagios' -p 'howtoforge' [...] |
(이 작업을 수행하지 않으면, Icinga 웹 인터페이스에서 다음과 같은 오류가 발생합니다:
NRPE: Command 'check_all_disks' not defined
NRPE: Command 'check_mysql_cmdlinecred' not defined
NRPE: Command 'check_procs' not defined)
보시다시피, 나는 명령 줄 인수를 하드코딩했습니다. 왜냐하면 command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$와 같은 변수를 사용하는 것이 나에게는 작동하지 않았기 때문입니다. 하지만 여전히 server1에서 server2에 대한 서비스 체크를 구성할 때 이러한 체크에 명령 줄 인수를 전달해야 합니다. server2는 /etc/nagios/nrpe.cfg에 명령 줄 인수를 하드코딩했기 때문에 이를 무시할 것입니다. 그러나 이를 생략하면 Icinga 웹 인터페이스에서 /usr/lib/nagios/plugins/check_nrpe: option requires an argument – ‘a’와 같은 오류가 발생합니다.
이제 파일을 저장하고 NRPE 서버를 재시작합니다:
/etc/init.d/nagios-nrpe-server restart이제 NRPE 서버가 대기 중인지 확인합니다:
netstat -tap | grep nrperoot@server2:~# netstat -tap | grep nrpe
tcp 0 0 *:nrpe *:* LISTEN 2132/nrpe
root@server2:~#이제 server1로 돌아갑니다…
server1:
… 그리고 server2의 NRPE 서버에 연결할 수 있는지 확인합니다:
/usr/lib/nagios/plugins/check_nrpe -H 192.168.0.101성공할 경우 출력은 다음과 같아야 합니다:
root@server1:~# /usr/lib/nagios/plugins/check_nrpe -H 192.168.0.101
NRPE v2.12
root@server1:~#이제 server2로 돌아갑니다:
server2:
server2에서 MySQL을 확인하고 싶습니다. NRPE 데몬을 사용하므로, server2에서 로컬로 체크를 실행할 수 있습니다. 즉, server1이 체크를 실행할 수 있도록 MySQL을 외부에 열 필요가 없습니다. 따라서 localhost와 localhost.localdomain을 위해 nagios라는 MySQL 사용자를 생성합니다:
mysql -u root -pGRANT USAGE ON *.* TO nagios@localhost IDENTIFIED BY 'howtoforge';
GRANT USAGE ON *.* TO [email protected] IDENTIFIED BY 'howtoforge';
FLUSH PRIVILEGES;quit;이제 server1로 돌아갑니다…
server1:
… 그리고 server2에 대한 Icinga 구성을 생성합니다:
vi /etc/icinga/objects/server2_icinga.cfg| define host{ use generic-host host_name server2.example.com alias server2 address 192.168.0.101 } define service{ use generic-service host_name server2.example.com service_description PING check_command check_ping!100.0,20%!500.0,60% } define service{ use generic-service ; Name of service template to use host_name server2.example.com service_description Disk Space check_command check_nrpe!check_all_disks!20%!10% } define service{ use generic-service host_name server2.example.com service_description Current Users check_command check_nrpe!check_users!20!50 } define service{ use generic-service ; Name of service template to use host_name server2.example.com service_description Total Processes check_command check_nrpe!check_procs!250!400 } define service{ use generic-service ; Name of service template to use host_name server2.example.com service_description Current Load check_command check_nrpe!check_load!5.0!4.0!3.0!10.0!6.0!4.0 } define service{ use generic-service host_name server2.example.com service_description MySQL check_command check_nrpe!check_mysql_cmdlinecred!nagios!howtoforge } define service{ use generic-service host_name server2.example.com service_description SMTP check_command check_smtp } define service{ use generic-service host_name server2.example.com service_description POP3 check_command check_pop } define service{ use generic-service host_name server2.example.com service_description IMAP check_command check_imap } |
(앞서 언급했듯이, server2의 /etc/nagios/nrpe.cfg에 일부 명령의 명령 줄 인수를 하드코딩했지만, 여전히 특정 체크에 대해 명령 줄 인수를 추가해야 합니다.)
보시다시피, 나는 일부 체크에 대해 check_nrpe를 사용하고 실제 체크(예: check_all_disks)를 check_nrpe에 대한 명령 줄 인수로 전달합니다. 이는 server2의 NRPE 서버에서 로컬로 실행될 체크입니다. 모든 체크에 대해 check_nrpe가 필요하지 않습니다. check_ping이나 check_smtp와 같이 외부에서 연결을 테스트하는 체크는 server1에서 실행할 수 있습니다.
server2에서 SSH 및 HTTP 서비스를 확인하기 위해, 우리는 또는 /etc/icinga/objects/server2_icinga.cfg에 다음 구문을 추가할 수 있습니다…
| [...] define service { use generic-service host_name server2.example.com service_description SSH check_command check_ssh } define service { use generic-service host_name server2.example.com service_description HTTP check_command check_http } |
… 또는 /etc/icinga/objects/hostgroups_icinga.cfg의 http-servers 및 ssh-servers 호스트 그룹에 server2.example.com을 추가합니다:
vi /etc/icinga/objects/hostgroups_icinga.cfg| # Some generic hostgroup definitions # A simple wildcard hostgroup define hostgroup { hostgroup_name all alias All Servers members * } # A list of your Debian GNU/Linux servers define hostgroup { hostgroup_name debian-servers alias Debian GNU/Linux Servers members localhost,server2.example.com } # A list of your web servers define hostgroup { hostgroup_name http-servers alias HTTP servers members localhost,server2.example.com } # A list of your ssh-accessible servers define hostgroup { hostgroup_name ssh-servers alias SSH servers members localhost,server2.example.com } |
Icinga를 재시작합니다:
/etc/init.d/icinga restart그 후 Icinga 웹 인터페이스에서 server2를 찾아야 합니다:

server2의 서비스 체크는 다음과 같습니다:

server2를 호스트 그룹에 추가했다면, 모든 호스트 그룹에 대한 서비스 개요 아래에 나열되어야 합니다:

5 링크
- Icinga: https://www.icinga.org/
- Icinga 문서: http://docs.icinga.org/latest/en/
- Nagios: http://www.nagios.org/
- Debian: http://www.debian.org/
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.