웹사이트 검색

Nagios 모니터링 서버에 Windows 호스트를 추가하는 방법


이 문서에서는 CPU 로드, 디스크 사용량, 디스크 사용량과 같은 Windows 시스템의 "비공개" 서비스를 모니터링하는 방법을 설명합니다. >메모리 사용량, 서비스 등. 이를 위해 Windows 시스템에 NSClient++ 애드온을 설치해야 했습니다. 이 애드온은 Windows 시스템과 Nagios 사이에서 프록시 역할을 하며 check_nt 플러그인과 통신하여 실제 서비스를 모니터링합니다. Nagios 설치 가이드를 따랐다면 check_nt 플러그인이 Nagios 모니터링 서버에 이미 설치되어 있습니다.

다음 가이드에 따라 Nagios 서버를 이미 설치하고 구성했다고 가정합니다.

  1. RHEL/CentOS 6.x/5.x 및 Fedora 19/18/17에 Nagios 4.0.1을 설치하는 방법
  2. Nagios 모니터링 서버에 Linux 호스트 추가

Windows 컴퓨터를 모니터링하려면 다음과 같은 몇 가지 단계를 수행해야 합니다.

  1. Windows 머신에 NSClient++ 애드온을 설치합니다.
  2. Windows 머신을 모니터링하기 위해 Nagios 서버를 구성합니다.
  3. Windows 시스템 모니터링을 위한 새 호스트 및 서비스 정의를 추가합니다.
  4. Nagios 서비스를 다시 시작합니다.

이 가이드를 간단하고 쉽게 만들기 위해 Nagios 설치 시 몇 가지 구성이 이미 완료되었습니다.

  1. check_nt 명령 정의가 command.cfg 파일에 이미 추가되었습니다. 이 정의 명령은 Windows 서비스를 모니터링하기 위해 check_nt 플러그인에서 사용됩니다.
  2. Windows 서버 호스트 템플릿templates.cfg 파일에 이미 생성되어 있습니다. 이 템플릿을 사용하면 새 Windows 호스트 정의를 추가할 수 있습니다.

위의 두 파일 "command.cfg" 및 "templates.cfg" 파일은 /usr/local/nagios/etc/objects/ 디렉토리. 요구 사항에 맞게 정의를 수정하고 추가할 수 있습니다. 하지만 이 문서에 설명된 지침을 따르면 20분 이내에 Windows 호스트를 성공적으로 모니터링할 수 있습니다.

1단계: Windows 시스템에 NSClient++ 에이전트 설치

원격 Windows 호스트NSClient++ 에이전트를 설치하려면 아래 지침을 따르세요. 먼저 아래 링크에서 최신 안정 버전인 NSClient++ 0.3.1 애드온 소스 파일을 다운로드하세요.

  1. http://sourceforge.net/projects/nscplus/

최신 안정 버전을 다운로드한 후 NSClient++ 파일의 압축을 새 C:\NSClient++ 디렉토리에 푼다.

이제 시작 화면에서 MS-DOS 명령 프롬프트를 열고 –> 실행 –> 'cmd'를 입력하고 Enter를 누르고 C:\NSClient++ 디렉토리로 변경합니다.

C:\NSClient++

그런 다음, 다음 명령을 사용하여 시스템에 NSClient++ 서비스를 등록합니다.

nsclient++ /install

마지막으로 다음 명령을 사용하여 NSClient++ 시스템 트레이를 설치합니다.

nsclient++ SysTray

Windows 서비스 관리자를 열고 NSClient를 마우스 오른쪽 버튼으로 클릭하고 속성으로 이동한 다음 '로그온' 탭을 클릭하고 '서비스가 데스크톱과 상호작용하도록 허용'이라는 확인란을 선택합니다. 아직 허용되지 않은 경우 확인란을 선택하여 허용하세요.

C:\NSClient++ 디렉토리에 있는 NSC.INI 파일을 열고 modules" 섹션에 정의된 모든 모듈의 주석 처리를 제거합니다. >CheckWMI.dllRemoteConfiguration.dll.

[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
;  You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; *                                                               *
; * N O T I C E ! ! ! - Y O U   H A V E   T O   E D I T   T H I S *
; *                                                               *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
;NSCAAgent.dll
; LUA script module used to write your own "check deamon" (sort of) early beta.
;LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
;CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll

'설정' 섹션에서 'allowed_hosts'의 주석 처리를 제거하고 Nagios 모니터링 서버IP 주소를 정의하거나 모든 호스트가 연결할 수 있도록 하려면 공백으로 남겨두세요.

[Settings]
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
;  If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
;  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=172.16.27.41

"NSClient" 섹션에서 "포트"의 주석 처리를 제거하고 기본 포트 '12489'로 설정합니다. Windows 방화벽에서 '12489' 포트를 열어야 합니다.

[NSClient]
;# NSCLIENT PORT NUMBER
;  This is the port the NSClientListener.dll will listen to.
port=12489

마지막으로 다음 명령을 사용하여 NSClient++ 서비스를 시작합니다.

nsclient++ /start

올바르게 설치 및 구성되면 내부에 검정색 'M'이 있는 노란색 원의 시스템 트레이에 새 아이콘이 표시됩니다.

2단계: Nagios 서버 구성 및 Windows 호스트 추가

이제 Nagios 서버에 로그인하고 Nagios 구성 파일에 일부 객체 정의를 추가하여 새 Windows 시스템을 모니터링하세요. Vi 편집기로 편집할 windows.cfg 파일을 엽니다.

[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg

Windows 시스템에 대해 이미 정의된 샘플 Windows 호스트 정의이므로 host_name, aliasaddress 필드와 같은 호스트 정의를 적절하게 변경할 수 있습니다. Windows 시스템의 가치.

###############################################################################
###############################################################################
#
HOST DEFINITIONS
#
###############################################################################
###############################################################################

Define a host for the Windows machine we'll be monitoring
Change the host_name, alias, and address to fit your situation

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       winserver       ; The name we're giving to this host
        alias           My Windows Server       ; A longer name associated with the host
        address         172.31.41.53    ; IP address of the host
        }

다음 서비스는 이미 windows.cfg 파일에 추가되어 활성화되어 있습니다. 모니터링해야 하는 다른 서비스 정의를 더 추가하려면 해당 정의를 동일한 구성 파일에 간단히 추가하면 됩니다. 위 단계에서 정의된 host_name을 사용하여 이러한 모든 서비스에 대한 host_name을 변경해야 합니다.

define service{
	use			generic-service
	host_name		winserver
	service_description	NSClient++ Version
	check_command		check_nt!CLIENTVERSION
	}

Add the following service definition to monitor the uptime of the Windows server.

define service{
	use			generic-service
	host_name		winserver
	service_description	Uptime
	check_command		check_nt!UPTIME
	}

Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.

define service{
	use			generic-service
	host_name		winserver
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	}

Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.

define service{
	use			generic-service
	host_name		winserver
	service_description	Memory Usage
	check_command		check_nt!MEMUSE!-w 80 -c 90
	}

Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.

define service{
	use			generic-service
	host_name		winserver
	service_description	C:\ Drive Space
	check_command		check_nt!USEDDISKSPACE!-l c -w 80 -c 90
	}

Add the following service definition to monitor the W3SVC service state on the Windows machine and generate a CRITICAL alert if the service is stopped.

define service{
	use			generic-service
	host_name		winserver
	service_description	W3SVC
	check_command		check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
	}

Add the following service definition to monitor the Explorer.exe process on the Windows machine and generate a CRITICAL alert if the process is not running.

define service{
	use			generic-service
	host_name		winserver
	service_description	Explorer
	check_command		check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
	}

마지막으로, /usr/local/nagios/etc/nagios.cfg에서 windows.cfg 파일의 주석 처리를 제거합니다.

[root@tecmint]# vi /usr/local/nagios/etc/nagios.cfg
Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg

마지막으로 Nagios 구성 파일에 오류가 있는지 확인하세요.

[root@tecmint]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

확인 프로세스에서 오류 메시지가 표시되면 오류 메시지 없이 확인 프로세스가 완료될 때까지 해당 오류를 수정하세요. 해당 오류를 수정한 후 Nagios 서비스를 다시 시작하세요.

[root@tecmint]# service nagios restart

Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

그게 다야. 이제 “http://Your-server-IP-address/nagios” 또는 “http://FQDN/nagios”의 Nagios 모니터링 웹 인터페이스로 이동하여 사용자 이름 “nagiosadmin ” 및 비밀번호. 원격 Windows 호스트가 추가되어 모니터링되고 있는지 확인하세요.

그게 다야! 지금은 다음 기사에서 Nagios 모니터링 서버프린터스위치를 추가하는 방법을 보여 드리겠습니다. NagiosWindows 호스트를 추가하는 데 어려움이 있는 경우. 댓글 섹션을 통해 귀하의 질문에 댓글을 달아주세요. 그때까지 linux-console.net에서 더 많은 귀중한 기사를 확인하시기 바랍니다.