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

Check to ping google from host in check_mk using WATO

· 52CE 我爱测

I'm new to check_mk and got it installed using OMD (last daily version). I'm trying to create a check so my hosts ping google to see if their network connection to the internet is working. I thought something so basic could be av…

问题原文

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

I'm new to check_mk and got it installed using OMD (last daily version). I'm trying to create a check so my hosts ping google to see if their network connection to the internet is working. I thought something so basic could be available using wato but I can't find it and as I have defined all using WATO now I'm not sure how to configure this manually.

I tried to add in the /omd/sites/mysite/etc/check_mk/main.mk the following


define command {
         command_name    check_tcp_http
         command_line    $USER1$/check_tcp -H $HOSTADDRESS$ -p 80
}

legacy_checks = [
   ( ( "check_tcp_http!www.google.com", "HTTP Service", True), [ "httpd" ], ALL_HOSTS ),
]

but get an error when check_mk tries to read the main.mk

Any idea how to accomplish what I want?

已采纳解答

原帖链接 · Santi · CC BY-SA 3.0

I manage to get it working by using local checks. I created a script on my hosts in the /usr/lib/check_mk_agent/local that the check_mk reads and pass the output to the Check_mk server

#!/bin/bash

host=8.8.8.8
if ping -c 1 $host &> /dev/nul
then
  status=0
  statustxt=OK
else
    status=2
    statustxt=CRITICAL
fi
echo "$status ping_$host varname=2;crit $statustxt"

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

资料来源与适用范围

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

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

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