Running Oracle Stored Procedures

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
delboy1966
Posts: 98
Joined: Thu Oct 22, 2015 5:26 am

Running Oracle Stored Procedures

Post by delboy1966 »

I am new to Oracle and have been tasked with executing a number of stored procedures that will return either a time stamp or a number, and then alert on them based on the thresholds.
I know how to execute MSSQL and MySQL SPs but it seems that Oracle isn't the same.

For database queries I use the CPAN DBI perl module which works fine.
I can run a basic query against an Oracle DB ok but not execute an SP.

The connection part of my code is:
#############################################
$dbh = DBI->connect("dbi:Oracle:host=$server;port=$port;sid=$db",$dbusername,$dbpassword, {RaiseError => 0, AutoCommit => 0}) || die;
$select = "EXEC DKURTULAY.NAGIOS_SMS_TABLE_CHECK.SMS_COUNT_PASTHOUR";
$sth = $dbh->prepare($select) || die "\$sth not created!\n";
$sth->execute();
@res = $sth->fetchrow_array();
$sth->finish();
$dbh->disconnect();

$res = $res[0];
print "$res\n";
##################################

And the error I get is:

##################################
DBD::Oracle::st execute failed: ORA-00900: invalid SQL statement (DBD ERROR: OCIStmtExecute) [for Statement "EXEC DKURTULAY.NAGIOS_SMS_TABLE_CHECK.SMS_COUNT_PASTHOUR"]
DBD::Oracle::st fetchrow_array failed: ERROR no statement executing (perhaps you need to call execute first) [for Statement "EXEC DKURTULAY.NAGIOS_SMS_TABLE_CHECK.SMS_COUNT_PASTHOUR"]
##################################

I would appreciate any help.

Thanks
Tony
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Running Oracle Stored Procedures

Post by dwhitfield »

Have you look through the Oracle plugins? https://exchange.nagios.org/directory/P ... ses/Oracle. I didn't see anything that seemed to do exactly what you want.

You may end up having to use event handlers: https://assets.nagios.com/downloads/nag ... dlers.html

Please let us know if you think either of those solutions will work for you.
Locked