INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

how can i fix this file in order to received the necessary e-mail messages ??

how can i fix this file in order to received the necessary e-mail messages ??

how can i fix this file in order to received the necessary e-mail messages ??

(OP)
dear all.
i'm a dba and i'm newbie with awk but im ready to give up with this --> :S .
So, i want to schedule a task in crontab at solaris that send e-mail message ONLY if the amount of GB in my filesystems exceeds the threshold configured.

The problem is that every execution (either exceeds or no the threshold) i receive an e-mail message, and ONLY i have to received message if the GB used is more than threshold that i putted.


Here are my lines of my script sh:
#------------------------------------START----------------------------------------
FEC_REPORT=`date "+%m/%d/%y %k:%M"`
export MAILTO="algo@dominio.com"

FS_LIMIT=$1

FS_GT=`df -k|grep -v boot|grep -v shm|awk '{print $5" "$6}' |/usr/xpg4/bin/awk -F"%" -v fs_limit=${FS_LIMIT} '$1 > fs_limit {print $1"%--->"$2}'`
if [ -n "${FS_GT}" ]
then
echo "${FS_GT}"|mailx -s "EMPRESA : File systems on `hostname` reached ${FS_LIMIT} USED: ${FEC_REPORT}" ${MAILTO}
fi
#--------------------------------------END--------------------------------------

i executed the script in this way: script.sh 80, where 80 is the threshold.

Please i need your help.
Thanks.
zipimon

RE: how can i fix this file in order to received the necessary e-mail messages ??

(OP)
PHV
thanks for your answers but i want to know how can i fix or change something in script in order to receive ONLY e-mail messages when the threshold value exceeds.
If the threshold value doesnt exceeds i wont receive an e-mail.
Actually either the threshold exceeds or no i received an e-mail.

Hopefully you can help me
thanks again

RE: how can i fix this file in order to received the necessary e-mail messages ??


Try this:

CODE

FEC_REPORT=`date "+%m/%d/%y %k:%M"`
export MAILTO="algo@dominio.com"

FS_LIMIT=$1

FS_GT=`df -k|grep -v boot|grep -v shm|awk '{print $5" "$6}' |/usr/xpg4/bin/awk -F"%" -v fs_limit=${FS_LIMIT} '$1 > fs_limit {print $1"%--->"$2}'`
if [ -n "${FS_GT}" ]
then
  echo "${FS_GT}"|mailx -s "EMPRESA : File systems on `hostname` reached ${FS_LIMIT} USED: ${FEC_REPORT}" ${MAILTO} 
fi 
3eyes

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: how can i fix this file in order to received the necessary e-mail messages ??

(OP)
Thanks guy for your answer..
I changed (;) but unfortunatelly the behavior is the same. My code shows here:

CODE -->

FEC_REPORT=`date "+%m/%d/%y %k:%M"`
export MAILTO="algo@dominio.com"
FS_LIMIT=$1

FS_GT=`df -k|grep -v boot|grep -v shm|awk '{print $5" "$6}' |/usr/xpg4/bin/awk -F"%" -v fs_limit=${FS_LIMIT} '$1 > fs_limit {print $1"%--->"$2}'`
if [ -n "${FS_GT}" ]
then
echo "${FS_GT}"|mailx -s "Empresa : File systems  on `hostname` reached ${FS_LIMIT} USED: ${FEC_REPORT}" ${MAILTO}
fi 

My OS is : SunOS HOSTNAME 5.10 Generic_142901-03 i86pc i386 i86pc

more ideas ??? :(

RE: how can i fix this file in order to received the necessary e-mail messages ??

(OP)
thanks PHV for your answer.
Humm i try to explain my issue :


1.- /opt --> 81 used.
2.- If i executed:
2.1.- script.sh 85 <ENTER>
Result now: I receive an e-mail with that body:
capacity Mounted%--->
DESIRABLE RESULT: i Wont receive any e-mail. Why ?? because the threshold (85) is greater than the Gb used (81) in /opt File system.

2.2.- script.sh 80 <ENTER>
Result now: I receive an e-mail with that body:
capacity Mounted%--->
81%---> /opt
DESIRABLE RESULT: This. I mean if the threshold (80) is less than the Gb occuped (81) in /opt filesystem i will received an e-mail with details like this example.

Actually i received e-mail when the threshold is reached or passed and e-mail when the threshold is not reached too.
ONLY, I want to received e-mail messages when the threshold reached or passed.

I hope letting me understand.
thanks again

RE: how can i fix this file in order to received the necessary e-mail messages ??

Ooops sorry, I posted the wrong code.
Try this:

CODE

FEC_REPORT=`date "+%m/%d/%y %k:%M"`
export MAILTO="algo@dominio.com"

FS_LIMIT=$1

FS_GT=`df -k|grep -v boot|grep -v shm|awk '{print $5" "$6}' |/usr/xpg4/bin/awk -F"%" -v fs_limit=${FS_LIMIT} 'int($1) > int(fs_limit) {print $1"%--->"$2}'`
if [ -n "${FS_GT}" ]
then
  echo "${FS_GT}"|mailx -s "EMPRESA : File systems on `hostname` reached ${FS_LIMIT} USED: ${FEC_REPORT}" ${MAILTO}
fi 
noevil
PS: notice the part:

CODE

"...int($1) > int(fs_limit) ..." 

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: how can i fix this file in order to received the necessary e-mail messages ??

(OP)
Thanks PHV for your help.
It works. !!!

RE: how can i fix this file in order to received the necessary e-mail messages ??

(OP)
thanks LKBrwnDBA for your answer too.

Only an additional question, now, the e-mail comes with its body :

88%---> /opt

but if i want to the e-mail comes with its head like this:


capacity Mounted%--->
88%---> /opt


it is possible to do that? how ??

Meanwhile i work with your advices but if u want i really appreciated if you can answer this question.
Thanks.

RE: how can i fix this file in order to received the necessary e-mail messages ??



Change the "echo":

CODE

if [ -n "${FS_GT}" ]
then
  echo "\n\n\t\tCapacity Mounted% --->\n\t\t\t${FS_GT}"|  mailx -s "EMPRESA : File systems on `hostname` reached ${FS_LIMIT} USED: ${FEC_REPORT}" ${MAILTO}
fi 
medal

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: how can i fix this file in order to received the necessary e-mail messages ??

(OP)
dear Lk
thanks but now the e-mail comes like this.

CODE -->

\n\n\t\tCapacity Mounted% --->\n\t\t\t88%---> /opt 

any idea ??
thanks again

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close