seeking help with shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting seeking help with shell script
# 1  
Old 10-04-2007
seeking help with shell script

I am trying to update a script which I had created to monitor tablespace usage.
Originally the sql spooled out to a text file anything with more than 75% used.
I have been asked to change this.
Now the sql must spool out all tablespaces.
The script I have to write should scan the file for values over 75% and if it encounters any it sends a high importance/priority email to the DBAs.
If no values above 75 are enountered it just sends out an informational email.
The bit I am having trouble with is the files scan for values 75 and over.
Any ideas from anyone?
# 2  
Old 10-04-2007
Would be of assistance to yourself to provide some insight as to type of shell you are using, platform and what you have so far in the way of your script.

Cheers,
Cameron
# 3  
Old 10-12-2007
Got it sussed.

The script I have is as follows from AIX 5L.
The bit i was trying to figure out is in bold. Took a bit of experimentation to get it right.

#!/usr/bin/sh
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/local/bi
n:/oracle/app/oracle/product/9.2.0/bin:.
export PATH

export DISTRIBUTION='****@*******.co.uk'

export TODAY=`date +'%d/%B/%Y'`
TNS_NAME=$1
export TNS_NAME
export ORACLE_HOME=/oracle/app/oracle/product/9.2.0
export ORAENV_ASK=NO
export warning_limit=75

PASSWORD=`grep $TNS_NAME ~oracle/dba_scripts/PASSWORDS/secure |cut -f2`
export PASSWORD

cd /oracle/dba_scripts

sqlplus /nolog <<EOF

connect system/$PASSWORD@$TNS_NAME
@/oracle/dba_scripts/percent_used1.sql
exit
EOF

export TBS_WARNINGS=`cat percent_used1.txt | awk '{print $2}'|sort -u -n -r|head -n1`
if [ $TBS_WARNINGS -ge $warning_limit ]
then
mailx -s"***CRITICAL*** Space report for "$TNS_NAME" on "$TODAY DISTRIBUTION < percent_used1.txt
else
mailx -s"Space report for "$TNS_NAME" on "$TODAY $DISTRIBUTION < percent_used1.txt

sleep 120
rm /oracle/dba_scripts/percent_used1.txt
exit 1
fi
# 4  
Old 10-12-2007
Quote:
Originally Posted by Niadh
I am trying to update a script which I had created to monitor tablespace usage.
Originally the sql spooled out to a text file anything with more than 75% used.
I have been asked to change this.

Now the sql must spool out all tablespaces.
The script I have to write should scan the file for values over 75% and if it encounters any it sends a high importance/priority email to the DBAs.
If no values above 75 are enountered it just sends out an informational email.
The bit I am having trouble with is the files scan for values 75 and over.
Any ideas from anyone?
Can you please provide the existing sql which use to spool only 75% used space, so that we can look insight what type of files it generating.....and then we could trace out....how to write the script
# 5  
Old 10-17-2007
Problem sorted

I got the Unix script sorted.
See my second post.

The script above produces the email as I needed.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Seeking Alternative for diff in hp

Hi , I have to use HP-unix OS to get difference between 2 files.while i tried a piece of code in other OS(linux/unix) as below, it worked fine & the output is desired one. diff --suppress-common-lines -y file_1 file_2 >d.txt The same doesn't works in HP -unix. Any help shall be... (6 Replies)
Discussion started by: vinil
6 Replies

2. Shell Programming and Scripting

Seeking help with search

Hello All, I'm looking for some help with grepping for two specific strings in files with multiple lines. For instance, I have files and the content looks like this: =====Start===== Record:1 Field 1 = aaaaaaaaaa Field 2 = bbbbbbbbbb Field 3 = 1234567890 ... (9 Replies)
Discussion started by: bbbngowc
9 Replies

3. Shell Programming and Scripting

Seeking assistance in Shell script

#!/bin/bash >error_log for s in `cat s.txt` do uptime $s >>error_log echo $s >>error_log done The above code produce output with server name and its uptime in 2 different lines .My requirement is to have the same in one line . Please assist (3 Replies)
Discussion started by: vinil
3 Replies

4. Programming

[C] seeking good books

I suppose everybody here read reference books like Kernighan & Ritchie one, but where's the real deal? I mean I'd like to learn more about special efficient techniques, tips&tricks, what compiler effectively does, and stuff like that. Could you please suggest me some books or internet... (1 Reply)
Discussion started by: Luke Bonham
1 Replies

5. Shell Programming and Scripting

Seeking for help in writing shell

Hi All, I got a problem and stuck to filter a log file, called it as "sample.log". This "sample.log" file is being generated by "script A". The "sample.log" look like below: :FORMATDATE_FORMATTIME:CmdArg->:SomeDoce:SomeFormatDocument: :FORMATDATE_FORMATTIME:imprtcp succeeded.... (1 Reply)
Discussion started by: anakiar
1 Replies

6. Shell Programming and Scripting

seeking help in text processing

Hi, I am a newbie in shell scripting. I want to get an expert help in solving a text processing issue. The issue I am facing is that, in the below log file contents I need to extract each block of lines (it could be a single line also) based on some regular expression and store it in... (8 Replies)
Discussion started by: Alecs
8 Replies

7. UNIX for Dummies Questions & Answers

Seeking help...Urgent!!! Please help me...

Can any1 please help me answer a couple of this question? 1) What is the process management of UNIX? (single task, multitasks, etc...) 2) What is the process management of Linux? (single task, multitasks, etc...) 3) What is the type of process of UNIX? (process, thread, etc...) 4)... (1 Reply)
Discussion started by: blind02002
1 Replies

8. UNIX for Dummies Questions & Answers

Seeking UNIX documentation

Hi, I am looking for documentation (PDF, DOC, books, web ...) about UNIX scripts. What could you advice me ? Thanks. (3 Replies)
Discussion started by: Filippo
3 Replies

9. Filesystems, Disks and Memory

seeking a doc on lvm etc...

Hi. I wanted to increase my knowledge base with unix. can you help me find a like that talks about luns, physical volumes, volume groups, logical volumes then mountpoints? i would appreciate it thanks Jigar (1 Reply)
Discussion started by: jigarlakhani
1 Replies
Login or Register to Ask a Question