LMS知識社群各系上網率圖資處首頁登入
CentOS 7 安裝Nagios (CentOS 7 install Nagios)
by 洪瑞展 2016-09-13 16:43:53, 回應(0), 人氣(2672)
# 更新系統
# 或自動排程更新
# vim /etc/crontab
# 30 3 * * * root yum -y update && yum clean packages
yum -y update

# 安裝php & http
yum install -y httpd php php-cli gd gd-devel gcc glibc glibc-common net-snmp wget

# 建立使用者
useradd nagios
passwd nagios

# 把 nagios, apache 兩個 user 放入 nagcmd group
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

# 下載安裝檔案
# 官方網址 https://www.nagios.com/products/nagios-core/
# sourceforge http://liquidtelecom.dl.sourceforge.net/project/nagios/ (建議)
cd /usr/local/src
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.1.tar.gz#_ga=1.254079432.1716516419.1472455736

# 解壓縮
tar xzvf nagios-4.2.1.tar.gz
cd nagios-4.2.1

# 編譯nagios
./configure -with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

# 安裝nagios plugins:
# 官方網址 http://nagios-plugins.org/download/
cd /usr/local/src
wget http://nagios-plugins.org/download/nagios-plugins-2.1.3.tar.gz
tar xzf nagios-plugins-*.tar.gz
cd nagios-plugins-*
./configure -with-nagios-user=nagios -with-nagios-group=nagios
make
make install

# 啟用服務
systemctl start httpd
systemctl enable httpd

# 設定開機自動啟動
systemctl start nagios
chkconfig -add nagios
chkconfig nagios on

# 驗證nagios是否正確
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# 設定管理網頁的帳號及密碼
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

# 設定防火牆
firewall-cmd --add-service=http --permanent
firewall-cmd --reload

# 測試 帳號nagiosadmin 密碼htpasswd設定密碼
http://IP/nagios