以下是安裝和配置Nagios的步驟:
安裝必要的軟件包:
sudo apt-get update
sudo apt-get install build-essential libgd2-xpm-dev openssl libssl-dev xinetd apache2 php libapache2-mod-php php-gd
sudo yum install gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
創(chuàng)建Nagios用戶:
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagios apache
下載Nagios核心軟件包:
解壓和編譯Nagios軟件包:
tar -xzf nagios-x.x.x.tar.gz
cd nagios-x.x.x
./configure --with-command-group=nagcmd
make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
sudo make install-webconf
創(chuàng)建Nagios管理員賬戶:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
安裝并配置Nagios插件:
tar -xzf nagios-plugins-x.x.x.tar.gz
cd nagios-plugins-x.x.x
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install
配置Nagios:
sudo vi /usr/local/nagios/etc/nagios.cfg
#cfg_dir=/usr/local/nagios/etc/servers
sudo mkdir /usr/local/nagios/etc/servers
define host {
use linux-server
host_name localhost
alias My localhost server
address 127.0.0.1
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
啟動(dòng)Nagios服務(wù):
sudo service nagios start
sudo systemctl start nagios
配置Nagios Web界面:
sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
sudo systemctl restart apache2
sudo ln -s /etc/httpd/conf.d/nagios.conf /etc/httpd/conf.d/nagios.conf
sudo systemctl restart httpd
訪問Nagios Web界面: