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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
05-04-2011, 04:11 AM
|
#16
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
Quote:
Originally Posted by brownie_cookie
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.
|
05-04-2011, 04:18 AM
|
#17
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
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???
|
|
|
|
05-04-2011, 04:31 AM
|
#18
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
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
|
|
|
|
05-04-2011, 04:36 AM
|
#19
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
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)'
|
|
|
|
05-04-2011, 04:42 AM
|
#20
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
Hello,
No you don't. Apparently you have a
Quote:
|
CentOS release 5.5 (Final)
|
Kind regards,
Eric
|
|
|
|
05-04-2011, 04:45 AM
|
#21
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
okay then  hahaha xD
but that doens't matter for the zip files right?
|
|
|
|
05-04-2011, 04:47 AM
|
#22
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
should i download from this page then ?
|
|
|
|
05-04-2011, 05:07 AM
|
#23
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
Quote:
Originally Posted by brownie_cookie
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.
|
05-04-2011, 05:11 AM
|
#24
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
okay thx !
let's try that and hope we get lucky 
|
|
|
|
05-04-2011, 05:20 AM
|
#25
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
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?
|
|
|
|
05-04-2011, 05:30 AM
|
#26
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
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.
|
05-04-2011, 05:32 AM
|
#27
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
thanks buddy  i don't know what i should do without you
let's try it out
|
|
|
|
05-04-2011, 05:36 AM
|
#28
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
Hi,
You're welcome. Good luck!
Kind regards,
Eric
|
|
|
|
05-04-2011, 05:37 AM
|
#29
|
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Original Poster
Rep:
|
what does this part do?
Code:
queryresult=`$sqlplus USER/PASS@TNSNAME <<EOF
command;
EOF`
i don't know what EOF is
|
|
|
|
05-04-2011, 05:59 AM
|
#30
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
Quote:
Originally Posted by brownie_cookie
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:04 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|