GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu22.04にNagiosをインストールする方法

Nagiosは、WindowsおよびLinuxオペレーティングシステムで実行されているサービスとアプリケーションを監視するための最高のオープンソース監視ツールの1つです。

Nagiosは、HTTP、FTP、SSH、SMTPなどのサービス、およびCPU負荷、メモリ、ディスク使用量、ログインユーザー、実行中のプロセスなどのシステムメトリックを監視できます。

ここでは、Ubuntu22.04にNagiosをインストールする方法を説明します。

前提条件

NagiosパッケージはUbuntuリポジトリで入手できますが、ソースからコンパイルします。したがって、Nagiosをコンパイルするために以下のパッケージをインストールしてください。

sudo apt update

sudo apt install -y build-essential apache2 php openssl perl make php-gd libgd-dev libapache2-mod-php libperl-dev libssl-dev daemon wget apache2-utils unzip

Nagiosのユーザーとグループを作成します。次に、nagiosおよびapacheユーザー(www-data)をnagcmdグループの一部に追加して、NagiosWebインターフェイスを介して外部コマンドを実行します。

sudo useradd nagios

sudo groupadd nagcmd

sudo usermod -a -G nagcmd nagios

sudo usermod -a -G nagcmd www-data

Ubuntu22.04にNagiosCoreをインストールする

まず、公式WebサイトからNagiosコアの最新バージョンをダウンロードします。

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz

tar -zxvf nagios-4.4.6.tar.gz

cd nagios-4.4.6/

次に、以下のコマンドを実行して、ソースコードからNagiosをコンパイルします。

sudo ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/

sudo make all

sudo make install

sudo make install-init

sudo make install-config

sudo make install-commandmode

Nagiosの構成ファイルは/usr/ local / nagios / etcディレクトリにあり、デフォルトの構成で問題なく動作するはずです。

次に、以下のコマンドを使用してNagiosWebインターフェースをインストールします。

sudo make install-webconf

Nagios Webインターフェースはデフォルトでパスワードで保護されており、Nagios Webインターフェースにアクセスするにはユーザーアカウント(nagiosadmin)を作成する必要があります。したがって、以下のコマンドを使用して、NagiosWebインターフェイスのユーザーアカウントを作成します。

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

次のコマンドを使用してCGIモジュールを有効にします。

sudo a2enmod cgi

最後に、ApacheWebサーバーを再起動します。

sudo systemctl restart apache2

Ubuntu22.04でNagiosアラートを取得

Nagiosアラートを取得するには、/ usr / local / nagios / etc / objects / contacts.cfgファイルを編集し、nagiosadminに関連付けられているメールアドレスを変更します。

sudo nano /usr/local/nagios/etc/objects/contacts.cfg

アラートを受信するには、メールアドレスフィールドを変更してください。

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           [email protected]      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

             }

Ubuntu22.04にNagiosプラグインをインストールする

システムを監視するには、Nagiosプラグインをインストールする必要があります。だから、公式ウェブサイトからNagiosプラグインをダウンロードしてください。

wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz

tar -zxvf nagios-plugins-2.3.3.tar.gz

cd nagios-plugins-2.3.3/

次に、Nagiosプラグインをコンパイルしてインストールします。

sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios

sudo make

sudo make install

Nagiosモニタリングツールを起動

それでは、Nagiosサービスを開始しましょう。サービスを開始する前に、Nagios構成ファイルを確認してください。

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Output:

Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
        Checked 8 services.
        Checked 1 hosts.
        Checked 1 host groups.
        Checked 0 service groups.
        Checked 1 contacts.
        Checked 1 contact groups.
        Checked 24 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 1 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

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

次に、以下のコマンドを使用してNagiosサービスを開始して有効にします

sudo systemctl enable --now nagios

NagiosWebインターフェースへのアクセス

次に、WebブラウザでURLをたどって、NagiosWebインターフェイスにアクセスします。

http:// ip-add-re-ss / nagios /

以前に作成したNagiosアカウントのユーザー名(nagiosadmin)とパスワードを入力します。

ログインに成功すると、Nagiosのホームページが表示されます。

左側のペインで[サービス]をクリックして、Nagiosによって監視されているサービスを確認します。

上のスクリーンショットでは、ローカルホスト、つまりNagiosサーバーのみが表示されています。リモートマシンを監視するには、NRPEプラグインを使用する必要があります。

読む :NagiosでリモートLinuxホストを監視する方法

結論

それで全部です。これまでに、Ubuntu22.04でNagiosが稼働していることを願っています。


Ubuntu
  1. Ubuntu15.04にNagiosをインストールする方法

  2. Ubuntu20.04LTSにNagiosをインストールする方法

  3. Ubuntu22.04LTSにNagiosをインストールする方法

  1. Ubuntu18.04にDockerをインストールする方法

  2. Ubuntu18.04にApacheをインストールする方法

  3. Ubuntu18.04にMariaDB10.4をインストールする方法

  1. Ubuntu18.04にMongoDBをインストールする方法

  2. Ubuntu18.04にJenkinsをインストールする方法

  3. Ubuntu20.04にClickHouseをインストールする方法