Oracle Login Check

Started by prutser, March 19, 2008, 05:12:45 PM

Previous topic - Next topic

prutser

Hello again,

I'm looking for a solution to test an oracle instance on Ms Win.
I would like to do a fake login (eg: sqlplus false_user/false_password@oracleinstance), and one way or another make a dci of the result...
I already do a check on port 1521 (ora listener) and check the service of the oracle instance.
Any help with this, or suggestions about other solutions would be very appreciated!

Thank you very much in advance!!
Peter.

Alex Kirhenshtein

You can add custom parameter on agent which calls sqlplus (or some script around it)

Add to nxagentd.conf:

ExternalParameterShellExec = Oracle.FakeLogin:sqlplus false_user/false_password@oracleinstance

Oracle.FakeLogin — parameter name, put anything you like there (I don't recall exactly list of allowed chars in name, but A-Z, a-z, 0-9 and "." should be safe)
sqlplus false_user/false_password@oracleinstance — command to be run. Output of this command will be returned by agent.

Also, you  can use arguments (e.g. you can check multiple oracle instances with single external parameter)
Example:
ExternalParameter = Echo(*):echo input was: $1

then we asking agent for this parameter:

$ nxget 127.0.0.1 "Echo(test request)"
input was: test request

prutser

I tried different ways, but do not get any feedback. I succeed in executing the command (using a bat-file with a ">logfile.txt" parameter, the logfile.txt is generated, so it means that the command has been executed). However I do not get any feedback. If I try: nxget, I do not get any output. If I create a DCI, the value returned is "#00"...
Creating a "ExternalParameterShellExec: echo(*): echo $1" returns the * output as expected.

Do you perhaps know what the reason could be? ???

Thank you very much!
Peter.

Alex Kirhenshtein

Check PATH and environment variables required by oracle client, netxms agent usually running under separate account with different settings.
Try to set all required in that bat file (e.g. PATH to sqlplus, ORACLE_HOME, etc)

You can try something like this:
echo @echo off > run.cmd && for /F "delims=" %a in ('set') do @echo set %a >> run.cmd

This should produce "run.cmd" with multiple "set ..." command. Just append sqlplus call at the end and try to run it using agent.

prutser

#4
Thank you very much for your answer. The problem seemed to be that you only get the first line. In my case the first line was blank, so..
Anyway, I created the following bat-file:
@echo off
sqlplus -L user/password@%1 | find "ORA-01017" >NUL
if errorlevel 1 goto else
      echo 0
   goto endif
:else
      echo 1
:endif

This seems to give either 0 or 1 so, what I need.
I then added this line in the etc/nxagentd.conf:
ExternalParameterShellExec = ORALogon(*):c:\_oratest\oralogon.cmd $1
This I capture in a DCI...

However maybe 1 question. It seems that when i want to edit the etc/nxagentd.conf, to reflect the changes, I hav to restart the agent service. Is there another way to reflect the changes in the config file?

Thank you very much for your help!!! And again, this software really is a jewel! ;)
Peter.

Alex Kirhenshtein

Quote from: prutser on March 21, 2008, 01:38:40 PM
However maybe 1 question. It seems that when i want to edit the etc/nxagentd.conf, to reflect the changes, I hav to restart the agent service. Is there another way to reflect the changes in the config file?

No, agent should be restarted to load updated config (at least now). However, if you edit agent's config from management console (right click on node -> edit agent configuration), there are an options to "save" or "save and restart agent". To use this feature agent should have write access to config file and server's IP should be in ControlServers or MasterServers section of agent's config.