NSClient++ 디버깅모드 진입

NagiOS 모니터링 시스템을 구축할 때에 윈도우OS를 사용하는 호스트를 모니터링 할 경우 대부분 NSClinet++를 사용하고있다. 윈도우용 nrpe 툴도 없는건 아니지만, 설치 및 운영의 편의성이 아무래도 NSClient++가 더 좋아 사용을 하기 시작했다.

문제는 NSClinet++만의 문제는 아니겠지만, 리눅스에서의 nrpe 처럼 로그나 설정 등을 세세히 모니터링하거나 접근하기가 어렵다는데에 있다.
nrpe의 경우 설치된 호스트 서버에서 nrpe.cfg 파일을 확인하고, 설정된 커맨드를 직접 입력하여 실행도 해보면서 확인도 가능한데, NSClient++는 그 조차도 어렵다.

아무래도 NSClinet++와 nrpe 툴간의 호출 방식 차이에서 비롯된것 같기는 한데, 정확한 이유는 좀 더 살펴봐야할 거 같고.
그나마 NSClinet++에서는 디버깅 모드를 지원하는 덕에 조금 다르게나마 실제 동작 상태 등을 어느정도 살펴 볼 수 있다.

디버깅 모드는 다음과 같이 진입한다.

C:\Program Files\NSClient++>nscp service --stop
Stopping service.

C:\Program Files\NSClient++>nscp test
L     client Module: CommandClient
L     client Command:
L     client Extra Query:

PATH로 nscp.exe 파일이 연결되어 있다면 어느 폴더에서나 실행이 되겠지만, 그렇지 않다면 커맨드 창에서 nscp.exe가 설치된 폴더로 이용하여 명령을 실행한다.(대부분 디렉토리는 C:\Program Files\NSClient++)
‘nscp test’ 명령을 실행하면 여러 체크 내용들이 지나가다 어느 순간 출력이 멈추고 별다른 프롬프트 없이 커서만 깜빡(?)이며 화면이 정지하는데, 이때부터 체크 명령들을 입력할 수도 있고, 모니터링 서버에서 명령이 호출되었을 때 값이나 상태등을 알려준다.

모니터링 서버에서 check_nt 명령을 통해서 정상적으로 호출이 이루어졌을 경우에는 다음과 같은 메시지가 출력된다.

D   check_nt Accepting connection from: [모니터링 서버IP]
D   check_nt Accepting connection from: [모니터링 서버IP]

에러가 발생하면 다음과 같이 출력된다.

E  w32system Exception in Failed to poll counter: PdhCollectQueryData failed: :800007d5: 諛섑솚???곗씠?곌? ?놁뒿?덈떎.
                    D:\source\nscp\modules\CheckSystem\check_pdh.cpp:244

이렇게 에러메시지를 통해서 문제가 될만한 부분들을 확인하고 처리해나가면 된다.

다음과 같이 ‘check_cpu’ 등의 명령을 직접 실행해 볼수도 있다.

check_cpu
L        cli OK: OK: CPU load is ok.
L        cli  Performance data: 'total 5m'=0%;80;90 'total 1m'=0%;80;90 'total 5
s'=0%;80;90

디버깅 모드를 빠져나올때는 ‘exit’ 명령을 이용하면 된다. 그리고 반드시 nscp 서비스를 재시작해 줄 것.

exit
D       core Attempting to stop all plugins
D       core Stopping all plugins
D       core Unloading plugin: CheckDisk.dll...
D       core Unloading plugin: CheckEventLog.dll...
D       core Unloading plugin: CheckHelpers.dll...
D       core Unloading plugin: CheckNSCP.dll...
D       core Unloading plugin: CheckSystem.dll...
D       core Unloading plugin: NRPEServer.dll...
D       core Unloading plugin: NSCAClient.dll...
D       core Unloading plugin: NSClientServer.dll...
D       core Unloading plugin: CommandClient.dll...
D       core Stopping: COM helper
D       core Stopping: Settings instance
Done

C:\Program Files\NSClient++>nscp service --start

C:\Program Files\NSClient++>nscp service --stop
Stopping service.

C:\Program Files\NSClient++>nscp service --start
Starting NSCP
C:\Program Files\NSClient++>

libwrap refused connection to nrpe (libwrap=nrpe) from

nagios 서버에서 호스트에 대한 체크가 정상적으로 이루어지지 않고, 시스템로그에 다음과 같은 메시지가 확인된다면,

xinetd[30023]: libwrap refused connection to nrpe (libwrap=nrpe) from AIX IP

다음 두가지 포함하여 보안 설정에서 nagios 서버에 대한 허용설정이 되어 있는지 확인.

  1. iptables 설정 확인
  2. /etc/hosts.allow,/etc/hosts.deny 설정 확인

Can’t locate Sys/Statistics/Linux.pm

Perl로 작성된 Nagios 플러그인 스크립트 실행 중 다음과 같은 에러가 발생하는 경우가 있습니다.

Can't locate Sys/Statistics/Linux.pm in @INC (@INC contains: /usr/local/nagios/libexec /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .)</strong></p>

Sys-Statistics-Linux 모듈이 설치되지 않아 발생하는 것으로

  1. 우선 다음 명령 실행하여 Sys-Statistics-Linux 설치를 진행해봅니다.
    /usr/bin/perl -e 'use CPAN;install Sys::Statistics::Linux';
    • 경우에 따라서 여러 질문들이 나올 경우가 있으나 대부분은 그냥 엔터로 넘기시고, 마지막 대륙,국가,저장소 선택만 Asia, Republic of Korea 로 선택, 저장소는 되도록 1번으로 선택하고 진행하시면 됩니다. 저장소 중 neowiz 는 추천하지 않습니다.
  2. 1번이 정상 진행되지 않거나 완료 후에도 문제가 계속된다면 CPAN사이트에서 다운로드하여 다음과 같이 설치 진행하면 해결 된다.
# tar xzf Sys-Statistics-Linux-0.66.tar.gz
# cd Sys-Statistics-Linux-0.66
# perl Makefile.PL
# make
# make test
# make install

테스트는 CentOS 5.9에서 진행되었으므로 참고하시길…