send mail through shell script

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
satisht
Participant
Posts: 15
Joined: Tue Nov 07, 2006 4:41 pm

send mail through shell script

Post by satisht »

Hi all,

I have to monitor disk space for the datastage projects on development and production on unix servers daily, I am generally using the commands to monitor disk space, but just to make the job easier I am just thinking of a shell script that would automatically generate a mail to me every 3 or 4 hours.
that how much disk space has been used?

Can anyone of you please suggest a shell script?


Thanks in advance
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

You can write a script to find the free space using

Code: Select all

df -k . | grep -v used | awk '{ print $2 " " $3 "      " $4 "          " $5 }'
Send a mail with mailx
You can schedule your script using cron or other scheduling tools, every 3 or 4 hours or whatever frequency you want.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: send mail through shell script

Post by DSguru2B »

satisht wrote:
Can anyone of you please suggest a shell script?
There is no pre-written shell script per se. But you can build your own as narasimha advised. A shell is nothing but unix commands bundled up on a file. Read about mailx, coupled that with whatever command you are using for checking disk space, viola, you have a shell script.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are you sure you have to monitor it? Most businesses will already have such monitoring in place and I've found you typically just need to let them know to include DataStage in that process. Check here every X and alarm when usage hits Y percent. Have you contacted your SAs and asked them? :?

Our 'DataStage' partition, for example, is checked every 15 minutes... in 3 or 4 hours the damage is more than likely already done.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply