Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to notify by mailx if disk is almost full 3

Status
Not open for further replies.

IThead

MIS
Sep 6, 2002
102
US
Hi,
Does anyone has any script that can check the disk usage by percentage? if any disk that is >90% (using df -k) will email an alert.

Thanks
 
strange error message.......

Are you sure the 3 arguments you pass to 'CHK_FILE_SPC' function are quoted with single quotes with spaces between the arguments?

What OS are you on?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi,

The arguments are correct.
CHK_FILE_SPC '/' '10' '%'

The O/S is HP-UX 11.00

Thanks
 
Thanks for the response. The execution pauses for about 6 seconds before giveing this error

Line 14 is

export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:
 
And what happens if you add set -x in the beginning of the CHK_FILE_SPC function ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I think the problem is here:

LOW_WATER_MARK = $AMOUNT * 1024

AMOUNT is get from:

export AMOUNT=`$DF $FILESYS | tail -1 | awk -v PERCENT=$2 '{print $2*PERCENT/100/1024}'`

and it is resulting in a float number, not integer. Try the commands by hands.
 
Sorry abt the delay. Ygor, gotta do this with df cmd only .. I will use bdf later....

Chacalinc, I verified.. it gives a float result. Now, I think LOW_WATER_MARK can't be defined as "integer". I tried "float" but it gives an error.

PHV, set -x at the beginning of the CHK_FILE_SPC function gives

+ date +%m%d
+ export DATE=0331
+ export TMP=/tmp/.chkfilspc.0331
+ export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:
+ hostname
+ export HOSTNAME=fddsms
+ export PROGRAM=temp.sh
+ export PAGE=/usr/local/bin/sendpage -n
+ export DF=df -k
+ set -x
+ CHK_FILE_SPC / 10 %
+ export FILESYS=/
+ [ % = % ]
+ df -k /
+ tail -1
+ awk -v PERCENT=10 {print $2*PERCENT/100/1024}
+ export AMOUNT=0
+ typeset -i FREE_SPACE LOW_WATER_MARK
+ + df -k /
+ tail -1
+ awk {print $3}
temp.sh[15]: allocation: The specified number is not valid for this command.

Line 15 is: export HOSTNAME=`hostname`
 
The problem is the format of df -k on hp-ux. Here's a demonstration..

$ export DF="df -k"
$ export FILESYS=/
$ FREE_SPACE=`$DF $FILESYS | tail -1 | awk '{print $3}'`
$ echo $FREE_SPACE
allocation

What you need to get the free space is the fourth field from bdf (or df -Pk)...

$ export DF="[highlight]bdf[/highlight]"
$ FREE_SPACE=`$DF $FILESYS | tail -1 | awk '{print [highlight]$4[/highlight]}'`
$ echo $FREE_SPACE
54812
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top