我正在编写一个插件来检查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>'
该插件按预期工作(对于+&amp; - 测试用例)并且似乎没有问题。 但是当插件从Nagios运行时,
check_command check_nhttps! <url here> '<very long post data with credential information>'
它总是显示严重错误(打印其他条件文本“一些问题”)。 P.S:尝试用双引号发送帖子数据。
请帮助!!!
答案 0 :(得分:0)
我认为你的帖子数据很可能包含一些混淆了nagios,可能是空格,甚至是!
的字符。最好将发布数据放入某个文件并使用--post-file。此外,您可以在脚本中插入echo "$2" > /tmp/this_is_my_post_data_when_executed_by_nagios
并检查帖子数据是否正常。