共计 3354 个字符,预计需要花费 9 分钟才能阅读完成。
Icinga 客户端的部署相对于服务器端来说,简单很多。对于服务器端来说,如果要通过以下这种方式来监控服务器,必须包含三个组件,Icinga 内核,Icinga 插件,NRPE(Nagios Remote Plugin Executor)。对于 Icinga 客户端来说,只需要部署 Icinga 插件和 NRPE。
icinga 中文化项目的下载地址为:http://sourceforge.net/projects/icinga-cn/files/
其中,Icinga 插件,NRPE 均在 icinga plugins 目录中。
在这里,我下载了 nagios-cn-plugins-2.0.3.tar.xz 和 icinga-nrpe-2.14.tar.gz。
新建 icinga 用户
# useradd icinga -s /sbin/nologin
安装 nagios-cn-plugins
# cd /usr/src/
# tar xvf /root/nagios-cn-plugins-2.0.3.tar.xz
# cd nagios-cn-plugins-2.0.3/
# ./configure –prefix=/usr/local/icinga
最后输出如下:
config.status: creating po/Makefile | |
--with-apt-get-command: | |
--with-ping6-command: /usr/sbin/ping6 -n -U -w %d -c %d %s | |
--with-ping-command: /usr/bin/ping -n -U -w %d -c %d %s | |
--with-package-name: nagios-plugins | |
--with-nagios-user: | |
--with-nagios-group: | |
--with-ipv6: yes | |
--with-mysql: no | |
--with-openssl: yes | |
--with-gnutls: no | |
--enable-extra-opts: yes | |
--with-perl: /usr/bin/perl | |
--enable-perl-modules: no | |
--with-cgiurl: /nagios/cgi-bin | |
--with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin | |
--enable-libtap: no |
# make
# make install
设置权限
# chown -R icinga.icinga /usr/local/icinga/
安装 NRPE
# cd /usr/src/
# tar xvf /root/icinga-nrpe-2.14.tar.gz
# cd icinga-nrpe-2.14/
# ./configure
最后输出如下:
*** Configuration summary for nrpe 2.14 12-21-2012 ***: | |
General Options: | |
------------------------- | |
NRPE port: 5666 | |
NRPE user: icinga | |
NRPE group: icinga | |
Icinga user: icinga | |
Icinga group: icinga | |
Review the options above for accuracy. If they look okay, | |
type 'make all' to compile the NRPE daemon and client. |
按照提示,
# make all
输出结果如下:
*** Compile finished *** | |
make install | |
- This installs files in /usr/local/icinga | |
make install-plugin | |
- This installs init-script files in /usr/local/icinga/libexec | |
make install-init | |
- This installs init-script files in /etc/init.d | |
make install-xinetd | |
- This installs sample-config/nrpe.xinetd in /etc/xinit.d | |
make install-init-freebsd | |
- This installs init-script.freebsd files in /etc/init.d | |
make install-init-debian | |
- This installs init-script.debian files in /etc/init.d | |
make install-init-SUSE | |
- This installs init-script.suse files in /etc/init.d | |
make install-daemon-config | |
- This installs the Nrpe config file in /usr/local/icinga/etc | |
If the NRPE daemon and client compiled without any errors, you | |
can continue with the installation or upgrade process. | |
Read the PDF documentation (NRPE.pdf) for information on the next | |
steps you should take to complete the installation or upgrade. |
对于 Linux 系统,可运行 make install,make install-plugin,make install-init,make install-xinetd,make install-daemon-config。各项的具体作用可参考上述的说明。
修改 NRPE 的配置文件
# vim /usr/local/icinga/etc/nrpe.cfg
在 allowed_hosts 后面添加 Icinga 服务端的地址
allowed_hosts=127.0.0.1,192.168.244.145
启动 NRPE 服务
# /etc/init.d/icinga-nrpe start
Starting icinga-nrpe (via systemctl): Warning: Unit file of icinga-nrpe.service changed on disk, 'systemctl daemon-reload' recommended. | |
[ | ]
# systemctl daemon-reload
# /etc/init.d/icinga-nrpe start
查看 5666 端口是否开启监听
# netstat -ntlup | grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 26517/nrpe
在服务端上进行验证
# /usr/local/icinga/libexec/check_nrpe -H 192.168.244.146
其中 192.168.244.146 是客户端的地址
如果输出的是 NRPE 的版本号:
NRPE v2.14
则代表服务端和客户端已建立通信。
总结:
1. 如果在服务端上进行验证时,报以下错误:
CHECK_NRPE: Error - Could not complete SSL handshake.
一般是 NRPE 的配置文件没有修改,或防火墙规则阻止了 Icinga 服务端和 NRPE 进程之间的连接。
2. 系统账号的 shell 使用 /sbin/nologin , 此时无法登陆系统,即使给了密码也不行。
所谓“无法登陆”指的仅是这个用户无法使用 bash 或其他 shell 来登陆系统而已,并不是说这个账号就无法使用系统资源。举例来说,各个系统账号中,打印作业有 lp 这个账号管理,www 服务器有 apache 这个账号管理,他们都可以进行系统程序的工作,但就是无法登陆主机而已。有时候有些服务,比如邮件服务,大部分都是用来接收主机的邮件而已,并不需要登陆。假如有账号试图连接我的主机取得 shell,我们就可以拒绝。另外,如果我想要让某个具有 /sbin/nologin 的用户知道,他们不能登陆主机时,可以新建 /etc/nologin.txt 这个文件,在文件内面写上不能登陆的原因,当用户登录时,屏幕上就会出现这个文件里面的内容。
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-01/127381.htm
