Sponsored Content
Top Forums Shell Programming and Scripting Shell script to capture ORA errors from Alert Log Post 302528901 by radoulov on Wednesday 8th of June 2011 07:29:56 AM
Old 06-08-2011
Modified the script as per your requirement (mail in any case).
There was an error in the previous version of the script that I corrected: oraenv wasn't sourced. You may need to adjust the path to oraenv.

Code:
#!/bin/bash


ORACLE_HOME=<your_oracle_home>
ORACLE_SID=<your_oracle_sid>
ORAENV_ASK=NO
export ORACLE_HOME ORACLE_SID ORAENV_ASK

# you may need to adjust the path to oraenv
. "$ORACLE_HOME"/bin/oraenv

_mailto=<your_email_address>
_mail_subject_ok="No ORA- for $ORACLE_SID on $HOSTNAME"
_mail_subject_ko="ORA- for $ORACLE_SID on $HOSTNAME"

_today=$(
  date '+%Y-%m-%d 00:00:00'
  )
_yesterday=$(
  date -d yesterday +'%Y-%m-%d 00:00:00'
  )  

_my_result=$(
  adrci exec="
    set home $ORACLE_SID;
    show alert -term -P \\\"MESSAGE_TEXT like '%ORA%' and ORIGINATING_TIMESTAMP between '$_yesterday' and '$_today'\\\"
   "
  )

[[ $_my_result == *ORA-* ]] && 
  _mail_subject=$_mail_subject_ko ||
    _mail_subject=$_mail_subject_ok

mailx -s "$_mail_subject" "$_mailto" <<< "$_my_result"


Please post the output of bash -xv <script_name> so I can verify the correct execution.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get ORA errors in alertlog file using shell script.

Hi, Can anyone tell me how to get all ORA errors between two particular times in an alertlog file using shell script. Thanks (3 Replies)
Discussion started by: suman_dba1
3 Replies

2. Shell Programming and Scripting

Script to capture errors

Hello; I'm trying to write a script to capture any hardware error from logs/syslog on my SUSE 10 servers so i can be notified if we have any hardware issues such a bad fan or battery, etc.. Thanks in advance for any help (2 Replies)
Discussion started by: Katkota
2 Replies

3. Shell Programming and Scripting

Need to capture the service name from tnsnames.ora and create connect string

ghkjkjoj (4 Replies)
Discussion started by: chetankelvin
4 Replies

4. Shell Programming and Scripting

Script to capture date/time in seconds in PERL... Cant understand errors

I'm Using this script to find the time of a file. I'm very much new to PERL and found this script posted by some one on this forum. It runs perfectly fine, just that it gives me following errors with the accurate output as well. I jus want the output to be stored in another file so that i can... (0 Replies)
Discussion started by: bankimmehta
0 Replies

5. UNIX for Advanced & Expert Users

grep all ORA errors except one ORA error

Hi - I am trying to grep all "ORA" errors in a log files.I have to grep all ORA errors except one error for example ORA-01653.How can exclude that error in "grep" command? In following "grep" command I want to exclude "ORA-01653" error grep -i ORA alert.log >>/tmp/ora_errors.txt ... (7 Replies)
Discussion started by: Mansoor8810
7 Replies

6. Shell Programming and Scripting

Capture makefile errors in shell script

Hi, I have a bash script which calls a few "make". I would like to know whether the makefile failed with any errors. How do I do that in the script? Thanks, S (2 Replies)
Discussion started by: suryaemlinux
2 Replies

7. Shell Programming and Scripting

How to turn off ora errors in shell script?

I have a shell script which select total count from a table and use its value in a if condition like below connect_string="username/password@tnsname" tot=`sqlplus -s $connect_string << EOF set echo off set feedback off set head off select count(*) from test_table; EOF ` if then echo... (2 Replies)
Discussion started by: vel4ever
2 Replies

8. Shell Programming and Scripting

Extracting Sysdate-1 ORA Errors - Can you help me in this UNIX Script?

Hi Guys, I wanted to create an Unix Shell Script that should fetch a particular string from a text file on a particular date. We all know Oracle generates alert logs for each and every day for every actions in the database. I have an alert log file now where it contains for about a months... (4 Replies)
Discussion started by: raja_dba
4 Replies

9. Shell Programming and Scripting

Shell script to capture Current day ORA errors from Alert Log

Please provide Shell script to capture ORA errors from Alert Log for a given date or Current date. -Veera (1 Reply)
Discussion started by: Veera_V
1 Replies

10. Shell Programming and Scripting

Check for “errors” or “ORA-”

I want to check for "errors" or "ORA-" in Y.if there is an error then exit Y=`sqlplus -s user/passwd<< EOF exec test_Proc; exit; EOF` if ; then exit 1 fi but this doesnt work (6 Replies)
Discussion started by: haadiya
6 Replies
CONTROL.CTL(5)							File Formats Manual						    CONTROL.CTL(5)

NAME
control.ctl - specify handling of Usenet control messages DESCRIPTION
The file /etc/news/control.ctl is used to determine what action is taken when a control message is received. It is read by the parsecon- trol script, which is called by all the control scripts. (For an explanation of how the control scripts are invoked, see innd(8).) The file consists of a series of lines; blank lines and lines beginning with a number sign (``#'') are ignored. All other lines consist of four fields separated by a colon: message:from:newsgroups:action The first field is the name of the message for which this line is valid. It should be either the name of the control message, or the word ``all'' to mean that it is valid for all messages. The second field is a shell-style pattern that matches the email address of the person posting the message. (The poster's address is first converted to lowercase.) The matching is done using the shell's case statement; see sh (1) for details. If the control message is ``newgroup'' or ``rmgroup'' then the third field specifies the shell-style pattern that must match the group being created or removed. If the control message is of a different type, then this field is ignored. The fourth field specifies what action to take if this line is selected for the message. The following actions are understood: doit The action requested by the control message should be performed. In most cases the control script will also send mail to usenet. doifarg If the control message has an argument, this is treated as a ``doit'' action. If no argument was given, it is treated as a ``mail'' entry. This is used in ``sendsys'' entries script so that a site can request its own newsfeeds(5) entry by posting a ``sendsys mysite'' article. On the other hand, sendsys ``bombs'' ask that the entire newsfeeds file be sent to a forged reply-to address; by using ``doifarg'' such messages will not be processed automatically. doit=file The action is performed, but a log entry is written to the specified log file, file. If file is the word ``mail'' then the record is mailed. A null string is equivalent to /dev/null. A pathname that starts with a slash is taken as the absolute filename to use as the log. All other pathnames are written to /var/log/news/file.log. The log is written by writelog (see newslog(8)). drop No action is taken; the message is ignored. log A one-line log notice is sent to standard error. Innd normally directs this to the file /var/log/news/errlog. log=file A log entry is written to the specified log file, file, which is interpreted as described above. mail A mail message is sent to the news administrator. Lines are matched in order; the last match found in the file is the one that is used. For example, with the following three lines: newgroup:*:*:drop newgroup:tale@*.uu.net:comp.*|misc.*|news.*|rec.*|sci.*|soc.*|talk.*:doit newgroup:kre@munnari.oz.au:aus.*:mail A newgroup coming from ``tale'' at a UUNET machine will be honored if it is in the mainstream Usenet hierarchy. If ``kre'' posts a new- group message creating ``aus.foo'', then mail will be sent. All other newgroup messages are ignored. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.8, dated 1996/09/06. SEE ALSO
innd(8), newsfeeds(5), scanlogs(8). CONTROL.CTL(5)
All times are GMT -4. The time now is 09:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy