bash - Nagios plugin script not working as expected -
below script, in using jvmtop.sh script's output store in respected variables , later processing in nagios graphs.
in client server bash, script outputs expected. when test check command in nagios, seems ./jvmtop.sh doesn't store output in variable. getting "critical - process monitor not running!"
let me know missing..
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" ] echo "critical - process monitor 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}'` }
personally think may due definition of jvmtop.sh on line 120, suggestion give full path script....
tmp_output=$(./jvmtop.sh --once | grep $process)
to
tmp_output=$(/path/to/jvmtop.sh --once | grep $process)
if not help, try enabling debug , defining debug level in nagios.cfg:
debug_level=2048 debug_file=/var/log/nagios_debug.log
do turn off once have finished it.
e2a: 1 last thing after line (120) echo out result of tmp output temp file , @ output see if has worked !
so echo $tmp_output > /tmp/observe.txt
since my suspicion still on - sent comment above export out java home since either can't find jvmtop.sh or if can don't know $java_home/bin/java ...
Comments
Post a Comment