simple script to alert of archive logs filling


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simple script to alert of archive logs filling
# 1  
Old 06-17-2008
simple script to alert of archive logs filling

Hi all.
I am not a DBA. But I do have responsibility for making sure the archive logs dont fill up and cause the database. This happend the other day while I was absent (sick) and I got a good ticking off for it.

Needless to say I dont want this happen!

Could anyone lend a hand to a complete novice here and explain how I could run a script that would alert me and my boss by email if the archive logs got to over 90% ???

We are running Oracle 9 on AIX Version 5.2.

Many thanks in advance.
# 2  
Old 06-17-2008
Question archive logs got to over 90%

Are you referring to a specific file, directory, or mounted filesystem?

The basic process would be:
create a script that cron will run every xx minutes/hours/etc...

The script will:
look at the file/directory/filesystem
detemine the math of 'how full'
if 'how full' > 90, send an email
# 3  
Old 06-17-2008
directory : oradbi1/oracle/logs
# 4  
Old 06-17-2008
Code:
du -k oradbi1/oracle/logs

That will tell you how many k are allocated/used. Is there a hard number you want this tracked against? (For example, the above command may return 543560 meaning 543M used; but maybe you do not want to exceed 600M.)
# 5  
Old 06-17-2008
OK thanks for the reply.
Actually there is just this directory that I need to monitor - /archlogs.
Here is a copy of what I see when I do df -m:


/dev/lv02 8064.00 7810.80 4% 17 1% /archlogs


So the size is 8064M. So once it hits around 7257M I would like an email fired to me and my boss.
# 6  
Old 06-17-2008
workings for the script

The following is a script that would use what you just told me; remember to delete the # comments from the df command line and the mailx command line.

Code:
> cat check_size 
#! /bin/bash
# check amount of space in use

#df -m >tmp_log_anal

curr_spc=$(cat tmp_log_anal | tr -s " " | cut -d" " -f3 | cut -d"." -f1)
echo $curr_spc

#send messages if above threshold

if [ $curr_spc -ge 7257 ]
   then
   echo "Threshold exceeded"
#   mailx -s "log file nearly full" abc@123.com 
fi

explaining this:
Code:
curr_spc=$(cat tmp_log_anal | tr -s " " | cut -d" " -f3 | cut -d"." -f1)

gets rid of extra space characters
using space char as delimiter, takes the 3rd field
now using period as delimiter, takes the 1st field (tricky way to get a whole number from a decimal)
# 7  
Old 06-17-2008
Thanks!
Im nots ure about one thing though - tmp_log_anal
I dont see any inclusion of the /archlogs directory contents.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[bash] script is filling up my /var/log

I am trying to create a script that checks if my VPN connection is up and running... Everything seems to work as except but for some reason, the script fills up my /var/log/auth.log with the below information Dec 13 01:07:44 debian sudo: soichiro : TTY=pts/0 ; PWD=/home/soichiro/Desktop ;... (5 Replies)
Discussion started by: soichiro
5 Replies

2. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

3. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

4. Shell Programming and Scripting

Script filling password from command line

I have this command that i am calling from php (exec()): openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12 and then i need to insert password twice Enter Export Password: Verifying - Enter Export Password: I need script that will fill the password... (3 Replies)
Discussion started by: rockyada
3 Replies

5. Solaris

archive logs mount point space check script

I have the below shell script which is checking /archlog mount point space on cappire(solaris 10) server. When the space usage is above 80% it should e-mail. When i tested this script it is working as expected. -------------------------------------------------------------------------... (0 Replies)
Discussion started by: dreams5617
0 Replies

6. Shell Programming and Scripting

simple script to alert if internet not working?

Hi, I am constantly automaticaly downloading a few things on the internet but since my internet connection is unstable, it sometimes wont work. Thing is the internet will appear to be connected, but no website can be accessed and no program can successfully connect to any location. I can fix... (4 Replies)
Discussion started by: fuzzylogic25
4 Replies

7. Shell Programming and Scripting

Filling out Web Form from Script

I am trying to fill out a web form from within a script I am writing. I think that I should be using curl to do this, but I'm not really sure. The form has username and password fields and a submit button. I want to be able to log in from the command line. Html from the site: <h5... (2 Replies)
Discussion started by: vockleya
2 Replies

8. UNIX for Advanced & Expert Users

how to archive logs older than 5 days & then delete them?

My code is tar -cvf logs.tar `find /usr/openv/logs/512*.log -mtime +2` && find *.log* -mtime +2 -exec rm {} \; this gives me output as: tar: Missing filenames:confused: (1 Reply)
Discussion started by: timus1980
1 Replies
Login or Register to Ask a Question