Bashプログラミング
 Computer >> コンピューター >  >> プログラミング >> Bashプログラミング

Nagios への Windows ホストの追加:ステップバイステップ ガイド

この記事ではWindowsを監視する方法について説明します。 マシンは「プライベート」 」 サービスなどのCPU 負荷ディスク使用量メモリ使用量、 サービス など。このためには、NSClient++ をインストールする必要がありました。 Windows のアドオン 機械。アドオンはWindows 間のプロキシとして機能します。 マシンとNagios check_nt と通信して実際のサービスを監視します。 プラグイン。 check_nt プラグインはNagios モニタリング サーバーにすでにインストールされています 、 私たちのNagiosをフォローした場合 インストールガイド。

すでにNagios をインストールして設定していることを前提としています。 以下のガイドに従ってサーバーを設定してください。

<オル>
  • RHEL/CentOS 6.x/5.x および Fedora 19/18/17 に Nagios 4.0.1 をインストールする方法
  • Linux ホストを Nagios モニタリング サーバーに追加する
  • Windows マシンを監視するには いくつかの手順に従う必要があります。

    <オル>
  • Windows マシンに NSClient++ アドオンをインストールします。
  • Windows マシンを監視するために Nagios サーバーを構成します。
  • Windows マシン監視用の新しいホストとサービス定義を追加します。
  • Nagios サービスを再起動します。
  • このガイドをシンプルかつ簡単にするために、いくつかの設定はNagios ですでに行われています。 インストール。

    <オル>
  • check_nt コマンド定義はすでに command.cfg に追加されています ファイル。この定義コマンドは check_nt によって使用されます。 Windows サービスを監視するプラグイン
  • 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 をダウンロードします。 アドオン ソース ファイルは、以下のリンクにあります。

    <オル>
  • http://sourceforge.net/projects/nscplus/
  • 最新の安定バージョンをダウンロードしたら、NSClient++ を解凍します。 ファイルを新しい C:\NSClient++ にコピーします。 ディレクトリ。

    ここでMS-DOSを開きます。 スタート画面からコマンド プロンプトを起動します。 –> 実行 –> 「cmd」と入力します ' Enter キーを押して、C:\NSClient++ に変更します。 ディレクトリ。

    C:\NSClient++

    次に、NSClient++ を登録します。 次のコマンドを使用して、システム上のサービスを起動します。

    nsclient++ /install

    最後に、NSClient++ システムトレイをインストールします。 次のコマンドを使用します。

    nsclient++ SysTray

    Windows サービス マネージャーを開きます。 NSClient を右クリックします。 プロパティに移動します 次に、「ログオン」 ' タブをクリックし、「サービスがデスクトップと対話できるようにする」というチェックボックスをクリックします。 ”。まだ許可されていない場合は、チェックボックスをオンにして許可してください。

    Nagios への Windows ホストの追加:ステップバイステップ ガイド NSClient++ をインストールする

    NSC.INI を開きます ファイルは C:\NSClient++ にあります。 ディレクトリに移動し、「モジュール」で定義されているすべてのモジュールのコメントを解除します。 ” セクション(CheckWMI.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」のコメントを解除します。 「設定」の「 」セクションを開き、IP アドレスを定義します。 Nagios 監視サーバーの または、空白のままにして任意のホストの接続を許可します。

    [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」に設定します。 「。」必ず「12489」を開いてください。 「Windows ファイアウォールのポート」 .

    [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を監視するための構成ファイル 機械。 windows.cfg を開きます。 Vi で編集するためのファイル 編集者。

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

    Windows マシン用にすでに定義されているサンプル Windows ホスト定義。host_name のようにホスト定義を簡単に変更できます。 、別名 、 そして住所 フィールドを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 を持つこれらすべてのサービス

    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
     }

    最後に、windows.cfg のコメントを解除します。 /usr/local/nagios/etc/nagios.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」の Nagios Monitoring Web インターフェイスに移動します。 」または「http://FQDN/nagios」 」と入力し、ユーザー名「nagiosadmin」を入力します。 」とパスワードを入力します。 リモート Windows ホストを確認します。 が追加され、監視されています。

    Nagios への Windows ホストの追加:ステップバイステップ ガイド Nagios モニター Windows ホスト

    それです!現時点では、今後の記事でプリンターを追加する方法を説明します。 とスイッチ Nagios 監視サーバーへ 。 Windows の追加中に問題が発生した場合 Nagios のホスト 。コメント セクションを通じてクエリをコメントしてください。それまでは Tecmint.com をご覧ください。 このような貴重な記事をもっとご覧ください。


    1. シェルスクリプトでの「Linux変数」の理解と記述–パート10

      Linuxシェルスクリプト言語は常にホットな話題であり、将来的には常にそうなるでしょう。シェルスクリプト言語は魔法のようで、他の言語と同じようにスクリプト言語でプログラムを実行するのはとても簡単です。ただし、私たちが行っていることと、その結果が期待されることについての深い知識が必要です。 私たちが読者のために書いたすべてのシェルスクリプトの記事は、最後の記事「Linux変数の洞察」を含めて高く評価されています。前回の記事を新しいレベルに拡張します。 変数属性 Linux環境の各変数には特定のオプションがあり、それらは「属性」と呼ばれます。これらのオプションまたは属性は、オンにすることがで

    2. Bash-it –スクリプトとエイリアスを制御するためのBashフレームワーク

      Bash-it は、 Bash 3.2+用のコミュニティBashコマンドとスクリプトのバンドルです。 、オートコンプリート、テーマ、エイリアス、カスタム関数などが付属しています。日常業務用のシェルスクリプトとカスタムコマンドを開発、保守、使用するための便利なフレームワークを提供します。 日常的にBashシェルを使用していて、すべてのスクリプト、エイリアス、関数を追跡する簡単な方法を探している場合は、 Bash-it あなたのためです! 〜/ binの汚染をやめましょう ディレクトリと.bashrc ファイル、フォーク/クローンBash-それをハッキングし始めます。 LinuxにBash-