OpenVZ 모니터링 · 5 min read · Oct 18, 2025

Debian 및 Ubuntu에서 vzwatchd로 OpenVZ 한계를 모니터링하는 방법

Vzwatchd는 컨테이너의 한계에 도달했을 때 서버 관리자에게 이메일로 알리는 OpenVZ 모니터링 데몬입니다. OpenVZ는 웹 호스팅 서비스에서 자주 사용되는 리눅스 커널 가상화 기술로, 상업적인 virtuozzo 가상화 애플리케이션의 무료 코어입니다. OpenVZ는 KVM이나 XEN보다 오버헤드가 적은 경량 가상화로, 고급 한계 옵션을 통해 가상 머신이 사용할 수 있는 자원의 양을 정의할 수 있으며 파일 시스템 쿼터를 지원합니다.

이 튜토리얼에서는 Debian 및 Ubuntu에서 vzwatchd 데몬의 설치 및 구성 방법을 설명합니다.

1 내 가상 서버가 OpenVZ를 사용하고 있나요

호스팅 회사에서 가상 서버를 임대했지만 어떤 가상화 기술을 사용하는지 모른다면, 다음 명령어를 실행하여 OpenVZ를 사용하는지 테스트해 보세요:

cat /proc/user_beancounters

출력이 아래와 비슷하다면, 귀하의 서버는 OpenVZ 또는 호환 기술을 사용하고 있으며 vzwatchd를 사용하여 vserver를 모니터링할 수 있습니다.

root@www:/# cat /proc/user_beancounters  
Version: 2.5  
 uid resource held maxheld barrier limit failcnt  
 101: kmemsize 190939926 274194432 9223372036854775807 9223372036854775807 0  
 lockedpages 0 3211 1048576 1048576 0  
 privvmpages 749006 781311 9223372036854775807 9223372036854775807 0  
 shmpages 22506 30698 9223372036854775807 9223372036854775807 0  
 dummy 0 0 9223372036854775807 9223372036854775807 0  
 numproc 237 312 9223372036854775807 9223372036854775807 0  
 physpages 486543 804959 0 1048576 0  
 vmguarpages 0 0 3145728 9223372036854775807 0  
 oomguarpages 233498 242378 1048576 9223372036854775807 0  
 numtcpsock 111 298 9223372036854775807 9223372036854775807 0  
 numflock 253 294 9223372036854775807 9223372036854775807 0  
 numpty 1 12 9223372036854775807 9223372036854775807 0  
 numsiginfo 0 33 9223372036854775807 9223372036854775807 0  
 tcpsndbuf 7083944 11209000 9223372036854775807 9223372036854775807 0  
 tcprcvbuf 3300832 10792248 9223372036854775807 9223372036854775807 0  
 othersockbuf 261256 1008400 9223372036854775807 9223372036854775807 0  
 dgramrcvbuf 0 5152 9223372036854775807 9223372036854775807 0  
 numothersock 166 526 1024 1024 0  
 dcachesize 168291899 247843839 9223372036854775807 9223372036854775807 0  
 numfile 3098 5205 9223372036854775807 9223372036854775807 0  
 dummy 0 0 9223372036854775807 9223372036854775807 0  
 dummy 0 0 9223372036854775807 9223372036854775807 0  
 dummy 0 0 9223372036854775807 9223372036854775807 0  
 numiptent 28 35 9223372036854775807 9223372036854775807 0

출력은 가상 머신의 한계를 보여주며, 각 행은 하나의 한계를 설명하고 vzwatchd가 감시하는 열은 한계에 도달한 횟수를 세는 마지막 열입니다.

2 vzwatchd 설치

Vzwatchd는 Perl로 작성되었으며, CPAN 명령어를 사용하여 Perl CPAN 아카이브에서 다운로드 및 설치됩니다.

필수 구성 요소 설치

다음 단계를 루트 사용자로 수행할 것입니다. Ubuntu에서 루트가 되려면 sudo -s를 실행하세요:

sudo -s

먼저 make 도구와 nano 편집기를 설치할 것입니다. make는 CPAN이 vzwatchd를 빌드하는 데 사용되며, 나중에 nano를 사용하여 구성 파일을 편집할 것입니다:

apt-get install make nano

다음으로 CPAN에서 vzwatchd를 설치할 것입니다:

cpan -i App::OpenVZ::BCWatch

서버에서 CPAN을 처음 사용하는 경우, 스크립트가 기본 CPAN 구성에 대한 몇 가지 질문을 할 것입니다:

Would you like to configure as much as possible automatically? [yes]
Would you like me to automatically choose some CPAN mirror sites for you? (This means connecting to the Internet) [yes]

두 질문 모두 “yes”로 대답하세요.

설치 프로그램은 이제 많은 Perl 모듈을 다운로드, 컴파일 및 설치할 것입니다:

root@rz3:~# cpan -i App::OpenVZ::BCWatch  

CPAN.pm requires configuration, but most of it can be done automatically.  
If you answer 'no' below, you will enter an interactive dialog for each  
configuration option instead.  
  
Would you like to configure as much as possible automatically? [yes] yes  
  
Autoconfigured everything but 'urllist'.  
  
Now you need to choose your CPAN mirror sites. You can let me  
pick mirrors for you, you can select them from a list or you  
can enter them by hand.  
  
Would you like me to automatically choose some CPAN mirror  
sites for you? (This means connecting to the Internet) [yes] yes  
Trying to fetch a mirror list from the Internet  
Fetching with LWP:  
http://www.perl.org/CPAN/MIRRORED.BY  
  
Looking for CPAN mirrors near you (please be patient)  
.............................. done!  
  
New urllist  
 http://www.planet-elektronik.de/CPAN/  
 http://cpan.noris.de/  
 http://cpan.lnx.sk/  
  
Autoconfiguration complete.  
  
commit: wrote '/root/.cpan/CPAN/MyConfig.pm'  
  
You can re-run configuration any time with 'o conf init' in the CPAN shell  
Fetching with LWP:  
http://www.planet-elektronik.de/CPAN/authors/01mailrc.txt.gz  
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'  
............................................................................DONE  
Fetching with LWP:  
http://www.planet-elektronik.de/CPAN/modules/02packages.details.txt.gz  
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'  
 Database was generated on Mon, 13 Apr 2015 23:29:02 GMT  
..............  
 New CPAN.pm version (v2.10) available.  
 [Currently running version is v1.960001]  
 You might want to try  
 install CPAN  
 reload cpan  
 to both upgrade CPAN.pm and run the new version without leaving  
the current session.  
   
 [... snip ...]  
   
 CPAN.pm: Going to build G/GW/GWOLF/Config-File-1.50.tar.gz  
  
Building Config-File  
 GWOLF/Config-File-1.50.tar.gz  
 ./Build -- OK  
Running Build test  
t/pod.t ........... Subroutine main::all_pod_files_ok redefined at /usr/local/share/perl/5.14.2/Test/Pod.pm line 90.  
t/pod.t ........... ok  
t/pod_coverage.t .. ok  
t/test.t .......... 1/11 Invalid characters in key to'be^ignored at line 10 - Ignoring at /root/.cpan/build/Config-File-1.50-NjLxod/blib/lib/Config/File.pm line 41,  line 10.  
Line format invalid at line 11: 'malformed line that should be also dropped (no equal sign)' at /root/.cpan/build/Config-File-1.50-NjLxod/blib/lib/Config/File.pm line 35,  line 11.  
t/test.t .......... ok  
All tests successful.  
Files=3, Tests=13, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.13 cusr 0.02 csys = 0.18 CPU)  
Result: PASS  
 GWOLF/Config-File-1.50.tar.gz  
 ./Build test -- OK  
Running Build install  
Building Config-File  
Installing /usr/local/share/perl/5.14.2/Config/File.pm  
Installing /usr/local/man/man3/Config::File.3pm  
 GWOLF/Config-File-1.50.tar.gz  
 ./Build install -- OK  
Running Build for S/SC/SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz  
 Has already been unwrapped into directory /root/.cpan/build/App-OpenVZ-BCWatch-0.04-4Al97O  
  
 CPAN.pm: Going to build S/SC/SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz  
  
Building App-OpenVZ-BCWatch  
 SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz  
 ./Build -- OK  
Running Build test  
t/00-load.t ....... ok  
t/basic.t ......... ok  
t/pod-coverage.t .. ok  
t/pod.t ........... ok  
All tests successful.  
Files=4, Tests=6, 0 wallclock secs ( 0.04 usr 0.01 sys + 0.27 cusr 0.04 csys = 0.36 CPU)  
Result: PASS  
 SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz  
 ./Build test -- OK  
Running Build install  
Building App-OpenVZ-BCWatch  
Installing /usr/local/man/man1/vzwatchd.1p  
Installing /usr/local/share/perl/5.14.2/App/OpenVZ/BCWatch.pm  
Installing /usr/local/man/man3/App::OpenVZ::BCWatch.3pm  
Installing /usr/local/bin/vzwatchd  
 SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz  
 ./Build install -- OK

중요한 것은 컴파일 출력의 마지막에 다음 줄이 표시되는 것입니다:

./Build install -- OK

대신 오류가 발생하면 명령을 다시 실행하세요. 모든 모듈을 성공적으로 컴파일하기 위해 명령을 두 번 실행해야 했습니다.

설치가 성공했는지 확인하려면 다음 명령을 실행하세요:

vzwatchd check

이 명령은 설치를 확인하고 예제 구성 파일을 생성합니다.

root@server:~# vzwatchd check  
/etc/vzwatchd.conf does not exist, creating one with defaults.  
Edit /etc/vzwatchd.conf to suit your needs and then start /usr/local/bin/vzwatchd again.

3 vzwatchd 구성 및 활성화

이제 vzwatchd.conf 파일을 편집하고 알림 메시지의 이메일 주소를 설정하겠습니다.

nano /etc/vzwatchd.conf

구성 파일은 다음과 같이 편집한 후 귀하의 이메일 주소로 변경되어야 합니다.

mail[from] = [email protected]  
mail[to] = [email protected]  
mail[subject] = vzwatchd on server.example.com: NOTICE  
sleep = 60  
verbose = 0  
monitor_fields = failcnt  
_active = 1

변경 사항은 다음과 같습니다:

  • “mail[from]” 행에는 알림 이메일의 발신 주소가 포함됩니다.
  • “mail[to]” 행에는 알림을 받을 이메일 주소가 포함됩니다.
  • “_active” 행의 값은 vzwatchd를 활성화하기 위해 1로 변경해야 합니다.
  • 여러 OpenVZ 서버를 실행하는 경우 “mail[subject]”를 서버 이름을 포함하도록 변경하는 것이 유용할 수 있습니다.

서버 부팅 시 자동으로 시작되도록 vzwatchd를 구성합니다:

vzwatchd install
root@server:~# vzwatchd install  
+ /usr/sbin/update-rc.d vzwatchd defaults  
update-rc.d: warning: /etc/init.d/vzwatchd missing LSB information  
update-rc.d: see   
Adding system startup for /etc/init.d/vzwatchd ...  
/etc/rc0.d/K20vzwatchd -> ../init.d/vzwatchd  
/etc/rc1.d/K20vzwatchd -> ../init.d/vzwatchd  
/etc/rc6.d/K20vzwatchd -> ../init.d/vzwatchd  
/etc/rc2.d/S20vzwatchd -> ../init.d/vzwatchd  
/etc/rc3.d/S20vzwatchd -> ../init.d/vzwatchd  
/etc/rc4.d/S20vzwatchd -> ../init.d/vzwatchd  
/etc/rc5.d/S20vzwatchd -> ../init.d/vzwatchd

그리고 vzwatchd 모니터 데몬을 시작합니다:

vzwatchd start
root@server:~# vzwatchd start  
Starting /usr/local/bin/vzwatchd server

이제 OpenVZ 가상 서버가 OpenVZ 컨테이너의 한계 중 하나에 도달하면 이메일로 알림을 받게 됩니다.

링크

  • OpenVZ
  • Vzwatchd
Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.