【问题标题】:Nagios Custom Plug-in(https authentication) not working as expectedNagios 自定义插件(https 身份验证)未按预期工作
【发布时间】:2014-01-23 13:51:17
【问题描述】:

我正在编写一个插件来检查对 https 站点的身份验证,然后在响应 html,body 中搜索文本以确认成功登录。我创建了以下插件

#!/bin/bash
add_uri='--no-check-certificate https://'
end_uri='/'
result=$(wget -O- $add_uri$1$end_uri --post-data=$2)
flag=`echo $result|awk '{print match($0,"QC Domain")}'`;
echo $flag
echo "Nagios refreshes properly1"

if [[ $flag -gt 0 ]] ; then
echo 'ALL SEEMS FINE!!'
exit 0
   else
echo 'Some Problem'
exit 2
fi;

当我直接从命令行执行这个插件时

./check_nhttps <url here>  '<very long post data with credential information>'

插件按预期工作(对于 + & - 测试用例),似乎没有问题。 但是当插件从 Nagios 运行时,

check_command                   check_nhttps! <url here>  '<very long post data with    credential information>'

它总是显示严重错误(也打印其他条件文本“Some Problem”)。 P.S:尝试用双引号发送帖子数据。

请帮忙!!!

【问题讨论】:

    标签: plugins nagios


    【解决方案1】:

    我认为您的帖子数据很可能包含一些混淆 nagios 的字符,可能是空格,甚至是 !。最好将发布数据放入某个文件并使用--post-file。另外,您可以在脚本中插入echo "$2" &gt; /tmp/this_is_my_post_data_when_executed_by_nagios 并检查帖子数据是否正常。

    【讨论】:

    • 终于让它工作了?原来 commands.cfg 中的参数顺序是错误的。你在脚本中打印参数的想法很有帮助!!!感谢您的帮助!!! ?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 2016-04-11
    • 2018-10-22
    • 2011-08-16
    相关资源
    最近更新 更多