returning a value from SQLPLUS does not work

Remote Monitoring Agent for Linux, FreeBSD, and other UNIX-like platforms.
Post Reply
tom
Posts: 2
Joined: Tue Oct 23, 2007 3:18 pm

returning a value from SQLPLUS does not work

Post by tom »

Hello,
I have written a small script to get the state of an oracle DB in HM.
The Script should return the state of the Oracle DB

If I run the script "test3.sh" within putty as user root, everthing worksfine and I get the result value.
If I call the script from Hostmonitor I get no value for val. The RMA is running with root rights.

I'm not very familiar with scripting on/and Linux. Probably it is more a problem of my scripting knowledge than a problem of HM. ;-)

Perhaps someone has an idea!
Thanks in advance.

Thomas

#!/bin/sh
VAL="Error"
VAL=`./home/oracle/epeppdm/test3.sh`
if [ "$VAL" == "OPEN" ]; then
echo ScriptRes:Ok:$VAL
else
echo ScriptRes:Bad:$VAL
fi

---------- test3.sh ----------
#!/bin/sh
instance='$Instance'
VAL="ERROR"
VAL=`/opt/oracle/product/10.2.0/bin/sqlplus -s system/manager <<END
set pagesize 0 feedback off verify off heading off echo off
select status from v$instance
exit;
END`
echo $VAL
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Re: returning a value from SQLPLUS does not work

Post by KS-Soft Europe »

tom wrote:If I run the script "test3.sh" within putty as user root, everthing worksfine and I get the result value.
If I call the script from Hostmonitor I get no value for val. The RMA is running with root rights.
Do you mean, you have tested it using "Lets try" tab of the "Script Manager" or you have setup a particular test? What exact error do you see in "Reply" field of the test? Have you selected appropriate agent from the "Test by" dropdown in "Test Properties" window?

Regards,
Max
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Re: returning a value from SQLPLUS does not work

Post by KS-Soft Europe »

tom wrote:#!/bin/sh
VAL="Error"
VAL=`./home/oracle/epeppdm/test3.sh`
if [ "$VAL" == "OPEN" ]; then
echo ScriptRes:Ok:$VAL
else
echo ScriptRes:Bad:$VAL
fi
I think, script should be like the following:

Code: Select all

#!/bin/sh
VAL="Error"
VAL=`/home/oracle/epeppdm/test3.sh`;
if [ $VAL == "OPEN" ] then
  echo ScriptRes:Ok:$VAL
else
  echo ScriptRes:Bad:$VAL
fi 
BTW. You may copy the foregoing script into some .sh file and try to execute it on your system to check it works.

Regards,
Max
tom
Posts: 2
Joined: Tue Oct 23, 2007 3:18 pm

Post by tom »

Hello again...

thanks for your fast reply :-)

We solved the problem .... the solution is ... that the RMA needs oracle user rights. We got no results from the RMA, because the RMA has not the rights to run sqlplus....
(...I have no idea, why the user root is allowed to start sqlplus in putty...)

Therfore we got no result in HM ;-)

Here know is the correct script wihich works fine..... if the RMA runs as user oracle ...

By the way ... HM is a great tool.

Thanks

Thomas

#!/bin/sh
instance='$Instance'
VAL="ERROR"
VAL=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select status from v$instance;
exit;
END`
if [ "$VAL" == "OPEN" -o "$VAL" == "MOUNTED" ]; then
echo ScriptRes:Ok:$VAL
else
echo ScriptRes:Bad:$VAL
fi
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

tom wrote:We solved the problem .... the solution is ... that the RMA needs oracle user rights. We got no results from the RMA, because the RMA has not the rights to run sqlplus....
Glad to hear that. :-)
tom wrote:Here know is the correct script wihich works fine..... if the RMA runs as user oracle ...
Thank you. Script looks fine. ;-)
tom wrote:By the way ... HM is a great tool.
Thank you. We appreciate your feedback. :-)

Regards,
Max
Post Reply