RHEL / CentOS 7 安裝 Nagios


Nagios 是一個開源的伺服器監測工具, 可以當發現問題時自動通知系統管理員。以下是 RHEL 及 CentOS 7 安裝設定 Nagios 的方法。

首先要安裝所需套件, 例如 HTTPD 及 PHP 等:

# yum install httpd php php-cli gd gd-devel gcc glibc glibc-common net-snmp wget

建立 Nagios 的帳號及群組, 並設定 Nagios 的群組接受經由網頁介面傳入的指令:

# useradd nagios
# passwd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

現在可以安裝 Nagios, 先到官方網站下載 Nagios 的最新版本:

# cd /usr/local/src
# wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz
# tar xzf nagios-4.0.8.tar.gz
# cd nagios-4.0.8
# ./configure –with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
# make install-webconf

安裝好 Nagios 後, 從官方網站下載相關 plugins:

# cd /usr/local/src
# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
# tar xzf nagios-plugins-2.0.3.tar.gz
# cd nagios-plugins-2.0.3
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
# make
# make install

安裝好 Nagios 及它的 plugins 後, 設定 Nagios 管理介面的 Apache 密碼保護, 以及設定 Apache 開機自動啟動:

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# systemctl start httpd
# systemctl enable httpd

現在啟動 Nagios 及設定開機自動執行:

# systemctl start nagios
# chkconfig –add nagios
# chkconfig nagios on

現在已經安裝完成 Nagios, 假設伺服器的 ip 是 192.168.1.100, 可以用瀏覽器透過以下網址登入 Nagios 的管理介面:

http://192.168.1.100/nagios

使用名稱稱是 “nagiosadmin”, 而密碼是在上面用 htpasswd 設定的密碼。

2 Comments

  1. p3505 13 January 2017
    • Sam Tang 13 January 2017

Leave a Reply