Page 4 of 4
Re: Script returns different result when ran locally versus
Posted: Fri Nov 07, 2014 2:54 pm
by sreinhardt
Just to verify, this:
printf '%b\n%s' "$sen_return" "$nuxeo_return"
at the very end, is the only line you are attempting to change the newline character at, correct? What does your current line here look like. As for output, considering you are using a newline, this is exactly what I would expect it to look like. The nuxeo_return value is going to be on the long service output message. When you use a newline character, it is going to break the output between [standard service output]\n[long service output]. This is why we need to use an html or other newline type character, so that when viewing it in html the line is broken, but when nagios has the output it considers it all one line, because it does not have an actual newline to break it up.
That said, the br tag will absolutely work in XI, that doesn't help your for core though. I'm going to have to see if that is possible or not and get back to you.
Re: Script returns different result when ran locally versus
Posted: Fri Nov 07, 2014 3:15 pm
by rickwilson7425
That is correct, I am using that "printf" line for my experimenting. Trying to keep it simple for now until we get a handle on the display problem.
Re: Script returns different result when ran locally versus
Posted: Mon Nov 10, 2014 3:48 pm
by abrist
I see you are posting in the customer forums. Do you still maintenance/support? Are you able to send a ticket to
[email protected]? If so, we could move this to a remote session.
Re: Script returns different result when ran locally versus
Posted: Tue Nov 11, 2014 8:37 am
by rickwilson7425
I could but this is not an XI issue and I really don't want to use up any of our support instances of I don't have to.
Re: Script returns different result when ran locally versus
Posted: Tue Nov 11, 2014 5:49 pm
by abrist
Fair enough. The next step will have to be to test your script on a test box. Can you post the most recent version of it?
Re: Script returns different result when ran locally versus
Posted: Wed Nov 12, 2014 8:46 am
by rickwilson7425
Here is where I left it yesterday. The <br> doesn't get interpreted as a line feed under this scenarios, it just shows up as text in the message. If I use the "\n" it does a line feed but the second line doesn't display as we have discussed before and the line that does display is in blue.
Code: Select all
#!/bin/bash
################# Check SENTINEL Port #################
# Clint adds to make a single return option
sen_return=''
mobil_return=''
nuxeo_return=''
nuxeo_not_defined_error_return=''
mobile_not_defined_error_return=''
final_response_string=''
exit_value=0
HOSTNAME_REDIS=`hostname -s`
# Gather ports (default sentinel port is 26379)
SEN_PORT=`grep -P '^port ' /etc/redis/rsentinel.conf | cut -f2 -d' ' | sort -u | tail -1`
if [[ `/usr/local/bin/redis-cli -p $SEN_PORT PING | grep 'PONG'` ]];then
# Success
sen_return="Sentinel port $SEN_PORT on $HOSTNAME_REDIS is OK. \<br>"
else
# Failure
sen_return="Sentinel port $SEN_PORT on $HOSTNAME_REDIS FAILED!!"
exit_value=1
fi
################# Check MOBILE Port #################
if [[ `find /apps/opt -maxdepth 1 -type d | grep /apps/opt/Tomcat_JDM` \
|| `find /apps/opt -maxdepth 1 -type d | grep /apps/opt/Tomcat_PWM` \
|| `find /apps/opt -maxdepth 1 -type d | grep /apps/opt/Tomcat_FDS` \
|| `find /apps/opt -maxdepth 1 -type d | grep /apps/opt/Tomcat_SYNC` \
|| `find /apps/opt -maxdepth 1 -type d | grep /apps/opt/Tomcat_REGISTRAR` ]];then
MOBIL_PORT=`grep 'MobileServices_Redis_Master ' /etc/redis/rsentinel.conf | grep 'monitor' | cut -f5 -d' ' | sort -u | tail -1`
if [ -z $MOBIL_PORT ];then
mobile_not_defined_error_return="WARNING $HOSTNAME_REDIS MOBILE REDIS NOT DEFINED IN SENTINEL."
exit_value=1
fi
if [[ `/usr/local/bin/redis-cli -p $MOBIL_PORT PING | grep 'PONG'` ]];then
# Success
mobil_return="Mobile port $MOBIL_PORT on $HOSTNAME_REDIS is OK. "
else
# Failure
mobil_return="Mobile port $MOBIL_PORT on $HOSTNAME_REDIS FAILED!!"
exit_value=1
fi
fi
################### Check NUXEO Port #################
if [[ `find /apps/opt -maxdepth 1 -type d | grep /apps/opt/nuxeo-jdm-server` ]];then
NUXEO_PORT=`grep -w Nuxeo_Redis_Master /etc/redis/rsentinel.conf | grep 'monitor' | cut -f5 -d' ' | sort -u | tail -1`
if [ -z $NUXEO_PORT ];then
nuxeo_not_defined_error_return="WARNING $HOSTNAME_REDIS NUXEO REDIS NOT DEFINED IN SENTINEL."
exit_value=1
fi
if [[ `/usr/local/bin/redis-cli -p $NUXEO_PORT PING | grep 'PONG'` ]];then
# Success
nuxeo_return="Nuxeo port $NUXEO_PORT on $HOSTNAME_REDIS is OK. \<br>"
else
# Failure
nuxeo_return="Nuxeo port $NUXEO_PORT on $HOSTNAME_REDIS FAILED!!"
exit_value=1
fi
fi
# Evaluate and return pretty printed output
final_response_string='';
# export final_response_string="${sen_return} ${mobil_return} ${nuxeo_return} ${nuxeo_not_defined_error_return} ${mobile_not_defined_error_return}"
for i in "$sen_return" "$mobil_return" "$nuxeo_return" "$nuxeo_not_defined_error_return" "$mobile_not_defined_error_return";do
if [[ -z "$i" ]];then continue;fi
# export final_response_string="$final_response_string"`echo "$i" | perl -nle'$x=( length($_) > 45 ) ? ( 44 - (length($_) % 45)) : ( 44 - length($_) );print "$_" . ". "x${x};'`
export final_response_string="$sen_return $nuxeo_return"
done
# printf '%b' "$sen_return" "$nuxeo_return"
# done
echo -e "$final_response_string"
exit $exit_value
Re: Script returns different result when ran locally versus
Posted: Wed Nov 12, 2014 5:25 pm
by abrist
Well, not much testing I can do here, other than zero out you script to just the echos.