安装

首先我们从 nagios-plugins 开始,我们需要下载它并从源代码编译它。
如下所示,我使用 wget 命令获得了一份副本,将其解压缩并解压。

wget http://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
gunzip nagios-plugins-2.0.3.tar.gz
tar -xvf nagios-plugins-2.0.3.tar

这会将内容提取到新创建的 nagios-plugins-2.0.3 目录中,进入该目录并尝试运行配置脚本。

# ./configure
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to disable maintainer-specific portions of Makefiles... yes
checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/nagios-plugins-2.0.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

它不起作用,因为在此示例中,我们的服务器上尚未安装 GCC,请使用以下命令安装它。

pkg install gcc-3

一旦完成,我们可能仍会收到相同的错误,或者如果我们已经安装了 GCC,我们也可能会收到相同的错误。
运行以下命令将 GCC 添加到 $PATH。

PATH=$PATH:/usr/bin:/usr/sbin:/usr/sfw/bin/
export $PATH

在我的实例中,我的 $PATH 已经是 /usr/bin:/usr/sbin 并且我想添加 /usr/sfw/bin/ 因为这是 GCC 在我的安装中的位置。
我们可以通过运行“echo $PATH”来确认路径。

现在你已经有了 GCC 并且 $PATH 已经正确设置,运行下面的命令来配置、制作和安装 nagios-plugins。

./configure
make
make install

我们应该能够通过运行以下命令进行测试,如果 nagios-plugins 正常工作,它应该返回服务器磁盘空间的结果。

/usr/local/nagios/libexec/check_disk -w 10 -c 5 -p /

要正确使用它,请运行以下命令以创建稍后将使用的 nagios 用户和组。

useradd -d /usr/local/nagios -m nagios
groupadd nagios
chown nagios:nagios /usr/local/nagios/
chown -R nagios:nagios /usr/local/nagios/libexec/

现在 nagios-plugins 已编译并可以使用,我们将对 NRPE 执行相同操作,如下所示下载并解压缩。

wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
gunzip nrpe-2.15.tar.gz
tar -xvf nrpe-2.15.tar

这将创建一个 nrpe-2.15 目录,输入它并运行以下配置命令。
configure 命令指定使用 SSL,如果没有这个,我发现 Nagios 会返回关于 SSL 的握手错误。

./configure --enable-ssl --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib
make
make install
cd ./src/; make ; cd ..
make install-daemon-config

现在安装了 NRPE,我们需要对其进行配置,这主要涉及编辑 /usr/local/nagios/etc/nrpe.cfg 文件并设置 allowed_hosts 变量以包含 nagios 服务器的 IP 地址,以便允许检查天然橡胶。

接下来编辑 /etc/services 并将以下内容添加到文件中。

nrpe            5666/tcp                        # NRPE

现在编辑 /etc/inet/inetd.conf 并将以下内容添加到文件中。
tcpd 位置可能会有所不同。

nrpe stream tcp nowait nagios /usr/sbin/tcpd /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -i

接下来运行这些命令。

inetconv
inetconv -e

使用此命令确认服务正在运行,它还显示了自 3 月 20 日启动以来 nrpe 一直在运行的此实例中的输出。

svcs svc:/network/nrpe/tcp:default
STATE          STIME    FMRI
online         Mar_20   svc:/network/nrpe/tcp:default

确认 NRPE 正在正确侦听端口 5666.

netstat -a | grep nrpe
      *.nrpe               *.*                0      0 128000      0 LISTEN

运行它以启用 tcp_wrappers。

inetadm -m svc:/network/nrpe/tcp:default tcp_wrappers=TRUE

然后,我们可以使用此命令确认它已正确设置。

inetadm -l svc:/network/nrpe/tcp:default
为 Solaris 11.2 编译 NRPE 和 nagios-plugins
日期:2020-07-07 20:57:05 来源:oir作者:oir