Nagiosは、ネットワーク内のさまざまなネットワークデバイスとサーバーを監視するための無料のオープンソースツールです。 LinuxとWindowsOSの両方をサポートし、ネットワークリソースを監視するための直感的なWebインターフェイスを提供します。構成すると、ネットワークデバイスまたはサーバーがダウンしたり、誤動作したりした場合に、電子メールで警告することができます。 Nagios CoreとNRPE(プラグイン)のインストールと構成に移ります。
前提条件:
下記のコマンドを使用して、前提条件のライブラリをインストールします。
dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel
dnf update -y
次のコマンドを使用してファイアウォールを無効にします。
systemctl stop firewalld.service
systemctl disable firewalld.service
ソースからNagiosをダウンロード:
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
tar -xvzf nagios-4.4.6.tar.gz

ソースからNagiosをコンパイル:
cd nagios-4.4.6/
./configure
make all

ユーザーとグループの作成:
次のコマンドは、ユーザーとグループ「nagios」を作成し、apacheユーザーをnagiosグループに追加します。
make install-groups-users
usermod -a -G nagios apache
Nagiosのインストール:
次のステップは、コマンド「./configure」および「makeall」で構成および作成されたNagiosをインストールすることです
make install
次に、デーモンファイルをインストールし、CLIで次のコマンドを入力してhttpdサービスを開始します。
make install-daemoninit
systemctl start httpd.service
systemctl enable httpd.service
systemctl status httpd.service

次のコマンドを実行して、コマンドモードをインストールします。
make install-commandmode

次に、Nagiosのサンプル構成ファイルをインストールします。これは、以下のコマンドを実行して、目的の構成とApacheWebサーバー構成ファイルに従ってサンプルファイルを編集するためです。
make install-config
make install-webconf
systemctl restart httpd.service

Nagiosユーザーアカウントの作成:
nagiosWebにアクセスするためのnagiosadminユーザーアカウントを作成します。言い換えれば、このWebはアラームを確認するために使用されます。下記のコマンドで、希望のユーザー名をnagiosadminに置き換えるだけで、独自のユーザー名を作成できます。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
上記のコマンドを実行した後、インターフェースはパスワードを要求しますnagioswebにアクセスしたいパスワードを設定します。

httpdおよびnagiosサービスを開始してください。
systemctl start httpd.service
systemctl enable httpd.service
systemctl status httpd.service
systemctl start nagios.service
systemctl enable nagios.service
systemctl status nagios.service

Nagiosのテスト:
これで、Nagiosがシステムにインストールされて実行され、Nagiosをテストできます。「http:// localhost / nagios」のようにWebブラウザにマシンIPを入力し、「createnagiosuseraccount」で設定したユーザー名とパスワードを入力します。

Nagiosプラグイン(NRPE)のインストール
NRPEは(Nagios Remote Plugin Executor)であり、Nagiosコアが監視用のプラグインを実行するため、スクリプトを使用して監視するためにリモートシステムにインストールするNagiosエージェントです。 NRPEを使用すると、他のマシンでNagiosプラグインをリモートで実行して、そのマシンのメトリック(CPU使用率、メモリ使用率、ディスク容量など)を監視できます。以下の手順に従って、CentOS8にNRPEをインストールしてください。
前提条件:
次の前提条件をインストールします。
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum --enablerepo=powertools,epel install perl-Net-SNMP


NRPEのインストール:
dnf install nrpe

NRPEサービスを開始して有効にする:
再起動時に自動的に開始されるように、nrpeサービスを開始して有効にします。
systemctl start nrpe.service
systemctl enable nrpe.service
systemctl status nrpe.service

コマンド「nano/etc/nagios/nrpe.cfg」を使用してnanoエディターでファイルを編集することにより、プラグインを編集および追加し、nrpeをチェックインできます。

プラグインを追加/編集するようにNRPEを構成できます。 Nagiosはこれらのプラグインをリモートで実行して、システムの状態などの目的のチェックをチェックします。