Nagios是一个开源监视工具,用于监视不同的Linux计算机或不同的客户端主机。它监视HTTP,FTP,SSH,SMTP等以及CPU使用率,RAM,磁盘使用率和正在运行的不同进程。
在Ubuntu 20.04 LTS Focal Fossa上安装Nagios
步骤1.首先通过在终端中运行以下apt命令,确保所有系统软件包都是最新的。
sudo apt update sudo apt upgrade sudo apt install build-essential apache2 php openssl perl make php-gd libgd-dev libapache2-mod-php libperl-dev libssl-dev daemon wget apache2-utils unzip
步骤2.创建用户和组。
将用户添加到Apache Web服务器组:
sudo useradd nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios sudo usermod -a -G nagcmd www-data
步骤3.在Ubuntu 20.04上安装Nagios。
现在,从官方页面下载Nagios,或者通过终端通过以下命令获取它:
cd /tmp wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz tar -zxvf /tmp/nagios-4.4.5.tar.gz cd /tmp/nagios-4.4.5/
然后,从源代码编译Nagios:
sudo ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/ sudo make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode
步骤4.配置Nagios。
Nagios将配置文件放在etc目录中。现在,在您最喜欢的编辑器的帮助下,编辑文件:/usr/local/nagios/
sudo nano /usr/local/nagios/etc/objects/contacts.cfg
更改电子邮件地址字段以接收通知:
define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email admin@idroot.us ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }
步骤5.安装Nagios Web界面。
使用以下命令安装Nagios Web界面:
sudo make install-webconf
然后创建一个用户帐户“ nagiosadmin”以访问Nagios Web界面。确保将您提供的密码保存在安全的地方,或者记住,以后将需要使用该密码:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
之后,运行以下命令:
sudo a2enmod cgi
接下来,重新启动Apache以使更改生效:
sudo systemctl restart apache2
步骤6.安装Nagios插件。
下一步,下载最新的nagios-plugins源并使用以下命令进行安装:
cd /tmp wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz tar -zxvf /tmp/nagios-plugins-2.3.3.tar.gz cd /tmp/nagios-plugins-2.3.3/
编译并安装插件:
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios sudo make sudo make install
步骤7.在Ubuntu 20.04上启动Nagios。
敲击给定命令,仔细检查上述配置,并确保所有配置预检查均正确:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Output: Nagios Core 4.4.5 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2019-08-20 License: GPL Website: https://www.nagios.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 8 services. Checked 1 hosts. Checked 1 host groups. Checked 0 service groups. Checked 1 contacts. Checked 1 contact groups. Checked 24 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 1 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0
然后,启用Nagios服务以在系统启动时自动启动:
sudo systemctl enable nagios
sudo systemctl start nagios
步骤8.访问Nagios。
默认情况下,Nagios将在HTTP端口80上可用。打开您喜欢的浏览器,然后浏览至或完成所需的步骤以完成安装。当提示您输入用户名和密码时,将引入用户名“ nagiosadmin”和您在步骤5中输入的密码。http://your-domain.com/nagios
http://your-server-ip/nagios
恭喜你!您已经成功安装了Nagios。感谢您使用本教程在Ubuntu 20.04 LTS(Focal Fossa)系统中安装Nagios监视工具。有关其他帮助或有用信息,我们建议您检查Nagios官方网站。
原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/Yun43994.html