我正在使用NAGIOS作为一个监控工具,我认为它是完美的。然而,我想知道在NAGIOS的帮助下,我们如何监控正在运行的服务,如DOCKER或任何其他服务。
我主要是尝试监控运行在服务器的Docker服务中的容器。
例如,下面给出的是我的主机服务器中的一个.cfg文件。我需要在这里进行哪些更改才能监控码头容器?
另外,有没有一些很酷的东西,我们也可以在Nagios的帮助下进行监控?
define host {
use linux-server
host_name testserver
alias Remote Host
address XXX.XXX.XXX
register 1
}
define service {
host_name testserver
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name testserver
service_description Disk Usage
check_command check_local_disk!20%!10%!/
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name testserver
service_description SSH Service
check_command check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}发布于 2021-04-15 17:50:30
您需要知道的第一件事是要在本地还是远程运行这些检查。也就是说,运行Nagios的服务器也可以运行Docker检查吗?
本地检查
为此,您只需下载一个插件,创建一个新的命令对象(在commands.cfg中,请参阅文档),并将其设置为新服务对象的check_command (示例):
define service {
host_name testserver
service_description Docker Check
check_command your_check_command!arg1!arg2 # args are optional
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}这将在testserver主机下创建一个新服务,它将使用您配置的your_check_command命令,并且它接受两个可在命令定义中使用的参数,如$ARG1$和$ARG2。这些参数的目的是使命令对象可重用(每个服务的一些细节可能不同)。
远程检查
如果检查需要在另一个节点上进行,可能是因为防火墙不允许您的Nagios服务器与您想要检查的任何内容进行通信,那么通常使用NRPE。它基本上是这样工作的:
┌────────────┬───────────┐ ┌─────┬─────┬──────────────┐
│ ├──────────┼│ ├─────┤ ├─────────────┼│
│testserver │check_nrpe│┼───►│nrped│ bar │check_docker ││
│ ├──────────┼│ ├─────┤ ├─────────────┼│
└────────────┴───────────┘ └─────┴─────┴─────┼────────┘
│
▼
┌─────────────┐
│targeted node│
└─────────────┘因此,您的Nagios服务器不再运行实际的插件,而是运行调用另一个安装了nrped (守护进程)的节点的check_nrpe。当这个守护进程被调用时,您给它一个预先配置的“命令”,该命令映射到bar上的一个插件。此插件运行,结果通过NRPE协议传回。
这只是一个概括性的概述,但希望它能为运行这些检查的两种主要方式提供一些思路。
是的,您可以使用Nagios检查许多事情。市面上可能有一百万个插件,所以只要开始谷歌搜索或者看看https://exchange.nagios.org/
https://stackoverflow.com/questions/66914805
复制相似问题