Linux Common Oracle Monitoring shell scripts

Source: Internet
Author: User
Tags dba error code file system linux

This article describes 8 commonly used monitoring data shell scripts. First, we reviewed some of the UNIX commands commonly used by DBAs, and explained how to execute the DBA script regularly with Unix cron. Online also has good

Many similar articles, but basically can not run normally, take a little time to rearrange the next, can be used directly later.

First, the article introduces 8 important scripts to monitor Oracle databases:

1. Check the availability of the instance

2. Check the availability of the listener

3. Check the error message in the alert log file

4. Empty the old log file before the place where the log file is stored

5. Analyze table and index to get better performance

6. Check the use of table space

7. Find the Invalid object

8. Monitoring Users and Transactions

Second, the basic knowledge of UNIX required by the DBA

Basic UNIX commands, here are some common UNIX commands:

ps--Display Process

grep--a text pattern in a search file

mailx--read or send mail

cat--connect files or show them

cut--Select columns to display

awk--Pattern Matching language

df--display of remaining disk space

Here are some examples of how DBAs can use these commands:

1. Display the available instances on the server:

$ ps-ef| grep Smon

Oracle 22086 1 0 02:32:24 0:04 ora_smon_pprd10

Oracle 5215 28972 0 08:10:19 pts/4 0:00 grep smon

2. Display the available listeners on the server:

$ PS-EF | grep Listener |grep-v grep

(The grep command should be coupled with the-I argument, that is, the grep-i listener, which ignores case, because sometimes the listener is uppercase and the result is not visible)

$ ps-ef|grep-i Listener

Oracle 9655 1 0 Mar 0:01/data/app/oracle/9.2.0/bin/tnslsnr Listener-inherit

Oracle 22610 1 0 02:45:02 0:02/data/app/oracle/10.2.0/bin/tnslsnr Listener-inherit

Oracle 5268 28972 0 08:13:02 pts/4 0:00 grep-i Listener

3. View file system usage for Oracle Archive directory

$ df-k | Grep/data

/DEV/MD/DSK/D50 104977675 88610542 15317357 86%/data

4. Statistics of the number of lines in the Alter.log file:

$ Cat Alert_pprd10.log | Wc-l

13124

$ More Alert_pprd10.log | Wc-l

13124

5. List all Oracle error messages in the Alert.log file:

$ grep ora-* Alert.log

Ora-00600:internal error code, arguments: [Kcrrrfswda.1], [], [], [], [], []

Ora-00600:internal error code, arguments: [1881], [25860496], [25857716], []

6. Crontab Basic

A crontab file contains six fields:

Min 0-59

Hour 0-23

Day of the month 1-31

Month 1-12

Week 0-6, with 0 = Sunday

7. Unix command or shell script

To edit a Crontab file, enter: CRONTAB-E

To view a Crontab file, enter: Crontab-l

0 4 * * 5/dba/admin/analyze_table.ksh

3 * * 3,6/dba/admin/hotbackup.ksh/dev/null 2>&1

In the example above, the first line shows a script for the analysis table running at 5 4:00am per week. The second line shows a script to perform a hot backup of 3 per Wednesday and Saturday:

00A.M. Run.

Iii. Common shell scripts for monitoring databases

The 8 shell scripts provided below cover 90% of the DBA's daily monitoring work, and you may also need to modify the UNIX environment variables.

1. Check the availability of Oracle instances

All databases on the server are listed in the Oratab file

$ cat/var/opt/oracle/oratab

#

# This file is used by ORACLE utilities. It is created by root.sh

# and updated by the ' Database Configuration Assistant when creating

# a database.

# A Colon, ': ', is used as the field terminator. A New Line terminates

# The entry. Lines beginning with a pound sign, ' # ', are comments.

#

# Entries are of the form:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.