ウェブサイト検索

Windows ホストを Nagios 監視サーバーに追加する方法


この記事では、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. Linux ホストを Nagios モニタリング サーバーに追加する

Windows マシンを監視するには、次のいくつかの手順に従う必要があります。

  1. NSClient++ アドオンを Windows マシンにインストールします。
  2. Windows マシンを監視するために Nagios サーバーを構成します。
  3. Windows マシン監視用の新しいホストとサービス定義を追加します。
  4. Nagios サービスを再起動します。

このガイドをシンプルかつ簡単にするために、 いくつかの設定はNagios のインストール時にすでに行われています。

  1. check_nt コマンド定義はすでに command.cfg ファイルに追加されています。この定義コマンドは、Windows サービスを監視するために check_nt プラグインによって使用されます。
  2. Windows サーバー ホストのテンプレートは、templates.cfg ファイル内にすでに作成されています。このテンプレートを使用すると、新しい Windows ホスト定義を追加できます。

上記 2 つのファイル「command.cfg」と「templates.cfg」ファイルは、/usr/local/nagios/etc/objects/ にあります。 ディレクトリ。要件に合わせて独自の定義を変更および追加できます。ただし、この記事で説明されている手順に従うことをお勧めします。20 分以内に Windows ホストを正常に監視できるようになります。

ステップ 1: Windows マシンに NSClient++ エージェントをインストールする

以下の手順に従って、NSClient++ エージェントリモート Windows ホストにインストールしてください。まず、以下のリンクにある最新の安定バージョン 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 ファイルを開き、「モジュール」セクションで定義されているすべてのモジュールのコメントを解除します。 >WMI.dll とRemoteConfiguration.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 サーバーにログインし、 新しいWindowsマシンを監視するためにNagios設定ファイルにいくつかのオブジェクト定義を追加します。 Vi エディタで編集するために windows.cfg ファイルを開きます。

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

Windows マシン用にすでに定義されているサンプル Windows ホスト定義。ホスト名エイリアスアドレスフィールドなどのホスト定義を適切なものに変更するだけです。 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 Monitoring Web インターフェイスに移動し、ユーザー名「nagiosadmin 」とパスワード。 リモート Windows ホストが追加され、監視されていることを確認します。

それでおしまい!現時点では、今後の記事でプリンタスイッチNagios モニタリング サーバーに追加する方法を説明します。 Windows ホストを Nagios に追加する際に問題が発生した場合。コメント セクションを介してクエリにコメントしてください。それまでは、linux-console.net でそのような貴重な記事をさらにご覧ください。