Nagios是一个用于监控系统、网络和基础设施的开源监控工具。下面是如何安装和配置Nagios的简单步骤:
安装Nagios:首先,安装Nagios的依赖项:sudo apt-get updatesudo 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.gzcd nagios-4.4.6
编译和安装Nagios:./configure --with-command-group=nagcmdmake allsudo make installsudo make install-initsudo make install-commandmodesudo make install-configsudo make install-webconfsudo make install-exfoliationsudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin # 创建一个用户并设置密码
安装Nagios插件:下载最新的Nagios插件软件包:wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
解压下载的插件软件包并进入解压后的目录:tar -zxvf nagios-plugins-2.3.3.tar.gzcd nagios-plugins-2.3.3
编译和安装插件:./configure --with-nagios-user=nagios --with-nagios-group=nagiosmakesudo make install
配置Nagios:修改Nagios配置文件以添加要监控的主机或服务:sudo vi /usr/local/nagios/etc/nagios.cfg
添加主机或服务的配置文件到Nagios配置目录:sudo vi /usr/local/nagios/etc/objects/hosts.cfgsudo vi /usr/local/nagios/etc/objects/services.cfg
检查Nagios配置文件的语法是否正确:sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
启动Nagios:启动Nagios服务:sudo systemctl start nagios
设置Nagios服务开机自启动:sudo systemctl enable nagios
访问Nagios Web界面:打开浏览器并输入Nagios Web界面的地址:http://your_server_ip/nagios使用之前创建的用户和密码登录Nagios Web界面至此,您已经完成了Nagios的安装和配置。您可以通过Nagios监控和管理您的系统、网络和基础设施。