seeking help with shell script


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
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  
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  
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  
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  
Problem sorted

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

The script above produces the email as I needed.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #44
Difficulty: Easy
Data moves through the Internet in a data structure called a 'packet'.
True or False?

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. Programming

Seeking Some libs for AIX 5.3

hello everybody! I m compiling some program with the g++ on AIX 5.3 and it needs some library that i didn't find them i am new with the AIX here is the compilation error : g++ -Daix -fpic -o printps -lxercesc1_1 -L/oracle/OraHome/lib32/ -L/epost2/blitz/lib -lhmltods -lhmltops -lgeneric... (0 Replies)
Discussion started by: eternalflame
0 Replies

8. 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

9. 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

Featured Tech Videos