LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-04-2011, 04:11 AM   #16
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290

Quote:
Originally Posted by brownie_cookie View Post
hmmm now you say i think i've downloaded the wrong zip files...

link which are for 64 bit i think
and i have a 32 bit...
Hi,

There's your problem. You can check the version of the file with:
Code:
file /usr/bin/sqlplus
if unsure.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-04-2011, 04:18 AM   #17
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
Code:
# file /usr/bin/sqlplus
/usr/bin/sqlplus: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped

# uname -a
Linux host 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:53:09 EST 2011 i686 i686 i386 GNU/Linux
so, which one do i need???
 
Old 05-04-2011, 04:31 AM   #18
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

Are you using CentOS or RHEL? Post the output of /etc/redhat-release to check but I'm sure from the output you posted that you have a 32-bit kernel running and the sqlplus binary is 64-bit so you should download and install the 32 bit version. In order to avoid problems, delete what you copied before installing the new version(s).

Kind regards,

Eric
 
Old 05-04-2011, 04:36 AM   #19
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
I have a RHEL 4 normally ...

Code:
# /etc/redhat-release
-bash: /etc/redhat-release: Permission denied
# chmod 755 /etc/redhat-release
# /etc/redhat-release
/etc/redhat-release: line 1: syntax error near unexpected token `('
/etc/redhat-release: line 1: `CentOS release 5.5 (Final)'
 
Old 05-04-2011, 04:42 AM   #20
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello,

No you don't. Apparently you have a
Quote:
CentOS release 5.5 (Final)
Kind regards,

Eric
 
Old 05-04-2011, 04:45 AM   #21
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
okay then hahaha xD

but that doens't matter for the zip files right?
 
Old 05-04-2011, 04:47 AM   #22
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
should i download from this page then ?
 
Old 05-04-2011, 05:07 AM   #23
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Quote:
Originally Posted by brownie_cookie View Post
okay then hahaha xD

but that doens't matter for the zip files right?
Hi,

Nope, it doesn't matter, the only thing that matters is that you're running a 32-bit kernel and that you need the 32-bit version of the Oracle client. The page you link to is for 64-bit
Quote:
Instant Client Downloads
for Linux AMD64
not for 32-bit. This link is for the 32-bit versions (x86 instead of x86_64).

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-04-2011, 05:11 AM   #24
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
okay thx !

let's try that and hope we get lucky
 
Old 05-04-2011, 05:20 AM   #25
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
wow i think it's working xD

Code:
# sqlplus user/host@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SID=sid)))'

SQL*Plus: Release 11.2.0.2.0 Production on Wed May 4 12:19:28 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options


---------- Post added 05-04-11 at 12:20 PM ----------

So does this mean that i now can use the plugin check_oracle from nagios?
 
Old 05-04-2011, 05:30 AM   #26
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello Björn,

Nice job buddy! You are connected!!

This means indeed that you can start using the Nagios plugins whenever they refer to SQLPLUS. As a bonus, you can start writing your own plugins for Oracle too. This is a skeleton I've written some time ago (at my previous job) for just that. Use it as a base if you like.
Code:
#!/bin/sh
#
# ## Plugin for Nagios to execute SQL string against Oracle DB
# ## Written by Eric Van Steenbergen (http://www.migrar-a-linux.com/)
# ##
# ## - 2010-07-05 coded and tested for Linux
#
# ## Description:
#
# This plugin executes a specific SQL query against an Oracle DB using sqlplus.
#
# Paths to commands used in this script.  These
# may have to be modified to match your system setup.

PATH=""

find="/usr/bin/find"
xargs="/usr/bin/xargs"
tail="/usr/bin/tail"
awk="/usr/bin/awk"
cut="/usr/bin/cut"
wc="/usr/bin/wc"
grep="/bin/grep"
sqlplus="/usr/bin/sqlplus"

PROGNAME=`/usr/bin/basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION="Revision 1.0"
AUTHOR="Eric Van Steenbergen"

# Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4

print_revision() {
    echo "$REVISION $AUTHOR"
}

print_usage() {
    echo "Usage: $PROGNAME"
    echo "Usage: $PROGNAME --help"
    echo "Usage: $PROGNAME --version"
}

print_help() {
    print_revision $PROGNAME $REVISION
    echo ""
    echo "Plugin for Nagios to run SQL query against Oracle DB using sqlplus"
    echo ""
    print_usage
    echo ""
}

# DB Query:

queryresult=`$sqlplus USER/PASS@TNSNAME <<EOF
command;
EOF`

# Check result:

result="ok"
exitstatus=$STATE_OK

##### Compare with thresholds

if [ "$queryresult" = "" ]; then
	echo ""
        result="critical"
        exitstatus=$STATE_CRITICAL;
else
	echo ""
	result="ok"
	exitstatus=$STATE_OK
fi

exit $exitstatus
Substitute credentials for your own, add commands where needed. It's a base I used back then to create plugins for specific queries to Oracle.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-04-2011, 05:32 AM   #27
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
thanks buddy i don't know what i should do without you

let's try it out
 
Old 05-04-2011, 05:36 AM   #28
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

You're welcome. Good luck!

Kind regards,

Eric
 
Old 05-04-2011, 05:37 AM   #29
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
what does this part do?

Code:
queryresult=`$sqlplus USER/PASS@TNSNAME <<EOF
command;
EOF`
i don't know what EOF is
 
Old 05-04-2011, 05:59 AM   #30
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Quote:
Originally Posted by brownie_cookie View Post
what does this part do?

Code:
queryresult=`$sqlplus USER/PASS@TNSNAME <<EOF
command;
EOF`
i don't know what EOF is
Hi,

The EOF part is used as termination for a HERE document. Have a look here to read about it. Basically, you put the complete sqlplus command string in one variable so that the final output gets saved in there. The command connects to the database instance with your credentials and then starts executing commnands untill encountering EOF on a single line. Replace command with the query you want to execute on the remote server, for example a select.

Kind regards,

Eric
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to configure autostart of oracle database and oracle soa suite on linux bootup sumit.tambekar Linux - Newbie 2 01-24-2011 07:35 PM
Oracle database help baks Programming 2 07-23-2007 02:55 AM
LXer: Oracle(R) Database Standard Edition One and Oracle Enterprise Linux on HP Set New World Record for Price Performance with TPC-C Benchmark LXer Syndicated Linux News 0 06-12-2007 05:01 PM
Difference between Oracle Server and Oracle Database ganninu Programming 3 02-27-2007 01:06 AM
Oracle database. chuck77 Linux - General 1 03-02-2006 08:24 AM


All times are GMT -5. The time now is 09:44 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration