서버 모니터링 · 10 min read · Oct 18, 2025
Debian Squeeze에서 Icinga로 서버 모니터링 - 페이지 2
3 Icinga 구성
server1.example.com:
주요 Icinga 구성 파일은 /etc/icinga/icinga.cfg이며, 추가 구성은 /etc/icinga/commands.cfg 및 /etc/icinga/resource.cfg에 저장됩니다. 일반적으로 기본 구성은 괜찮으므로 이러한 파일을 변경할 필요는 없습니다.
가장 먼저 변경해야 할 것은 /etc/icinga/objects/contacts_icinga.cfg의 연락처 세부정보로, 알림이 올바른 이메일 주소로 전송되도록 해야 합니다:
vi /etc/icinga/objects/contacts_icinga.cfg| [...] define contact{ contact_name root alias Falko Timme service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-service-by-email host_notification_commands notify-host-by-email email [email protected] } [...] |
로컬호스트(= server1.example.com)에 대한 서비스 체크는 /etc/icinga/objects/localhost_icinga.cfg에 정의되어 있습니다. 해당 파일을 살펴보세요:
cat /etc/icinga/objects/localhost_icinga.cfg| # 로컬 호스트 모니터링을 위한 간단한 구성 파일 # 이는 다른 서버를 구성하는 예로 사용할 수 있습니다; # 이 호스트에 특정한 사용자 정의 서비스가 여기에 추가되지만, # icinga-common_services.cfg에 정의된 서비스도 적용될 수 있습니다. # define host{ use generic-host ; 사용할 호스트 템플릿의 이름 host_name localhost alias localhost address 127.0.0.1 } # 로컬 머신의 루트 파티션의 디스크 공간을 체크하는 서비스 정의 # 20% 미만일 경우 경고, 10% 미만일 경우 치명적입니다. define service{ use generic-service ; 사용할 서비스 템플릿의 이름 host_name localhost service_description Disk Space check_command check_all_disks!20%!10% } # 로컬 머신에 현재 로그인한 사용자 수를 체크하는 서비스 정의 # 20명 초과일 경우 경고, 50명 초과일 경우 치명적입니다. define service{ use generic-service ; 사용할 서비스 템플릿의 이름 host_name localhost service_description Current Users check_command check_users!20!50 } # 로컬 머신에서 현재 실행 중인 프로세스 수를 체크하는 서비스 정의 # 250개 초과일 경우 경고, 400개 초과일 경우 치명적입니다. define service{ use generic-service ; 사용할 서비스 템플릿의 이름 host_name localhost service_description Total Processes check_command check_procs!250!400 } # 로컬 머신의 부하를 체크하는 서비스 정의. define service{ use generic-service ; 사용할 서비스 템플릿의 이름 host_name localhost service_description Current Load check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0 } |
check_command 명령(예: check_all_disks)은 /etc/nagios-plugins/config 디렉토리의 Nagios 플러그인 구성 파일에 정의되어 있습니다:
ls -l /etc/nagios-plugins/configroot@server1:~# ls -l /etc/nagios-plugins/config
total 144
-rw-r--r-- 1 root root 277 May 23 04:55 apt.cfg
-rw-r--r-- 1 root root 182 May 23 04:55 breeze.cfg
-rw-r--r-- 1 root root 458 May 23 04:55 dhcp.cfg
-rw-r--r-- 1 root root 909 May 23 04:55 disk.cfg
-rw-r--r-- 1 root root 1722 May 23 04:55 disk-smb.cfg
-rw-r--r-- 1 root root 321 May 23 04:55 dns.cfg
-rw-r--r-- 1 root root 673 May 23 04:55 dummy.cfg
-rw-r--r-- 1 root root 146 May 23 04:55 flexlm.cfg
-rw-r--r-- 1 root root 159 May 23 04:55 fping.cfg
-rw-r--r-- 1 root root 414 May 23 04:55 ftp.cfg
-rw-r--r-- 1 root root 320 May 23 04:55 games.cfg
-rw-r--r-- 1 root root 157 May 23 04:55 hppjd.cfg
-rw-r--r-- 1 root root 3579 May 23 04:55 http.cfg
-rw-r--r-- 1 root root 818 May 23 04:55 ifstatus.cfg
-rw-r--r-- 1 root root 748 May 23 04:55 ldap.cfg
-rw-r--r-- 1 root root 195 May 23 04:55 load.cfg
-rw-r--r-- 1 root root 2062 May 23 04:55 mail.cfg
-rw-r--r-- 1 root root 708 May 23 04:55 mailq.cfg
-rw-r--r-- 1 root root 385 May 23 04:55 mrtg.cfg
-rw-r--r-- 1 root root 567 May 23 04:55 mysql.cfg
-rw-r--r-- 1 root root 2355 May 23 04:55 netware.cfg
-rw-r--r-- 1 root root 420 May 23 04:55 news.cfg
-rw-r--r-- 1 root root 491 May 23 04:55 nt.cfg
-rw-r--r-- 1 root root 466 May 23 04:55 ntp.cfg
-rw-r--r-- 1 root root 426 May 23 04:55 pgsql.cfg
-rw-r--r-- 1 root root 2026 May 23 04:55 ping.cfg
-rw-r--r-- 1 root root 511 May 23 04:55 procs.cfg
-rw-r--r-- 1 root root 240 May 23 04:55 radius.cfg
-rw-r--r-- 1 root root 397 May 23 04:55 real.cfg
-rw-r--r-- 1 root root 315 May 23 04:55 rpc-nfs.cfg
-rw-r--r-- 1 root root 5550 May 23 04:55 snmp.cfg
-rw-r--r-- 1 root root 753 May 23 04:55 ssh.cfg
-rw-r--r-- 1 root root 784 May 23 04:55 tcp_udp.cfg
-rw-r--r-- 1 root root 438 May 23 04:55 telnet.cfg
-rw-r--r-- 1 root root 155 May 23 04:55 users.cfg
root@server1:~#이제 /etc/nagios-plugins/config/disk.cfg 파일을 확인해 보겠습니다:
cat /etc/nagios-plugins/config/disk.cfg| # 'check_disk' 명령 정의 define command{ command_name check_disk command_line /usr/lib/nagios/plugins/check_disk -w '$ARG1$' -c '$ARG2$' -e -p '$ARG3$' } # 'check_all_disks' 명령 정의 define command{ command_name check_all_disks command_line /usr/lib/nagios/plugins/check_disk -w '$ARG1$' -c '$ARG2$' -e } # 'ssh_disk' 명령 정의 define command{ command_name ssh_disk command_line /usr/lib/nagios/plugins/check_by_ssh -H '$HOSTADDRESS$' -C "/usr/lib/nagios/plugins/check_disk -w '$ARG1$' -c '$ARG2$' -e -p '$ARG3$'" } #### # IPv6가 활성화된 시스템에서 IPv4 연결성을 테스트하려면 이러한 체크를 사용하세요 #### # 'ssh_disk_4' 명령 정의 define command{ command_name ssh_disk_4 command_line /usr/lib/nagios/plugins/check_by_ssh -H '$HOSTADDRESS$' -C "/usr/lib/nagios/plugins/check_disk -w '$ARG1$' -c '$ARG2$' -e -p '$ARG3$'" -4 } |
보시다시피, check_all_disks 명령은 /usr/lib/nagios/plugins/check_disk -w ‘$ARG1$’ -c ‘$ARG2$’ -e로 정의되어 있습니다. 다시 /etc/icinga/objects/localhost_icinga.cfg 파일을 살펴보면 check_command check_all_disks!20%!10%라는 줄이 있습니다. Icinga는 서비스 체크에 명령줄 인수를 전달할 수 있도록 해주며, 느낌표(!)로 구분합니다. 따라서 check_command check_all_disks!20%!10%는 첫 번째 명령줄 인수로 20%를, 두 번째 명령줄 인수로 10%를 /usr/lib/nagios/plugins/check_disk -w ‘$ARG1$’ -c ‘$ARG2$’ -e 명령에 전달하여 최종적으로 /usr/lib/nagios/plugins/check_disk -w ‘20%’ -c ‘10%’ -e로 변환됩니다.
느낌표가 포함된 명령줄 인수를 전달하려면, 느낌표를 백슬래시로 이스케이프해야 합니다: !
Nagios 플러그인(즉, Icinga가 체크를 실행하는 데 사용하는 도구)은 /usr/lib/nagios/plugins 디렉토리에 위치합니다:
ls -l /usr/lib/nagios/pluginsroot@server1:~# ls -l /usr/lib/nagios/plugins
total 2476
-rwxr-xr-x 1 root root 106120 May 23 04:55 check_apt
-rwxr-xr-x 1 root root 5369 May 23 04:55 check_bgpstate
-rwxr-xr-x 1 root root 2242 May 23 04:55 check_breeze
-rwxr-xr-x 1 root root 46192 May 23 04:55 check_by_ssh
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_clamd -> check_tcp
-rwxr-xr-x 1 root root 32072 May 23 04:55 check_cluster
-rwxr-xr-x 1 root root 44816 May 23 04:55 check_dhcp
-rwxr-xr-x 1 root root 41392 May 23 04:55 check_dig
-rwxr-xr-x 1 root root 119216 May 23 04:55 check_disk
-rwxr-xr-x 1 root root 8726 May 23 04:55 check_disk_smb
-rwxr-xr-x 1 root root 45488 May 23 04:55 check_dns
-rwxr-xr-x 1 root root 28968 May 23 04:55 check_dummy
-rwxr-xr-x 1 root root 3053 May 23 04:55 check_file_age
-rwxr-xr-x 1 root root 6315 May 23 04:55 check_flexlm
-rwxr-xr-x 1 root root 44656 May 23 04:55 check_fping
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_ftp -> check_tcp
-rwxr-xr-x 1 root root 36584 May 23 04:55 check_game
lrwxrwxrwx 1 root root 10 Aug 23 12:14 check_host -> check_icmp
-rwxr-xr-x 1 root root 41136 May 23 04:55 check_hpjd
-rwxr-xr-x 1 root root 164624 May 23 04:55 check_http
-rwxr-xr-x 1 root root 49264 May 23 04:55 check_icmp
-rwxr-xr-x 1 root root 34536 May 23 04:55 check_ide_smart
-rwxr-xr-x 1 root root 15134 May 23 04:55 check_ifoperstatus
-rwxr-xr-x 1 root root 12598 May 23 04:55 check_ifstatus
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_imap -> check_tcp
-rwxr-xr-x 1 root root 6887 May 23 04:55 check_ircd
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_jabber -> check_tcp
-rwxr-xr-x 1 root root 40816 May 23 04:55 check_ldap
lrwxrwxrwx 1 root root 10 Aug 23 12:14 check_ldaps -> check_ldap
-rwxr-xr-x 1 root root 3407 May 23 04:55 check_linux_raid
-rwxr-xr-x 1 root root 36168 May 23 04:55 check_load
-rwxr-xr-x 1 root root 6026 May 23 04:55 check_log
-rwxr-xr-x 1 root root 20284 May 23 04:55 check_mailq
-rwxr-xr-x 1 root root 36264 May 23 04:55 check_mrtg
-rwxr-xr-x 1 root root 34440 May 23 04:55 check_mrtgtraf
-rwxr-xr-x 1 root root 45936 May 23 04:55 check_mysql
-rwxr-xr-x 1 root root 44688 May 23 04:55 check_mysql_query
-rwxr-xr-x 1 root root 36616 May 23 04:55 check_nagios
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_nntp -> check_tcp
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_nntps -> check_tcp
-rwxr-xr-x 1 root root 48720 May 23 04:55 check_nt
-rwxr-xr-x 1 root root 46288 May 23 04:55 check_ntp
-rwxr-xr-x 1 root root 44880 May 23 04:55 check_ntp_peer
-rwxr-xr-x 1 root root 42224 May 23 04:55 check_ntp_time
-rwxr-xr-x 1 root root 60912 May 23 04:55 check_nwstat
-rwxr-xr-x 1 root root 8326 May 23 04:55 check_oracle
-rwxr-xr-x 1 root root 40400 May 23 04:55 check_overcr
-rwxr-xr-x 1 root root 40656 May 23 04:55 check_pgsql
-rwxr-xr-x 1 root root 48848 May 23 04:55 check_ping
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_pop -> check_tcp
-rwxr-xr-x 1 root root 114640 May 23 04:55 check_procs
-rwxr-xr-x 1 root root 40624 May 23 04:55 check_radius
-rwxr-xr-x 1 root root 40464 May 23 04:55 check_real
-rwxr-xr-x 1 root root 9581 May 23 04:55 check_rpc
lrwxrwxrwx 1 root root 10 Aug 23 12:14 check_rta_multi -> check_icmp
-rwxr-xr-x 1 root root 1137 May 23 04:55 check_sensors
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_simap -> check_tcp
-rwxr-xr-x 1 root root 127216 May 23 04:55 check_smtp
-rwxr-xr-x 1 root root 152008 May 23 04:55 check_snmp
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_spop -> check_tcp
-rwxr-xr-x 1 root root 36688 May 23 04:55 check_ssh
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_ssmtp -> check_tcp
-rwxr-xr-x 1 root root 37832 May 23 04:55 check_swap
-rwxr-xr-x 1 root root 49328 May 23 04:55 check_tcp
-rwxr-xr-x 1 root root 38128 May 23 04:55 check_time
lrwxrwxrwx 1 root root 9 Aug 23 12:14 check_udp -> check_tcp
-rwxr-xr-x 1 root root 44560 May 23 04:55 check_ups
-rwxr-xr-x 1 root root 36168 May 23 04:55 check_users
-rwxr-xr-x 1 root root 2936 May 23 04:55 check_wave
-rwxr-xr-x 1 root root 38152 May 23 04:55 negate
-rwxr-xr-x 1 root root 36104 May 23 04:55 urlize
-rw-r--r-- 1 root root 1938 May 23 04:55 utils.pm
-rwxr-xr-x 1 root root 862 May 23 04:55 utils.sh
root@server1:~#플러그인이 어떤 명령줄 인수를 받을 수 있는지 알아보려면, –help 스위치를 사용하여 해당 플러그인을 호출하십시오. 예를 들어, check_disk 플러그인을 사용하는 방법을 알아보려면 다음을 실행하십시오:
/usr/lib/nagios/plugins/check_disk --help이 지식을 바탕으로 /etc/icinga/objects/localhost_icinga.cfg의 서비스 체크를 원하는 대로 수정할 수 있으며, /etc/nagios-plugins/config 디렉토리에서 플러그인 구성을 추가/수정할 수 있습니다.
이제 MySQL에 대한 서비스 체크를 추가하고 싶다고 가정해 보겠습니다. 먼저 적절한 플러그인 구성을 살펴보겠습니다:
cat /etc/nagios-plugins/config/mysql.cfg| # 'check_mysql' 명령 정의 define command{ command_name check_mysql command_line /usr/lib/nagios/plugins/check_mysql -H '$HOSTADDRESS$' } # 'check_mysql_cmdlinecred' 명령 정의 define command{ command_name check_mysql_cmdlinecred command_line /usr/lib/nagios/plugins/check_mysql -H '$HOSTADDRESS$' -u '$ARG1$' -p '$ARG2$' } # 'check_mysql_database' 명령 정의 define command{ command_name check_mysql_database command_line /usr/lib/nagios/plugins/check_mysql -d '$ARG3$' -H '$HOSTADDRESS$' -u '$ARG1$' -p '$ARG2$' } |
내가 사용하고 싶은 명령은 check_mysql_cmdlinecred입니다. 이 명령은 MySQL 사용자 이름과 비밀번호를 인수로 받습니다(호스트 주소는 서비스 체크 정의의 host_name 매개변수에서 가져옵니다). MySQL 사용자 nagios와 비밀번호 howtoforge를 사용하고 싶으므로, 다음 섹션을 /etc/icinga/objects/localhost_icinga.cfg에 추가합니다:
vi /etc/icinga/objects/localhost_icinga.cfg| [...] define service{ use generic-service host_name localhost service_description MySQL check_command check_mysql_cmdlinecred!nagios!howtoforge } |
Icinga를 재시작하기 전에 MySQL 사용자 nagios를 비밀번호 howtoforge로 생성해야 합니다:
mysql -u root -pGRANT USAGE ON *.* TO nagios@localhost IDENTIFIED BY 'howtoforge';
GRANT USAGE ON *.* TO [email protected] IDENTIFIED BY 'howtoforge';
FLUSH PRIVILEGES;quit;(USAGE 권한은 ‘권한 없음’의 동의어입니다. 즉, nagios 사용자는 MySQL에 연결할 수 있지만 데이터를 변경하거나 읽을 수는 없습니다.)
이제 변경 사항이 적용되도록 Icinga를 재시작합니다:
/etc/init.d/icinga restart이제 Icinga 웹 인터페이스에서 localhost의 서비스를 확인하면 MySQL 체크가 추가된 것을 볼 수 있어야 합니다:

마찬가지로 SMTP, POP3 및 IMAP에 대한 체크를 추가할 수 있습니다. 이들은 단순한 연결 체크이므로 인수가 필요하지 않습니다:
vi /etc/icinga/objects/localhost_icinga.cfg| [...] define service{ use generic-service host_name localhost service_description SMTP check_command check_smtp } define service{ use generic-service host_name localhost service_description POP3 check_command check_pop } define service{ use generic-service host_name localhost service_description IMAP check_command check_imap } |
Icinga를 재시작합니다…
/etc/init.d/icinga restart… 그리고 잠시 후 Icinga 웹 인터페이스에서 새로운 체크를 볼 수 있어야 합니다:

로컬호스트에 대한 SSH 및 HTTP 체크가 /etc/icinga/objects/localhost_icinga.cfg에 정의되어 있지 않다는 것을 눈치챘을 것입니다. 이들은 /etc/icinga/objects/hostgroups_icinga.cfg 파일의 호스트 그룹에 정의되어 있습니다. 호스트 그룹을 사용하면 여러 서버에 대해 서비스 체크를 실행하고 한 번만 정의할 수 있습니다. 해당 파일을 살펴보세요:
cat /etc/icinga/objects/hostgroups_icinga.cfg| # 일부 일반 호스트 그룹 정의 # 간단한 와일드카드 호스트 그룹 define hostgroup { hostgroup_name all alias All Servers members * } # Debian GNU/Linux 서버 목록 define hostgroup { hostgroup_name debian-servers alias Debian GNU/Linux Servers members localhost } # 웹 서버 목록 define hostgroup { hostgroup_name http-servers alias HTTP servers members localhost } # SSH 접근 가능한 서버 목록 define hostgroup { hostgroup_name ssh-servers alias SSH servers members localhost } |
보시다시피, http-servers라는 호스트 그룹과 ssh-servers라는 호스트 그룹이 있으며, localhost는 이들 각 그룹의 구성원입니다. 호스트 그룹에 대한 서비스 체크는 /etc/icinga/objects/services_icinga.cfg에 정의되어 있습니다. 이 파일에는 서비스 체크가 포함되어 있으며, 이러한 체크가 적용될 호스트 그룹을 hostgroup_name 매개변수를 사용하여 참조합니다:
cat /etc/icinga/objects/services_icinga.cfg| # 웹 서비스가 실행 중인지 확인 define service { hostgroup_name http-servers service_description HTTP check_command check_http use generic-service notification_interval 0 ; > 0으로 설정하면 다시 알림을 받습니다 } # SSH 서비스가 실행 중인지 확인 define service { hostgroup_name ssh-servers service_description SSH check_command check_ssh use generic-service notification_interval 0 ; > 0으로 설정하면 다시 알림을 받습니다 } |
보시다시피, SSH 및 HTTP 서비스 체크가 여기에서 정의되어 있습니다.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.