- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh script to check db2 database connectivity
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 11:43 PM
тАО06-02-2005 11:43 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 11:48 PM
тАО06-02-2005 11:48 PM
Re: ksh script to check db2 database connectivity
You don't!!!!
You write it in PERL using db2 modules:
http://search.cpan.org/search?query=db2&mode=all
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2005 11:39 AM
тАО06-03-2005 11:39 AM
Re: ksh script to check db2 database connectivity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2005 05:46 AM
тАО06-04-2005 05:46 AM
Re: ksh script to check db2 database connectivity
I don't know anything about db2; however, the model that I've used for oracle should be workable for db2 as well. Effectively, you call sqlplus with a here document to query a known table. If it shows up, everything's good. If not, send the email. For instance:
---------------------------
#!/bin/ksh
. $(oracle_environment_file}
( sqlplus /nolog << eof
connect 1/2 as sysdba
select file_name
from dba_data_files
order by file_name
/
eof
) > /tmp/dba_data_files.$$
lines=$(wc -l /tmp/dba_data_files.$$ | awk '{print $1}')
if [ ${lines} -lt 10 ]
then
### send email message to pager..
fi
--------------------------
Please note that was written on the fly in a web browser, not copied from a functioning script, so it may need some tweaking even on an oracle database.
Something like that, though, should work for db2 as well.
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2005 11:16 AM
тАО06-10-2005 11:16 AM
SolutionPasted below is a ksh script that does what you're looking for.
=============================================
#!/bin/ksh
#
db2 <
list tables for all
disconnect
quit
EOT
#
if [ $? -ne 0 ]; then
mailx -s "DB2 down!!!" your_email_address
exit 1
else
exit 0
fi
#
=============================================
best of luck!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2005 04:39 AM
тАО06-11-2005 04:39 AM
Re: ksh script to check db2 database connectivity
I like you're script, it's clean, simple and best of all it works.
Thanks all for you're help. This forum is great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-11-2005 04:40 AM
тАО06-11-2005 04:40 AM