Nagios 是企業級基礎設施監控標準工具。本文記錄在 CentOS 5.5 上從源碼編譯安裝 Nagios Core 3.2.3 與 Plugins 1.4.15 的完整流程,含用戶權限、Web 界面配置、插件編譯、SELinux 處理及驗證步驟。
yum -y install gcc gd gd-devel httpd php # 創建用戶組 useradd nagios && usermod -s /sbin/nologin nagios groupadd nagcmd usermod -G nagcmd nagios usermod -G nagcmd apache
cd /usr/local/src wget https://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz tar xzf nagios-3.2.3.tar.gz && cd nagios-3.2.3 ./configure --with-command-group=nagcmd make all && make install && make install-init && make install-config make install-commandmode && make install-webconf
tar xzf nagios-plugins-1.4.15.tar.gz && cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make && make install
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadminvim /usr/local/nagios/etc/objects/contacts.cfgchkconfig --add nagios && chkconfig nagios on chkconfig httpd on service httpd restart && service nagios start
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgchcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ # 或永久關閉:vim /etc/selinux/config 設置 SELINUX=disabled
瀏覽器打開 https://IP/nagios,使用 nagiosadmin 登錄即可進入監控儀表盤。