Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYSDBA connections not working (eg for standby database) #3

Open
dtseiler opened this issue Mar 25, 2013 · 4 comments
Open

SYSDBA connections not working (eg for standby database) #3

dtseiler opened this issue Mar 25, 2013 · 4 comments

Comments

@dtseiler
Copy link
Contributor

The latest release of check_oracle_health did not work for SYSDBA connections because the code was setting the username to "sysdba" when it needs to be null.

I have a patch to correct this as well as use the ora_session_mode keywords instead of the hex constant for easier readability and in case those constants change.

--- check_oracle_health 2013-03-21 14:49:52.000000000 -0500
+++ check_oracle_health_dts     2013-03-25 09:05:47.000000000 -0500
@@ -4739,6 +4739,7 @@

 use strict;
 use Net::Ping;
+use DBD::Oracle qw(:ora_session_modes);

 our @ISA = qw(DBD::Oracle::Server::Connection);

@@ -4803,15 +4804,17 @@
       alarm($self->{timeout} - 1); # 1 second before the global unknown timeout
       my $dsn = sprintf "DBI:Oracle:%s", $self->{connect};
       my $connecthash = { RaiseError => 0, AutoCommit => $self->{commit}, PrintError => 0 };
+      my $username = $self->{username};
       if ($self->{username} eq "sys" || $self->{username} eq "sysdba") {
         $connecthash = { RaiseError => 0, AutoCommit => $self->{commit}, PrintError => 0,
-              #ora_session_mode => DBD::Oracle::ORA_SYSDBA
-              ora_session_mode => 0x0002  };
+              ora_session_mode => ORA_SYSDBA   };
         $dsn = sprintf "DBI:Oracle:";
+        $username = '';
       }
+       $self->debug("Connecting to " . $dsn);
       if ($self->{handle} = DBI->connect(
           $dsn,
-          $self->{username},
+          $username,
           $self->{password},
           $connecthash)) {
         $self->{handle}->do(q{
@dtseiler
Copy link
Contributor Author

I accidentally left an extra debug line in there.

@dtseiler
Copy link
Contributor Author

Also, FYI, I do get this output when I try to run on standby, but only in verbose mode. The check itself returns cleanly.

Wed Apr 24 15:00:19 2013: fetchrow_array: select dbms_utility.port_string,sys_context('userenv', 'session_user'),i.thread#,i.parallel, i.instance_name, d.name FROM dual, v$instance i, v$database d
Wed Apr 24 15:00:19 2013: args: $VAR1 = [];

bumm Can't call method "execute" on an undefined value at /usr/local/nagios/libexec/check_oracle_health_dts line 5004.
DBD::Oracle::Server::Connection::Dbi
bumm ORA-00904: "DBMS_UTILITY"."PORT_STRING": invalid identifier (DBD ERROR: error possibly near <> indicator at char 8 in ' select <>dbms_utility.port_string,sys_context('userenv', 'session_user'),i.thread#,i.parallel, i.instance_name, d.name FROM dual, v$instance i, v$database d ') DBD::Oracle::Server::Connection::Dbi

@dtseiler
Copy link
Contributor Author

You could use v$database.platform_name on standby to get the OS platform, but that's only available in 10g or higher. The output is somewhat different so you'd need to handle the if/else statements that check the values.

@dtseiler
Copy link
Contributor Author

Or you could draw the hard line and and say future versions of check_oracle_health only work for 10g or higher (at least for standby support). I think at this point in time, cutting off 8i/9i support in future versions isn't a horrible idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant