View previous topic :: View next topic |
Author |
Message |
tom
Joined: 23 Oct 2007 Posts: 2
|
Posted: Tue Oct 23, 2007 3:59 pm Post subject: returning a value from SQLPLUS does not work |
|
|
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 |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Wed Oct 24, 2007 5:23 am Post subject: Re: returning a value from SQLPLUS does not work |
|
|
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 |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Wed Oct 24, 2007 8:33 am Post subject: Re: returning a value from SQLPLUS does not work |
|
|
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: | #!/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 |
|
Back to top |
|
|
tom
Joined: 23 Oct 2007 Posts: 2
|
Posted: Wed Oct 24, 2007 10:40 am Post subject: |
|
|
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 |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Wed Oct 24, 2007 10:52 am Post subject: |
|
|
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 |
|
Back to top |
|
|
|