Nagios是一個用于監控系統、網絡和基礎設施的開源監控工具。下面是如何安裝和配置Nagios的簡單步驟:
首先,安裝Nagios的依賴項: sudo apt-get update sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev
下載最新的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: ./configure --with-command-group=nagcmd make all sudo make install sudo make install-init sudo make install-commandmode sudo make install-config sudo make install-webconf sudo make install-exfoliation sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin # 創建一個用戶并設置密碼
下載最新的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
編譯和安裝插件: ./configure --with-nagios-user=nagios --with-nagios-group=nagios make sudo make install
修改Nagios配置文件以添加要監控的主機或服務: sudo vi /usr/local/nagios/etc/nagios.cfg
添加主機或服務的配置文件到Nagios配置目錄: sudo vi /usr/local/nagios/etc/objects/hosts.cfg sudo vi /usr/local/nagios/etc/objects/services.cfg
檢查Nagios配置文件的語法是否正確: sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
啟動Nagios服務: sudo systemctl start nagios
設置Nagios服務開機自啟動: sudo systemctl enable nagios
至此,您已經完成了Nagios的安裝和配置。您可以通過Nagios監控和管理您的系統、網絡和基礎設施。