设为首页收藏本站

LinuxTone | 运维专家网论坛 - 最棒的Linux运维与开源架构技术交流社区!

 找回密码
 注册

QQ登录

只需一步,快速开始

#公告#抱歉,网站将关闭,不再开放。由于PC时代已远逝 。在这个后移动互联网时代,我们继续携手前行,保持对技术的热情。共同构建linuxtone知识星球欢迎加入,一起讨论技术、招聘人才、分享资源。请新老linuxtone人 扫码移步到 知识星球:linuxtone

学习是一种信仰!分享是一种快乐!能力= 心态 * 沟通 * 知识 (你的每一天需要正能量!)

 网站的发展需要你贡献一份力量!希望你能每天坚持看贴1小时,并回答网友的问题!祝你在浏览论坛的过程中取得进步!谢谢!linuxtone加油!大家加油! 友情提示: 你今天学习了吗?你今天进步了吗?少一点抱怨!多一点进步!Life is short ! Why not linuxtone ?  

网站的发展、感谢每位坛友的努力!

查看: 3922|回复: 4

check_icmp 代替check_ping [复制链接]

Rank: 7Rank: 7Rank: 7

签到
27
注册时间
2008-6-1
最后登录
2017-9-11
在线时间
152 小时
阅读权限
100
积分
2894
帖子
309
主题
39
精华
5
UID
35

LT同学

发表于 2010-5-17 23:57:51 |显示全部楼层
本帖最后由 huzi1986 于 2010-5-18 00:09 编辑

今天下午无聊研究了一下pnp for nagios ,很顺利就弄出来了,测试环境,也就一些常见的服务 SSH监控 磁盘 负载之类的,结果发现check_ping 怎么也无法获取数据,打开debug日志,看到无法获取取性能日志,当然也可以在nagios看到 性能数据是空的,官方文档原文Performance Data Support For PluginsNormally plugins return a single line of text that indicates the status of some type of measurable data. For example, the check_ping plugin might return a line of text like the following:PING ok ? Packet loss = 0%, RTA = 0.80 msWith this type of output, the entire line of text is available in the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macros (depending on whether this plugin was used as a host check or service check).In order to facilitate the passing of plugin-specific performance data to Nagios, the plugin specification has been expanded. If a plugin wishes to pass performance data back to Nagios, it does so by sending the normal text string that it usually would, followed by a pipe character (|), and then a string containing one or more performance data metrics. Let’s take the check_ping plugin as an example and assume that it has been enhanced to return percent packet loss and average round trip time as performance data metrics. A sample plugin output might look like this:PING ok ? Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80When Nagios seems this format of plugin output it will split the output into two parts: everything before the pipe character is considered to be the “normal” plugin output and everything after the pipe character is considered to be the plugin-specific performance data. The “normal” output gets stored in the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macro, while the optional performance data gets stored in the $HOSTPERFDATA$ or $SERVICEPERFDATA$ macro. In the example above, the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macro would contain “PING ok ? Packet loss = 0%, RTA = 0.80 ms” (without quotes) and the $HOSTPERFDATA$ or $SERVICEPERFDATA$ macro would contain “percent_packet_loss=0, rta=0.80” (without quotes).其实上面说的这么多,简单地来说 默认我们使用的check_ping 插件是获取不到性能数据PING ok ? Packet loss = 0%, RTA = 0.80 ms 这个就是默认check_ping得出来的结果check_icmp是check_ping的扩展,加了性能数据,check_icmp得到的结果如下PING ok ? Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80现在我们要在command.cfg中添加command,我的配置:define command{command_name    check_icmpcommand_line    $USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -n 10}下面就在nagios 监控对象中添加icmp的选项define service{use                             generic-service         ; Name of service template to usehost_name                       huziservice_description             PINGcheck_command                   check_icmp!100.0,20%!500.0,60%}保存退出,然后重新加载nagios 服务service nagios reload过了几分钟,问题来了,就如下图所示,点击进去,有详细提示,按照上面的做法来做就可以解决问题,我确google了好长时间,呵呵!具体做法是cd /usr/local/nagios/libexec  (我的插件目录在这里)chown root:nagios check_icmpchmod 4711 check_icmp再重新加载nagios服务service nagios reload

为啥第一帖,直接copy过来成这样呢!
哥上的不是网,上的是寂寞

Rank: 7Rank: 7Rank: 7

注册时间
2008-6-1
最后登录
2017-9-11
在线时间
152 小时
阅读权限
100
积分
2894
帖子
309
主题
39
精华
5
UID
35

LT同学

发表于 2010-5-18 00:05:54 |显示全部楼层
本帖最后由 huzi1986 于 2010-5-18 00:08 编辑

今天下午无聊研究了一下pnp for nagios ,很顺利就弄出来了,测试环境,也就一些常见的服务 SSH监控 磁盘 负载之类的,结果发现check_ping 怎么也无法获取数据,打开debug日志,看到无法获取取性能日志,当然也可以在nagios看到 性能数据是空的,官方文档原文

Performance Data Support For Plugins

Normally plugins return a single line of text that indicates the status of some type of measurable data. For example, the check_ping plugin might return a line of text like the following:

PING ok ? Packet loss = 0%, RTA = 0.80 ms

With this type of output, the entire line of text is available in the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macros (depending on whether this plugin was used as a host check or service check).

In order to facilitate the passing of plugin-specific performance data to Nagios, the plugin specification has been expanded. If a plugin wishes to pass performance data back to Nagios, it does so by sending the normal text string that it usually would, followed by a pipe character (|), and then a string containing one or more performance data metrics. Let’s take the check_ping plugin as an example and assume that it has been enhanced to return percent packet loss and average round trip time as performance data metrics. A sample plugin output might look like this:

PING ok ? Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80

When Nagios seems this format of plugin output it will split the output into two parts: everything before the pipe character is considered to be the “normal” plugin output and everything after the pipe character is considered to be the plugin-specific performance data. The “normal” output gets stored in the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macro, while the optional performance data gets stored in the $HOSTPERFDATA$ or $SERVICEPERFDATA$ macro. In the example above, the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macro would contain “PING ok ? Packet loss = 0%, RTA = 0.80 ms” (without quotes) and the $HOSTPERFDATA$ or $SERVICEPERFDATA$ macro would contain “percent_packet_loss=0, rta=0.80” (without quotes).

其实上面说的这么多,简单地来说 默认我们使用的check_ping 插件是获取不到性能数据

PING ok ? Packet loss = 0%, RTA = 0.80 ms 这个就是默认check_ping得出来的结果

check_icmp是check_ping的扩展,加了性能数据,check_icmp得到的结果如下

PING ok ? Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80

现在我们要在command.cfg中添加command,我的配置:

define command{

command_name    check_icmp

command_line    $USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -n 10

}

下面就在nagios 监控对象中添加icmp的选项

define service{

use                             generic-service         ; Name of service template to use

host_name                       huzi

service_description             PING

check_command                   check_icmp!100.0,20%!500.0,60%

}

保存退出,然后重新加载nagios 服务

service nagios reload

过了几分钟,问题来了,就如下图所示,点击进去,有详细提示,按照上面的做法来做就可以解决问题,我确google了好长时间,呵呵!

具体做法是

cd /usr/local/nagios/libexec  (我的插件目录在这里)

chown root:nagios check_icmp

chmod 4711 check_icmp

再重新加载nagios服务

service nagios reload










有数据咯



发个贴好累啊!杂个整的啊

原文:http://www.lovebsd.com/index.php/archives/348
哥上的不是网,上的是寂寞

使用道具 举报

LT管理团队

社区首席勤杂工

Rank: 9Rank: 9Rank: 9

注册时间
2008-5-19
最后登录
2019-11-16
在线时间
1946 小时
阅读权限
200
积分
59419
帖子
2551
主题
1209
精华
25
UID
1

LT总司令

发表于 2010-5-18 09:58:42 |显示全部楼层
虎子兄发威,我顶一下!
<-sina_sign,1762622645,2a5b1a59,10->感谢大家对linuxtone的支持!</strong>

使用道具 举报

Rank: 7Rank: 7Rank: 7

注册时间
2008-6-1
最后登录
2017-9-11
在线时间
152 小时
阅读权限
100
积分
2894
帖子
309
主题
39
精华
5
UID
35

LT同学

发表于 2010-5-18 10:07:47 |显示全部楼层
虎子兄发威,我顶一下!
NetSeek 发表于 2010-5-18 09:58



小弟不才,见笑了,呵呵!

使用道具 举报

Rank: 6Rank: 6

注册时间
2008-11-12
最后登录
2019-4-24
在线时间
57 小时
阅读权限
70
积分
4548
帖子
359
主题
1
精华
0
UID
528
发表于 2011-3-26 19:46:56 |显示全部楼层
支持。。。。。

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

IT运维专家网感谢您的支持

合作联系: QQ:67888954/MSN:cnseek@msn.com/mail:netseek@linuxtone.org

Archiver|手机版|感谢所有关心和支持过LinuxTone的朋友们 转载本站内容请注明原作者名及出处 ( 京ICP备08103151 )   |

GMT+8, 2020-6-2 13:41 , Processed in 0.023189 second(s), 14 queries , Apc On.

Powered by Discuz! X2 Licensed

© 2001-2011 Comsenz Inc.

回顶部