check_cpu + nsclient:仅在5分钟内设置关键阈值

时间:2018-11-20 08:35:08

标签: monitor nagios

我正在使用centeron(nagios)来监视使用NSClient的某些VM的CPU。在我的情况下,如果在5m的时间内平均cpu负载> 95,则设置cpu探针的临界状态才有意义。这可以实现吗?

我找不到有关如何在关键参数中进行指定的文档

默认命令

check_cpu

返回

CPU Load ok
'total 5m load'=0%;80;90 'total 1m load'=0%;80;90 'total 5s load'=7%;80;90

具有特定阈值的命令(但所有时间段都可以匹配)

check_cpu "critical=load > 90"

3 个答案:

答案 0 :(得分:0)

这不完全是我想要做的,但我要做的是以下

check_nrpe -u -H XX.XXX.X.XXX -c check_cpu -a "crit=load > 95" "warn=load > 90" time=5m

将输出限制为5m时间段。

请注意,要从centeron执行此操作,您必须在nsclient.ini文件中设置以下变量(在该文件上浪费了很多时间)

[/settings/NRPE/server]
allow nasty characters=true

[/settings/external scripts]
allow nasty characters=true

答案 1 :(得分:0)

检查此脚本,

define service{
    use                     generic-service
    host_name               xxx
    service_description     CPU Load
    check_command           check_nrpe!check_load
    contact_groups          sysadmin

}

---
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

答案 2 :(得分:0)

您可以尝试类似的方法

check_nrpe -u -H XX.XXX.X.XXX -c check_cpu -a "warning=time = '5m' and load > 80" "critical=time = '5m' and load > 90" show-all

您还可以检查the documentation以获得更多信息。