nagios.service 启动操作超时。正在终止

nagios.service 启动操作超时。正在终止

我有一个 Centos 7 Box,上面安装了 Nagios,然后从旧的 Centos 盒中迁移了所有配置文件。

一切看起来都很好,nagios -v没有返回任何错误。

但是,systemd 无法启动服务并提示超时。以下是结果systemctl -l status nagios.service

● nagios.service - Nagios Network Monitoring
   Loaded: loaded (/usr/lib/systemd/system/nagios.service; disabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Fri 2016-02-05 10:52:55 CET; 13min ago
     Docs: https://www.nagios.org/documentation/
  Process: 2259 ExecStart=/usr/sbin/nagios -d /etc/nagios/nagios.cfg (code=exited, status=0/SUCCESS)
  Process: 2257 ExecStartPre=/usr/sbin/nagios -v /etc/nagios/nagios.cfg (code=exited, status=0/SUCCESS)

Feb 05 10:52:52 nagios.adflux.net nagios[2261]: SERVICE ALERT: VM-CRO-JIRA2;Drive Space C:;CRITICAL;SOFT;1;CRITICAL - Socket timeout after 10 seconds
Feb 05 10:52:52 nagios.adflux.net nagios[2261]: SERVICE ALERT: ESXi-ls1;PING;WARNING;SOFT;1;PING WARNING - Packet loss = 33%, RTA = 80.47 ms
Feb 05 10:52:55 nagios.adflux.net systemd[1]: nagios.service start operation timed out. Terminating.
Feb 05 10:52:55 nagios.adflux.net nagios[2261]: Caught SIGTERM, shutting down...
Feb 05 10:52:55 nagios.adflux.net nagios[2268]: Caught SIGTERM, shutting down...
Feb 05 10:52:55 nagios.adflux.net nagios[2261]: Successfully shutdown... (PID=2261)
Feb 05 10:52:55 nagios.adflux.net nagios[2261]: Event broker module 'NERD' deinitialized successfully.
Feb 05 10:52:55 nagios.adflux.net systemd[1]: Failed to start Nagios Network Monitoring.
Feb 05 10:52:55 nagios.adflux.net systemd[1]: Unit nagios.service entered failed state.
Feb 05 10:52:55 nagios.adflux.net systemd[1]: nagios.service failed.

在日志中没有发现其他错误(或者至少,在我查看的地方,也许......很可能我在这里遗漏了一些东西)。

运行命令/sbin/nagios /etc/nagios/nagios.cfg启动监控服务,一切按预期运行。但这并不能解决我的问题,因为 Nagios 不是作为守护进程启动的,而是链接到我的 shell。这表明问题不是由 Nagios 引起的,而是由 systemd 本身引起的。

任何有关此问题的线索都将不胜感激。

非常感谢。

答案1

看起来 Nagios 没有正确地分叉到后台-d选项,这是 systemd 所期望的type=forking

因此 systemd 将非 fork 视为启动期间的超时。这可能与 NERD 或其他问题有关。

您可以通过以下方式在前台运行 Nagios:

cp /usr/lib/systemd/system/nagios.service /etc/systemd/system/nagios.service
vim /etc/systemd/system/nagios.service
# remove Type=forking and -d in cmd line of nagios
systemctl daemon-reload
systemctl restart nagios.service

然而,有一个错误...

答案2

您已将 Nagios 安装更新到远超旧配置选项的水平。尽管 -V 显示所有飞行都正常。

我遇到了同样的问题,因为我没有在 nagios.cfg.rpmnew 文件中包含任何差异。

备份我的配置后我重新安装,然后将我的更改添加到新配置中。

答案3

您已经通过覆盖默认的 SystemD 配置解决了问题。我遇到了类似的问题,我的 Centos 7 机器上的 Nagios 在最近的自动升级后停止工作。问题是我的 /etc/nagios/nagios.cfg 配置定义的 PID 与 SystemD 配置预期的 PID 不同(/var/run/nagios.pid 与 /var/run/nagios/nagios.pid),因此 SystemD 无法检测到 Nagios 守护程序是否实际启动。我收到的消息类似于此:

systemctl status nagios.service -l
 nagios.service - Nagios Network Monitoring
   Loaded: loaded (/usr/lib/systemd/system/nagios.service; disabled; vendor preset: disabled)
   Active: failed (Result: timeout) since jue 2016-02-18 12:33:05 UTC; 1min 43s ago
     Docs: https://www.nagios.org/documentation/
  Process: 26986 ExecStart=/usr/sbin/nagios -d /etc/nagios/nagios.cfg (code=exited, status=0/SUCCESS)
  Process: 26985 ExecStartPre=/usr/sbin/nagios -v /etc/nagios/nagios.cfg (code=exited, status=0/SUCCESS)

feb 18 12:33:04 mvdatos.com nagios[26989]: wproc: 'Core Worker 26992' seems to be choked. ret = -1; bufsize = 124: errno = 32 (Broken pipe)
feb 18 12:33:04 mvdatos.com nagios[26989]: wproc: Socket to worker Core Worker 26991 broken, removing
feb 18 12:33:04 mvdatos.com nagios[26989]: wproc: Socket to worker Core Worker 26992 broken, removing
feb 18 12:33:04 mvdatos.com nagios[26989]: wproc: Socket to worker Core Worker 26993 broken, removing
feb 18 12:33:04 mvdatos.com nagios[26989]: Successfully shutdown... (PID=26989)
feb 18 12:33:05 mvdatos.com systemd[1]: Failed to start Nagios Network Monitoring.
feb 18 12:33:05 mvdatos.com systemd[1]: Unit nagios.service entered failed state.
feb 18 12:33:05 mvdatos.com systemd[1]: nagios.service failed.
feb 18 12:33:35 mvdatos.com systemd[1]: Stopped Nagios Network Monitoring.
feb 18 12:33:36 mvdatos.com systemd[1]: Stopped Nagios Network Monitoring.

直接运行守护进程(/usr/sbin/nagios -d /etc/nagios/nagios.cfg)运行完美,暗示问题与 SystemD 有关,而不是 Nagios。

希望这可以帮助其他人解决启动 Nagios 时 SystemD 超时的问题。

答案4

此答案假设您使用yumEPEL 安装。如果您从源安装,文件可能位于不同的位置,但想法是相同的。确保用户nagios有权访问这些文件。

查找此部分/etc/nagios/nagios.cfg

# LOCK FILE
# This is the lockfile that Nagios will use to store its PID number
# in when it is running in daemon mode.
lock_file=/var/run/nagios/nagios.pid

这是 Nagios 启动时将创建的文件。旧版本可能使用nagios.lock,或者路径可能类似于/usr/local/nagios/

systemd指定要查找的 pid 文件/lib/systemd/system/nagios.service

PIDFile=/var/run/nagios/nagios.pid

这需要与lock_file您的中的相同nagios.cfg,否则systemd将超时并停止您的nagios服务。

由于您已经从旧的 Nagios 安装中迁移了配置文件等,请确保更改配置文件中的所有路径,例如 nagios.cfgobjects.cfgcommands.cfglibexec`,等等。,, etc . You will probably also have to move around your custom scripts in

相关内容