Page 1 of 1

check_oracle_health SQL query

Posted: Mon Jan 27, 2020 9:05 am
by biswajit.banerjee
In Check_oracle_health how can I convert following in sql query

select * from
(
select
opname,
start_time,
target,
sofar,
totalwork,
units,
elapsed_seconds,
message
from
v$session_longops
order by start_time desc
)
where rownum <=1;


I am not able to convert it make it work . Getting unknown issue .

Please help

Re: check_oracle_health SQL query

Posted: Mon Jan 27, 2020 3:43 pm
by tgriep
The issue is probably caused by the $ in the query so use the following example that escapes the $ in the query for the --name option.

Code: Select all

"select * from(select opname, start_time, target, sofar, totalwork, units, elapsed_seconds, message from v$"$"session_longops order by start_time desc) where rownum <=1;"

Re: check_oracle_health SQL query

Posted: Tue Jan 28, 2020 12:48 am
by biswajit.banerjee
No It is not working
. /usr/local/nagiosxi/etc/configwizards/oracle/oracle && /usr/local/nagios/libexec/check_oracle_health --connect '172.17.148.178:1521/AWSPROD' --username 'sys' --password 'sys' --mode sql --name="select * from(select opname, start_time, target, sofar, totalwork, units, elapsed_seconds, message from v$"$"session_longops order by start_time desc) where rownum <=1;"

UNKNOWN - got no valid response for select * from(select opname, start_time, target, sofar, totalwork, units, elapsed_seconds, message from v$session_longops order by start_time desc) where rownum <=1; - ORA-00933: SQL command not properly ended (DBD ERROR: error possibly near <*> indicator at char 164 in 'select * from(select opname, start_time, target, sofar, totalwork, units, elapsed_seconds, message from v$session_longops order by start_time desc) where rownum <=1<*>;')

Re: check_oracle_health SQL query

Posted: Tue Jan 28, 2020 12:31 pm
by mbellerue
Based on the message returned, it looks like it was passed to Oracle properly, but Oracle doesn't like the query for some reason. It says it isn't terminated properly, but it looks proper to me. If you copy and paste the query as it is shown in the check result, does it run in Oracle?

Re: check_oracle_health SQL query

Posted: Wed Jan 29, 2020 1:51 am
by biswajit.banerjee
Yes run on Oracle

Re: check_oracle_health SQL query

Posted: Wed Jan 29, 2020 12:27 pm
by mbellerue
Would it be possible to trace the query in Oracle when the plugin executes it? We're getting an Oracle error back, which means the plugin is connecting, authenticating, and getting as far as actually running the query.