大网数据广告活动
服务器运维问答

Monitoring Ansible pull with Nagios

· 52CE 我爱测

I have a couple (say 40) of workstations and servers that are configured using Ansible in the pull configuration. Each machine has a cron job that uses ansible-pull to pull a git repository and apply it onto the host itself. The …

问题原文

原帖链接 · Martin Ueding · CC BY-SA 4.0

I have a couple (say 40) of workstations and servers that are configured using Ansible in the pull configuration. Each machine has a cron job that uses ansible-pull to pull a git repository and apply it onto the host itself. The results are currently emailed to my account.

In the emails I have to check whether some of the hosts have not send an email on that day to figure out that they are either just turned off or have some other issue. If a machine is missing I try to connect via SSH. If it is turned off, that's fine. Otherwise I try to fix the issue.

A couple of days ago I set up Nagios on one server to get an overview of the machines. Setting up monitoring via ping and SSH was easy enough, now I see which machines are up and which are down.

Now I would like to somehow also monitor the Ansible state in Nagios. I did not found a direct plugin on the Nagios Exchange, so I had the following ideas:

  1. Write the output of ansible-pull into a log file with a timestamp and then let the Nagios host retrieve all the logs from the machines. Then it would need to check that the last timestamp is not older than 24+X hours, where X is some margin like 1 hour.

  2. Convert everything back to the push architecture and just run ansible-playbook on the infrastructure server. This then creates some file and I have an overview there, which might be somehow parsable by Nagios.

  3. Port our configuration management to Puppet as that seems to have some monitoring build in and use that instead of Nagios.

  4. Buying Ansible tower might be a solution, but there won't be money for it. Until now people just have come to my office if their workstation hangs, so we do not really have a business need for a monitoring system. I want to do it with free software only.

The first option seems to be the easiest from the current setup, I am just not sure what a sensible implementation would be. An answer would be greatly appreciated if it provides me with a rough outline for the implementation and pointers to needed plugins for Nagios.

已采纳解答

原帖链接 · mzhaase · CC BY-SA 4.0

For this, you would use some form or remote command execution. Icinga2 Agent, NRPE, or SSH, and place the check executable on the machine itself. It will be checked locally and just return the check output.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-08-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。