Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Off topic: Unix problem on Sunos 8

RE: Off topic: Unix problem on Sunos 8

From: Glenn Travis <Glenn.Travis_at_wcom.com>
Date: Fri, 12 Jan 2001 15:02:27 -0500
Message-Id: <10739.126556@fatcity.com>


Here is a script I use to email me when a filesystem gets too full. Hope it helps...

BEGIN


#!/bin/ksh
#
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# Purpose:
# To monitor filesystem usage.
#
# If the filesystem is over the specified
# threshold, an email will be sent.
#
# Parameters:
# $1 - email to send notification to.
# $2 - filesystem to check:%full threshold.
# $x - filesystem to check:%full threshold.
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

if [ $# -lt 2 ]

then	echo "Syntax: $0 <emailtonofity> <filesystem:threshold>."
	echo "Example: $ chkfilesystem.ksh person_at_address.com /tmp:95
/export/home:80 /export/tools:90 ..."
	exit 1

fi

TMPFIL=/tmp/chkfilesystem.tmp.$$
HST=`hostname`

EMAIL=$1
shift

while [ "$1" != "" ]
do

	FILESYS=`echo $1 | cut -f1 -d':'`
	THRESHOLD=`echo $1 |cut -f2 -d':'`

	grep "$FILESYS" /etc/vfstab > /dev/null 2>&1
	if [ $? -ne 0 ]
	then	echo "Filesystem $FILESYS does not exist on $HST."
		exit 1
	fi

	echo "Checking $FILESYS > ${THRESHOLD}%..."  | tee $TMPFIL

	pctg=`df -k | grep -i $FILESYS | awk '{print $5}' | tr -d %`

	if [ $pctg -gt $THRESHOLD ]
	then	echo "$FILESYS filesystem on $HST is ${pctg}% full."
		df -k $FILESYS | tee -a $TMPFIL
		mailx -s "$FILESYS on $HST ${pctg}% full!!  Please investigate." $EMAIL <
$TMPFIL
		rm $TMPFIL
	fi

	shift

done

END
> -----Original Message-----
> From: root_at_fatcity.com [mailto:root_at_fatcity.com]On Behalf Of Viraj
> Luthra
> Sent: Thursday, January 11, 2001 12:46 AM
> To: Multiple recipients of list ORACLE-L
> Subject: Off topic: Unix problem on Sunos 8
>
>
> Hi,
>
>
> Apologies for going off topic but I need help.
>
> The following piece of code is giving me a problem on SUNOS 5.8
> or Solaris 8:-
>
>    CheckAgtB()
>   {
>      awk "BEGIN {rc = $1 + 0 <= $2 + 0 ;} END {exit rc}" /dev/null
>      return $?
>   }
>
> if CheckAgtB $tmpspaceavail $tmpspaceneeded; then
>    ECHO "Sufficient space available."
> fi
>
>
> The above code basically compares tmpspaceavail value with
> tmpspaceneeded. If tmpspaceavail is more than tmpspaceneeded
> (which will be the case), then it returns true and prints the
> message "Suffecient space available".
>
> But that piece of code does not work on Solaris 8 but does work
> on other platforms like AIX 4.33 or HP 11etc.
>
> Could you please help. I have tried different calculating
> utilities like bc or expr but none seem to work. Please help.
>
> Regards,
>
> Raja
>
>
> Get your small business started at Lycos Small Business at
> http://www.lycos.com/business/mail.html
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Viraj Luthra
>   INET: viraj999_at_lycos.com
>
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
Received on Fri Jan 12 2001 - 14:02:27 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US