/usr/local/nagios/libexec/check_oracle_nrs.sh "select 1 from dual where exists (select p.inst_id, machine, count(distinct spid) from gv\$process p , gv\$session s where p.inst_id=s.inst_id and p.addr=s.paddr group by p.inst_id , machine having count(distinct spid) > 500 );" server.com 1522 PRODEBS
Notice there are a couple $ that are being escaped and fed to my custom script. My issue now is, I can't figure out how to put this in an argument. In the bash script I have
TEST=`echo $1| /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib ORACLE_HOME=/usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/bin/sqlplus -s user/pass@//$2:$3/$4`
CORRECT="no rows selected"
if [[ "$TEST" != *"$CORRECT"* ]]; then
echo "CRITICAL: $TEST"
exit 2
fi
echo "OK: No Rows Selected"
exit 0
If it didn't have the $ inside the sql query this would all be working.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
define service {
host_name extn-chi-pdb01
service_description PRODEBS - MX_DB_Processes
use extn_generic-service-5
servicegroups extn_prodebs
check_command check_xi_oraclenrs!'select 1 from dual where exists (select p.inst_id, machine, count(distinct spid) from gv$process p , gv$session s where p.inst_id=s.inst_id and p.addr=s.paddr group by p.inst_id , machine having count(distinct spid) > 500 );'!1522!PRODEBS!!!!!
check_period xi_timeperiod_24x7
notification_period xi_timeperiod_24x7
_xiwizard oraclequery
register 1
}
(No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
Works fine from command line...any more ideas?
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
How did you modify your check command - in the CCM or via Home->Service Detail->Configure-Re-Configure this service? I've seen cases when modifying via "Confiture->Re-configure..." doesn't work, when using ";" semi-colon in the check command. Nagios strips out everything after the ";". It works fine if you use the CCM for mods.
Be sure to check out our Knowledgebase for helpful articles and solutions!
lmiltchev wrote:How did you modify your check command - in the CCM or via Home->Service Detail->Configure-Re-Configure this service? I've seen cases when modifying via "Confiture->Re-configure..." doesn't work, when using ";" semi-colon in the check command. Nagios strips out everything after the ";". It works fine if you use the CCM for mods.
I used CCM, I rarely use the reconfigure option and right now the testing is a pain because of my 15 minute restart issue. However, I fixed it with your assistance Ludmil. It was the ";" causing the issue. I ended up removing the ; and just adding it in my script
TEST=`echo "$1;"| /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib ORACLE_HOME=/usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/bin/sqlplus -s user/pass@//$2:$3/$4`
CORRECT="no rows selected"
if [[ "$TEST" != *"$CORRECT"* ]]; then
echo "CRITICAL: $TEST"
exit 2
fi
echo "OK: No Rows Selected"
#echo "$1"
exit 0
Close this up, issue has been worked around. Feel free to open an internal bug report abotu the ; causing escaping issues if you'd like. With the ; on the end of ARG1 the other ARG's were then ignored when the check ran, it caused all kinds of fun for me.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github