Linux Nagios - 连接被拒绝和套接字超时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12088830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:08:53  来源:igfitidea点击:

Nagios - Connection refused & Socket timeout

linuxnagios

提问by Manroop

I need to monitor windows services(like CPU load, memory usage etc.), so I have installed Nagios monitoring tool. The installation is complete and 'check_nt' plugin is also installed. Upto this no error is there, but while executing scripts with agent NSClient++ 'Connection refused by host' error still persists.

我需要监控 Windows 服务(如 CPU 负载、内存使用等),所以我安装了 Nagios 监控工具。安装完成,“check_nt”插件也安装了。到目前为止,没有错误,但是在使用代理 NSClient++ 执行脚本时,“主机拒绝连接”错误仍然存​​在。

./check_nt -H 10.112.32.78 -p 1248 -v MEMUSE -w 80 -c 90
              Connection refused by host

./check_nt -H 10.112.32.78 -p 1248 -v MEMUSE -w 80 -c 90
              Socket timeout after 10 seconds


I have verified that nagios is working correctly, as under.

我已经验证 nagios 工作正常,如下所示。

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 3.4.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 05-11-2012
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
    Checked 8 services.
Checking hosts...
    Checked 1 hosts.
Checking host groups...
    Checked 1 host groups.
Checking service groups...
    Checked 0 service groups.
Checking contacts...
    Checked 1 contacts.
Checking contact groups...
    Checked 1 contact groups.
Checking service escalations...
    Checked 0 service escalations.
Checking service dependencies...
    Checked 0 service dependencies.
Checking host escalations...
    Checked 0 host escalations.
Checking host dependencies...
    Checked 0 host dependencies.
Checking commands...
    Checked 24 commands.
Checking time periods...
    Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

M new to nagios, thanks in advance :)

M nagios 新手,提前致谢:)

采纳答案by Michael Guthrie

The connection is getting blocked either by a firewall or your Nagios server is not in the nsc.ini file in the "allowed hosts" field. Make sure that port is open on your windows firewall, as well as any other net filters in between your Nagios server and your client.

连接被防火墙阻止,或者您的 Nagios 服务器不在“允许的主机”字段中的 nsc.ini 文件中。确保 Windows 防火墙上的端口以及 Nagios 服务器和客户端之间的任何其他网络过滤器是打开的。

回答by Horaasje

Make sure your Windows server/host you want to monitor is listening on port 5666 for NRPE and 12489 for NT by issuing this command in Windows cmd :

通过在 Windows cmd 中发出以下命令,确保要监视的 Windows 服务器/主机正在侦听 NRPE 的端口 5666 和 NT 的 12489 端口:

netstat -aon | findstr 5666
netstat -aon | findstr 12489

It could be that the Windows Firewall is also denying connections on these ports, have a look at that to.

可能是 Windows 防火墙也拒绝这些端口上的连接,看看那个。

Also add the ip address of your Nagios Monitoring Server to the allowed_hosts of your NSClient++ configuration file located here :

还要将 Nagios 监控服务器的 IP 地址添加到位于此处的 NSClient++ 配置文件的 allowed_hosts 中:

C:\Program Files\NSClient++

Also during the installation of NSClient++ there was a check-box for check_nt, make sure you checked that too during installation.

同样在安装 NSClient++ 的过程中,有一个 check_nt 复选框,请确保您在安装过程中也选中了它。

After editting configuration files from NSClient++ make sure you restart the NSClient++ service. (in services.msc or Start>Programs>NSClient++>Stop NSClient++ and then Start>Programs>NSClient++>Start NSClient++)

从 NSClient++ 编辑配置文件后,请确保重新启动 NSClient++ 服务。(在 services.msc 或开始>程序>NSClient++>停止NSClient++然后开始>程序>NSClient++>启动NSClient++)

回答by user2414854

http://pc-freak.net/blog/monitoring-windows-hosts-with-nagios-on-debian-gnulinux/

http://pc-freak.net/blog/monitoring-windows-hosts-with-nagios-on-debian-gnulinux/

Depending on your flavor of linux the commands are easily googled for.

根据您的 linux 风格,这些命令很容易在 google 上搜索。

Install necessery nagios debian packages

安装必要的 nagios debian 软件包

apt-get install nagios-images nagios-nrpe-plugin nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard nagios3 nagios3-cgi nagios3-common nagios3-core

apt-get install nagios-images nagios-nrpe-plugin nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard nagios3 nagios3-cgi nagios3-common nagios3-core

回答by Raymond Lui

I just came across an issue with this with centos 7. After a few hours of searching and comparing with other servers on the same network, I was ready to give up

我刚刚在centos 7上遇到了这个问题。经过几个小时的搜索并与同一网络上的其他服务器进行比较后,我准备放弃了

I literally compared the nrpe.cfg between both, definitely had the IP for allowed host, and all plugins were rsync'd, permissions were all the same. One problem I had was telnetting to the nrpe port 5666

我从字面上比较了两者之间的 nrpe.cfg,肯定有允许主机的 IP,并且所有插件都是 rsync 的,权限都是一样的。我遇到的一个问题是远程登录到 nrpe 端口 5666

telnet working_server_ip 5666 works

telnet working_server_ip 5666 有效

telnet not_working_server_ip 5666 connection refused.

telnet not_working_server_ip 5666 连接被拒绝。

Took me a while but I somehow came across the two OS, the one working is centos6, while the other is centos7.

花了我一段时间,但我以某种方式遇到了两个操作系统,一个是centos6,另一个是centos7。

If you are installing nrpe on centos7, make sure you disable the firewall and I am not talking about SELinux

如果您在 centos7 上安装 nrpe,请确保禁用防火墙,我不是在谈论 SELinux

systemctl stop firewalld

systemctl 停止 firewalld

and then try again

然后再试一次