请帮助我了解此shell脚本的作用:
# main
for HOST in ${HOSTS}
do
URI=http://${HOST}:80
count=99
result=`/opt/splunk/bin/splunk search "index=${INDEX} sourcetype=${SOURCETYPE} SPLUNK_HEALTH_CHECK |stats count" -earliest_time ${EARLIEST} -latest_time ${LATEST} -uri ${URI} -auth ${USER}:${PASS} -preview F -output csv -timeout ${TIMEOUT} 2>&1 |grep -v count |tr -d '\n' |sed 's/"//g'`
if expr $result : '[0-9]*' > /dev/null 2>&1; then
count=$result
result="OK"
fi
date +"%Y-%m-%d %T sh=${HOST} status=\"${result}\" delay_status=$count"
done
从splunk调用此脚本时,出现以下错误:
status =“无法查找HOME变量。验证令牌不能为 cached。10“ delay_status = 99
答案 0 :(得分:0)
Could not look up HOME variable. Auth tokens cannot be cached
当尝试以root
用户或错误设置权限运行Splunk时,通常会发生此错误。在您的情况下,您正在将USER和PASS传递到脚本中,但是bash不能正确扩展这些值(请参见https://answers.splunk.com/answers/446944/getting-error-could-not-look-up-home-variable-auth.html)。