瑞尔 | 中央操作系统 | 甲骨文Linux
安全增强型 Linux
本指南基于 SELinux 被禁用或处于宽容模式。执行此操作的步骤如下。
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
先决条件
执行这些步骤以安装先决条件包。
===== RHEL 5/6/7 | 中央操作系统 5/6/7 | 甲骨文 Linux 5/6/7 =====
yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
yum install openssl-devel
===== RHEL 8 | 中央操作系统 8 | CentOS 流 8=====
dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel
dnf install openssl-devel
dnf update -y
下载源代码
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
tar xzf nagioscore.tar.gz
编译
cd /tmp/nagioscore-nagios-4.4.6/
./configure
make all
创建用户和组
这将创建nagios用户和组。apache用户也被添加到nagios组中。
制作安装组用户
usermod -a -G nagios apache
安装二进制文件
此步骤安装二进制文件、CGI 和 HTML 文件。
make install
首页» 分类 »产品» Nagios Core »安装
Nagios Core - 从源代码安装 Nagios Core
文章编号:96 | 评分:4.3/5 来自 55 票 | 最后更新者rspielman于 2022 年 4 月 15 日星期五上午 10:27-> 编辑文章 <-
从源代码安装 Nagios Core
本文档描述了如何从源代码安装 Nagios Core。
本指南分为几个部分,涵盖不同的操作系统 (OS) 发行版。如果您的操作系统分发版未包含在本指南中,请联系我们,看看我们是否可以添加它。某些发行版可能会丢失,因为我们无法访问允许我们开发文档的测试环境。
Nagios Core 4.4.6 和 Nagios Plugins 2.3.3 是本指南中使用的版本,但是未来的版本也应该可以很好地执行这些步骤。
注意:从 Nagios Core 4.4.7 开始,openssl 是必需的先决条件。此命令已添加到以下更流行的发行版(CentOS、RHEL、Ubuntu 等)的文档中。如果您使用的是其他发行版(Solaris、Gentoo 等),则需要在先决条件部分运行适当的命令来安装 openssl。
本文档分为两个不同的部分:
安装 Nagios 核心
安装 Nagios 插件
这种分离是为了明确区分安装它的操作系统需要哪些先决条件包。例如,SNMP 包作为 Nagios 插件部分的一部分安装,因为 Nagios Core 不需要 SNMP。
请选择您的操作系统:
红帽企业 Linux (RHEL)
中央操作系统
甲骨文Linux
Ubuntu
SUSE 软件 | openSUSE Leap
德比安
树莓派
软呢帽
架构Linux
Gentoo
FreeBSD
索拉里斯
苹果操作系统
瑞尔 | 中央操作系统 | 甲骨文Linux
安全增强型 Linux
本指南基于 SELinux 被禁用或处于宽容模式。执行此操作的步骤如下。
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
先决条件
执行这些步骤以安装先决条件包。
===== RHEL 5/6/7 | 中央操作系统 5/6/7 | 甲骨文 Linux 5/6/7 =====
yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
yum install openssl-devel
===== RHEL 8 | 中央操作系统 8 | CentOS 流 8=====
dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel
dnf install openssl-devel
dnf update -y
下载源代码
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
tar xzf nagioscore.tar.gz
编译
cd /tmp/nagioscore-nagios-4.4.6/
./configure
make all
创建用户和组
这将创建nagios用户和组。apache用户也被添加到nagios组中。
make install-groups-users
usermod -a -G nagios apache
安装二进制文件
此步骤安装二进制文件、CGI 和 HTML 文件。
make install
安装服务/守护进程
这将安装服务或守护程序文件,并将它们配置为在引导时启动。Apache httpd服务也在此时配置。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
make install-daemoninit
chkconfig --level 2345 httpd on
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentoOS 流 8=====
make install-daemoninit
systemctl enable httpd.service
有关启动和停止服务的信息将在后面进一步解释。
安装命令模式
这将安装和配置外部命令文件。
make install-commandmode
安装配置文件
这将安装 *SAMPLE* 配置文件。这些是必需的,因为 Nagios 需要一些配置文件才能启动。
make install-config
安装 Apache 配置文件
这将安装 Apache Web 服务器配置文件。如果需要,还可以配置 Apache 设置。
make install-webconf
配置防火墙
您需要在本地防火墙上允许端口 80 入站流量,以便您可以访问 Nagios Core Web 界面。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT
service iptables save
ip6tables -I INPUT -p tcp --destination-port 80 -j ACCEPT
service ip6tables save
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent
创建 nagiosadmin 用户帐户
您需要创建一个 Apache 用户帐户才能登录 Nagios。
以下命令将创建一个名为 nagiosadmin 的用户帐户,系统将提示您提供该帐户的密码。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 123456
启动 Apache Web 服务器
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
service httpd start
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
systemctl start httpd.service
启动服务/守护进程
此命令启动 Nagios Core。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
service nagios start
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
systemctl start nagios.service
测试 Nagios
Nagios 现在正在运行,要确认这一点,您需要登录到 Nagios Web 界面。
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
系统将提示您输入用户名和密码。用户名是nagiosadmin(您在前面的步骤中创建了它),密码是您之前提供的。
登录后,您将看到 Nagios 界面。恭喜你安装了 Nagios Core。
可是等等 ...
目前你只安装了 Nagios Core 引擎。您会注意到主机和服务下的一些错误,大致如下:
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_load, ...) failed. errno is 2: No such file or directory
安装 Nagios 插件后,这些错误将得到解决,这将在下一步中介绍。
安装 Nagios 插件
Nagios Core 需要插件才能正常运行。以下步骤将引导您完成安装 Nagios 插件。
先决条件
确保您安装了以下软件包。
===== 中央操作系统 5 =====
yum install -y gcc glibc glibc-common make gettext automake wget openssl-devel net-snmp net-snmp-utils epel-release
yum install -y perl-Net-SNMP
cd /tmp
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz
tar xzf autoconf-2.60.tar.gz
cd /tmp/autoconf-2.60
./configure
make
make install
===== 中央操作系统 6/7 =====
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum install -y perl-Net-SNMP
===== 中央操作系统 8 | CentOS 流 8=====
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum --enablerepo=powertools,epel install perl-Net-SNMP
===== RHEL 5 | 甲骨文 Linux 5 =====
cd /tmp
wget http://archives.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm
rpm -ihv epel-release-latest-5.noarch.rpm
yum install -y gcc glibc glibc-common make gettext automake wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz
tar xzf autoconf-2.60.tar.gz
cd /tmp/autoconf-2.60
./configure
make
make install
===== RHEL 6 | 甲骨文 Linux 6 =====
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ihv epel-release-latest-6.noarch.rpm
yum install -y gcc glibc glibc -common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
===== RHEL 7 =====
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ihv epel-release-latest-7.noarch.rpm
subscription-manager repos --enable =rhel-7-server-optional-rpms
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
===== 瑞尔 8 =====
在撰写本文时,用于 RHEL 8 的 EPEL 尚未发布,受影响的命令已删除,但如果 EPEL 8 可用,则*应该*有效
# cd /tmp
# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# rpm -ihv epel-release-latest-8.noarch.rpm
# subscription-manager repos --enable=rhel-8-server-optional-rpms
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
# yum install -y perl-Net-SNMP
=====甲骨文Linux 7 =====
yum install -y yum-utils
yum-config-manager --enable ol7_optional_latest
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ihv epel-release-latest-7.noarch.rpm
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
=====甲骨文Linux 8 =====
yum install -y yum-utils
yum-config-manager --enable ol8_optional_latest
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -ihv epel- release-latest-8.noarch.rpm
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum 安装-y perl-Net-SNMP
下载源代码
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
tar zxf nagios -plugins.tar.gz
编译+安装
cd /tmp/nagios-plugins-release-2.3.3/
./tools/setup
./configure
make
make install
测试插件
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
转到主机或服务对象,然后在“命令”菜单下“重新安排下一次检查”。您之前看到的错误现在应该消失了,正确的输出将显示在屏幕上。
服务/守护进程命令
不同的 Linux 发行版有不同的启动/停止/重新启动/状态 Nagios 的方法。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
service nagios start
service nagios stop
service nagios restart
service nagios status
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
systemctl start nagios.service
systemctl stop nagios.service
systemctl restart nagios.service
systemctl status nagios.service
Ubuntu
安全增强型 Linux
本指南基于 SELinux 被禁用或处于宽容模式。SELinux 在 Ubuntu 上默认不启用。如果您想查看它是否已安装,请运行以下命令:
sudo dpkg -l selinux*
先决条件
执行这些步骤以安装先决条件包。
===== Ubuntu 14.x / 15.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 apache2-utils php5 libgd2-xpm-dev
===== Ubuntu 16.x / 17.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev
===== Ubuntu 18.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev
===== Ubuntu 20.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev
sudo apt-get install openssl libssl-dev
下载源代码
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
tar xzf nagioscore.tar.gz
编译
cd /tmp/nagioscore-nagios-4.4.6/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
创建用户和组
这将创建nagios用户和组。www -data用户也被添加到nagios组中。
sudo make install-groups-users
sudo usermod -a -G nagios www-data
安装二进制文件
此步骤安装二进制文件、CGI 和 HTML 文件。
sudo make install
安装服务/守护进程
这将安装服务或守护程序文件,并将它们配置为在引导时启动。
sudo make install-daemoninit
有关启动和停止服务的信息将在后面进一步解释。
安装命令模式
这将安装和配置外部命令文件。
sudo make install-commandmode
安装配置文件
这将安装 *SAMPLE* 配置文件。这些是必需的,因为 Nagios 需要一些配置文件才能启动。
sudo make install-config
安装 Apache 配置文件
这将安装 Apache Web 服务器配置文件并配置 Apache 设置。
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi
配置防火墙
您需要在本地防火墙上允许端口 80 入站流量,以便您可以访问 Nagios Core Web 界面。
sudo ufw allow Apache
sudo ufw reload
创建 nagiosadmin 用户帐户
您需要创建一个 Apache 用户帐户才能登录 Nagios。
以下命令将创建一个名为 nagiosadmin 的用户帐户,系统将提示您提供该帐户的密码。
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
启动 Apache Web 服务器
===== Ubuntu 14.x =====
需要重新启动它,因为它已经在运行。
sudo service apache2 restart
===== Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x =====
需要重新启动它,因为它已经在运行。
sudo systemctl restart apache2.service
启动服务/守护进程
此命令启动 Nagios Core。
===== Ubuntu 14.x =====
sudo start nagios
===== Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x =====
sudo systemctl start nagios.service
测试 Nagios
Nagios 现在正在运行,要确认这一点,您需要登录到 Nagios Web 界面。
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
系统将提示您输入用户名和密码。用户名是nagiosadmin(您在前面的步骤中创建了它),密码是您之前提供的。
登录后,您将看到 Nagios 界面。恭喜你安装了 Nagios Core。
可是等等 ...
目前你只安装了 Nagios Core 引擎。您会注意到主机和服务下的一些错误,大致如下:
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_load, ...) failed. errno is 2: No such file or directory
安装 Nagios 插件后,这些错误将得到解决,这将在下一步中介绍。
安装 Nagios 插件
Nagios Core 需要插件才能正常运行。以下步骤将引导您完成安装 Nagios 插件。
扩张 类别 支持选项 (8)
首页» 分类 »产品» Nagios Core »安装
Nagios Core - 从源代码安装 Nagios Core
文章编号:96 | 评分:4.3/5 来自 55 票 | 最后更新者rspielman于 2022 年 4 月 15 日星期五上午 10:27-> 编辑文章 <-
从源代码安装 Nagios Core
本文档描述了如何从源代码安装 Nagios Core。
本指南分为几个部分,涵盖不同的操作系统 (OS) 发行版。如果您的操作系统分发版未包含在本指南中,请联系我们,看看我们是否可以添加它。某些发行版可能会丢失,因为我们无法访问允许我们开发文档的测试环境。
Nagios Core 4.4.6 和 Nagios Plugins 2.3.3 是本指南中使用的版本,但是未来的版本也应该可以很好地执行这些步骤。
注意:从 Nagios Core 4.4.7 开始,openssl 是必需的先决条件。此命令已添加到以下更流行的发行版(CentOS、RHEL、Ubuntu 等)的文档中。如果您使用的是其他发行版(Solaris、Gentoo 等),则需要在先决条件部分运行适当的命令来安装 openssl。
本文档分为两个不同的部分:
安装 Nagios 核心
安装 Nagios 插件
这种分离是为了明确区分安装它的操作系统需要哪些先决条件包。例如,SNMP 包作为 Nagios 插件部分的一部分安装,因为 Nagios Core 不需要 SNMP。
请选择您的操作系统:
红帽企业 Linux (RHEL)
中央操作系统
甲骨文Linux
Ubuntu
SUSE 软件 | openSUSE Leap
德比安
树莓派
软呢帽
架构Linux
Gentoo
FreeBSD
索拉里斯
苹果操作系统
瑞尔 | 中央操作系统 | 甲骨文Linux
安全增强型 Linux
本指南基于 SELinux 被禁用或处于宽容模式。执行此操作的步骤如下。
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
先决条件
执行这些步骤以安装先决条件包。
===== RHEL 5/6/7 | 中央操作系统 5/6/7 | 甲骨文 Linux 5/6/7 =====
yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
yum install openssl-devel
===== RHEL 8 | 中央操作系统 8 | CentOS 流 8=====
dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel
dnf install openssl-devel
dnf update -y
下载源代码
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
tar xzf nagioscore.tar.gz
编译
cd /tmp/nagioscore-nagios-4.4.6/
./configure
make all
创建用户和组
这将创建nagios用户和组。apache用户也被添加到nagios组中。
制作安装组用户
usermod -a -G nagios apache
安装二进制文件
此步骤安装二进制文件、CGI 和 HTML 文件。
安装
安装服务/守护进程
这将安装服务或守护程序文件,并将它们配置为在引导时启动。Apache httpd服务也在此时配置。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
make install-daemoninit
chkconfig --level 2345 httpd on
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentoOS 流 8=====
make install-daemoninit
systemctl 启用 httpd.service
有关启动和停止服务的信息将在后面进一步解释。
安装命令模式
这将安装和配置外部命令文件。
使安装命令模式
安装配置文件
这将安装 *SAMPLE* 配置文件。这些是必需的,因为 Nagios 需要一些配置文件才能启动。
进行安装配置
安装 Apache 配置文件
这将安装 Apache Web 服务器配置文件。如果需要,还可以配置 Apache 设置。
安装-webconf
配置防火墙
您需要在本地防火墙上允许端口 80 入站流量,以便您可以访问 Nagios Core Web 界面。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT
服务 iptables 保存
ip6tables -I INPUT -p tcp --destination-port 80 -j ACCEPT
服务 ip6tables 保存
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent
创建 nagiosadmin 用户帐户
您需要创建一个 Apache 用户帐户才能登录 Nagios。
以下命令将创建一个名为 nagiosadmin 的用户帐户,系统将提示您提供该帐户的密码。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
将来添加其他用户时,您需要从上述命令中删除-c,否则它将替换现有的 nagiosadmin 用户(以及您可能已添加的任何其他用户)。
启动 Apache Web 服务器
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
服务 httpd 启动
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
systemctl 启动httpd.service
启动服务/守护进程
此命令启动 Nagios Core。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
服务nagios启动
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
systemctl 启动nagios.service
测试 Nagios
Nagios 现在正在运行,要确认这一点,您需要登录到 Nagios Web 界面。
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
系统将提示您输入用户名和密码。用户名是nagiosadmin(您在前面的步骤中创建了它),密码是您之前提供的。
登录后,您将看到 Nagios 界面。恭喜你安装了 Nagios Core。
可是等等 ...
目前你只安装了 Nagios Core 引擎。您会注意到主机和服务下的一些错误,大致如下:
(标准输出无输出)标准错误:execvp(/usr/local/nagios/libexec/check_load, ...) 失败。errno 为 2:没有那个文件或目录
安装 Nagios 插件后,这些错误将得到解决,这将在下一步中介绍。
安装 Nagios 插件
Nagios Core 需要插件才能正常运行。以下步骤将引导您完成安装 Nagios 插件。
这些步骤安装 nagios-plugins 2.3.3。将来会提供更新的版本,您可以在以下安装步骤中使用这些版本。有关所有可用版本,请参阅GitHub 上的发布页面。
请注意,以下步骤会安装 Nagios 插件包中的大部分插件。但是,有些插件需要这些说明中未包含的其他库。详细安装说明请参考以下知识库文章:
文档 - 从源代码安装 Nagios 插件
先决条件
确保您安装了以下软件包。
===== 中央操作系统 5 =====
yum 安装 -y gcc glibc glibc-common make gettext automake wget openssl-devel net-snmp net-snmp-utils epel-release
yum install -y perl-Net-SNMP
cd /tmp
wget http://ftp.gnu.org/ gnu/autoconf/autoconf-2.60.tar.gz
tar xzf autoconf-2.60.tar.gz
cd /tmp/autoconf-2.60
./configure
make
make install
===== 中央操作系统 6/7 =====
yum 安装 -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum install -y perl-Net-SNMP
===== 中央操作系统 8 | CentOS 流 8=====
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum --enablerepo=powertools,epel 安装 perl-Net-SNMP
===== RHEL 5 | 甲骨文 Linux 5 =====
cd /tmp
wget http://archives.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm
rpm -ihv epel-release-latest-5.noarch.rpm
yum install -y gcc glibc glibc-common make gettext automake wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz
tar xzf autoconf-2.60.tar.gz
cd /tmp/autoconf-2.60
./configure
make
make install
===== RHEL 6 | 甲骨文 Linux 6 =====
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ihv epel-release-latest-6.noarch.rpm
yum install -y gcc glibc glibc -common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
===== RHEL 7 =====
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ihv epel-release-latest-7.noarch.rpm
subscription-manager repos --enable =rhel-7-server-optional-rpms
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
===== 瑞尔 8 =====
在撰写本文时,用于 RHEL 8 的 EPEL 尚未发布,受影响的命令已删除,但如果 EPEL 8 可用,则*应该*有效。
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -ihv epel-release-latest-8.noarch.rpm 订阅
管理器 repos --enable =rhel-8-server-optional-rpms
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum install -y perl-Net-SNMP
=====甲骨文Linux 7 =====
yum install -y yum-utils
yum-config-manager --enable ol7_optional_latest
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ihv epel- release-latest-7.noarch.rpm
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum 安装-y perl-Net-SNMP
=====甲骨文Linux 8 =====
yum install -y yum-utils
yum-config-manager --enable ol8_optional_latest
cd /tmp
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -ihv epel- release-latest-8.noarch.rpm
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
yum 安装-y perl-Net-SNMP
下载源代码
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
tar zxf nagios -plugins.tar.gz
编译+安装
cd /tmp/nagios-plugins-release-2.3.3/
./tools/setup
./configure
make
make install
测试插件
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
转到主机或服务对象,然后在“命令”菜单下“重新安排下一次检查”。您之前看到的错误现在应该消失了,正确的输出将显示在屏幕上。
服务/守护进程命令
不同的 Linux 发行版有不同的启动/停止/重新启动/状态 Nagios 的方法。
===== RHEL 5/6 | 中央操作系统 5/6 | 甲骨文 Linux 5/6 =====
服务nagios 启动
服务nagios 停止
服务nagios 重新启动
服务nagios 状态
===== RHEL 7/8 | 中央操作系统 7/8 | 甲骨文 Linux 7/8 | CentOS 流 8=====
systemctl 启动nagios.service
systemctl 停止nagios.service
systemctl 重新启动nagios.service
systemctl 状态nagios.service
Ubuntu
安全增强型 Linux
本指南基于 SELinux 被禁用或处于宽容模式。SELinux 在 Ubuntu 上默认不启用。如果您想查看它是否已安装,请运行以下命令:
sudo dpkg -l selinux*
先决条件
执行这些步骤以安装先决条件包。
===== Ubuntu 14.x / 15.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 apache2-utils php5 libgd2-xpm-dev
===== Ubuntu 16.x / 17.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev
===== Ubuntu 18.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev
===== Ubuntu 20.x =====
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev
sudo apt-get install openssl libssl-dev
下载源代码
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz
tar xzf nagioscore.tar.gz
编译
cd /tmp/nagioscore-nagios-4.4.6/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
创建用户和组
这将创建nagios用户和组。www -data用户也被添加到nagios组中。
sudo make install-groups-users
sudo usermod -a -G nagios www-data
安装二进制文件
此步骤安装二进制文件、CGI 和 HTML 文件。
须藤安装
安装服务/守护进程
这将安装服务或守护程序文件,并将它们配置为在引导时启动。
sudo make install-daemoninit
有关启动和停止服务的信息将在后面进一步解释。
安装命令模式
这将安装和配置外部命令文件。
须藤使安装命令模式
安装配置文件
这将安装 *SAMPLE* 配置文件。这些是必需的,因为 Nagios 需要一些配置文件才能启动。
须藤使安装配置
安装 Apache 配置文件
这将安装 Apache Web 服务器配置文件并配置 Apache 设置。
sudo make install-webconf
sudo a2enmod 重写
sudo a2enmod cgi
配置防火墙
您需要在本地防火墙上允许端口 80 入站流量,以便您可以访问 Nagios Core Web 界面。
sudo ufw 允许 Apache
sudo ufw 重新加载
创建 nagiosadmin 用户帐户
您需要创建一个 Apache 用户帐户才能登录 Nagios。
以下命令将创建一个名为 nagiosadmin 的用户帐户,系统将提示您提供该帐户的密码。
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
将来添加其他用户时,您需要从上述命令中删除-c,否则它将替换现有的 nagiosadmin 用户(以及您可能已添加的任何其他用户)。
启动 Apache Web 服务器
===== Ubuntu 14.x =====
需要重新启动它,因为它已经在运行。
sudo 服务 apache2 重新启动
===== Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x =====
需要重新启动它,因为它已经在运行。
sudo systemctl restart apache2.service
启动服务/守护进程
此命令启动 Nagios Core。
===== Ubuntu 14.x =====
须藤启动nagios
===== Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x =====
sudo systemctl 启动 nagios.service
测试 Nagios
Nagios 现在正在运行,要确认这一点,您需要登录到 Nagios Web 界面。
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
系统将提示您输入用户名和密码。用户名是nagiosadmin(您在前面的步骤中创建了它),密码是您之前提供的。
登录后,您将看到 Nagios 界面。恭喜你安装了 Nagios Core。
可是等等 ...
目前你只安装了 Nagios Core 引擎。您会注意到主机和服务下的一些错误,大致如下:
(标准输出无输出)标准错误:execvp(/usr/local/nagios/libexec/check_load, ...) 失败。errno 为 2:没有那个文件或目录
安装 Nagios 插件后,这些错误将得到解决,这将在下一步中介绍。
安装 Nagios 插件
Nagios Core 需要插件才能正常运行。以下步骤将引导您完成安装 Nagios 插件。
这些步骤安装 nagios-plugins 2.3.3。将来会提供更新的版本,您可以在以下安装步骤中使用这些版本。有关所有可用版本,请参阅GitHub 上的发布页面。
请注意,以下步骤会安装 Nagios 插件包中的大部分插件。但是,有些插件需要这些说明中未包含的其他库。详细安装说明请参考以下知识库文章:
文档 - 从源代码安装 Nagios 插件
先决条件
确保您安装了以下软件包。
sudo apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
下载源代码
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
tar zxf nagios -plugins.tar.gz
编译+安装
cd /tmp/nagios-plugins-release-2.3.3/
sudo ./tools/setup
sudo ./configure
sudo make
sudo make install
测试插件
将 Web 浏览器指向 Nagios Core 服务器的 IP 地址或 FQDN,例如:
http://10.25.5.143/nagios
http: //core-013.domain.local/nagios
转到主机或服务对象,然后在“命令”菜单下“重新安排下一次检查”。您之前看到的错误现在应该消失了,正确的输出将显示在屏幕上。
服务/守护进程命令
不同的 Linux 发行版有不同的启动/停止/重新启动/状态 Nagios 的方法。
===== Ubuntu 14.x =====
sudo start nagios
sudo stop nagios
sudo restart nagios
sudo status nagios
===== Ubuntu 15.x / 16.x / 17.x / 18.x / 20.x =====
sudo systemctl start nagios.service
sudo systemctl stop nagios.service
sudo systemctl restart nagios.service
sudo systemctl status nagios.service
5. 处理出现http警告
touch /var/www/html/index.html
yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
邮件
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
yum install -y sendmail* mailx
firewall-cmd --zone=public --add-port=25/tcp --permanent
echo "Nagios Test Email " | mail -s "Alert" 18895729286@163.com
vi /etc/nagios/nagios.cfg
vi /usr/local/nagios/etc/nagios.cfg
vi objects/contacts.cfg
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl restart network