下面是我的脚本,其中我使用jvmtop.sh脚本的输出存储在受尊敬的变量中,并稍后用图形在nagios中处理。Nagios插件脚本不按预期方式工作
在客户端服务器bash中,脚本按预期输出。但是当我在nagios中执行Test check命令时,似乎./jvmtop.sh不会将输出存储在变量中。我正在“关键 - 监视进程没有运行!”
让我知道我缺少什么..
get_vals() {
current=/usr/local/nagios/libexec/
cd $current
OLDIFS=$IFS
IFS='\n'
tmp_output=$(./jvmtop.sh --once | grep $process)
IFS=$OLDIFS
if [ -z "$tmp_output" ]
then
echo "CRITICAL - Process to monitor is not running!"
exit $ST_CR
fi
PID=`echo ${tmp_output} | awk '{print $1}'`
HPCUR=`echo ${tmp_output} | awk '{print $3}' | sed 's/.$//'`
HPMAX=`echo ${tmp_output} | awk '{print $4}' | sed 's/.$//'`
NHCUR=`echo ${tmp_output} | awk '{print $5}' | sed 's/.$//'`
NHMAX=`echo ${tmp_output} | awk '{print $6}' | sed 's/.$//'`
CPU=`echo ${tmp_output} | awk '{print $7}' | sed 's/.$//' | cut -d . -f 1`
GC=`echo ${tmp_output} | awk '{print $8}' | sed 's/.$//' | cut -d . -f 1`
THREAD=`echo ${tmp_output} | awk '{print $11}'`
}
也尝试导出JAVA_HOME = {它的路径}在你自己的shell脚本的顶部,所以当nagios运行它时 - 它可以找到它 - – Vahid