[SunHELP] DiskUsage Monitorind Script

Girguis, Ashraf sunhelp at sunhelp.org
Mon Aug 20 14:33:53 CDT 2001


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C129AF.21999154
Content-Type: text/plain;
	charset="iso-8859-1"

#!/bin/sh
################################
# Script to check disk space. The script uses
# the paramater passed to it from the command
# line and (if exists) a data file that
# specifies individual file systems limits.
 
# format of exceptions file:
#     {file system} {new limit}
#     /opt 75
 
################################
 
limit="$1"
home="`pwd`"
infile="$home/`basename $0`.exceptions"
fsystems=`df -k | egrep '^/dev|^swap' | awk '{print $6}'`
 
#########################
 
pageadmins()
{
 # send email documentation and annoying page
 df -k | mailx -s "`hostname`:${fs} ${cap}% (limit=${limit}%)" unixsa
 mailx -s "`hostname`:${fs} ${cap}%" beeper_unixsa < /dev/null
}
 
#########################
 
# check for command line value
if [ ! "${limit}" ]
then
 echo "Usage: `basename $0` {capacity limit}"
 exit
fi
 
# go thru local file systems & /tmp
for fs in $fsystems
do
 # check current capacities against limit
 cap=`df -k $fs | tail -1 | awk '{print $5}' | sed 's/%//g'`
 if [ $cap -ge $limit ]
 then
  sendpage="yes"
 
  # if current capacity too much, check exceptions file
  # if no file exists, newlimit will be null
  newlimit=`grep -s $fs $infile | awk '{print $2}'`
  if [ "${newlimit}" -a $cap -lt $newlimit ]
  then
    sendpage="no"
  fi
 
  # file system still too full? page admins
  if [ $sendpage = "yes" ]
  then
   limit=$newlimit
   pageadmins
   exit
  fi
 fi
done
 
 
 
 
I hope this helps
Thanks
Ashraf

-----Original Message-----
From: Wally A. Alubankudi [mailto:walubank at hotmail.com]
Sent: Monday, August 20, 2001 1:26 PM
To: sunhelp at sunhelp.org
Subject: [SunHELP] DiskUsage Monitorind Script



Hi All,
           Does anyone has a simple kornshell diskusage monitoring script???
Wally



  _____  

Get your FREE download of MSN Explorer at http://explorer.msn.com
<http://go.msn.com/bql/hmtag_itl_EN.asp> 
_______________________________________________ SunHELP maillist -
SunHELP at sunhelp.org http://www.sunhelp.org/mailman/listinfo/sunhelp


------_=_NextPart_001_01C129AF.21999154
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.00.3314.2100" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#0000ff face=Arial 
size=2>#!/bin/sh<BR>################################<BR># Script to check disk 
space. The script uses<BR># the paramater passed to it from the command<BR># 
line and (if exists) a data file that<BR># specifies individual file systems 
limits.<BR> <BR># format of exceptions file:<BR>#     
{file system} {new limit}<BR>#     /opt 75</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial 
size=2>################################</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial 
size=2>limit="$1"<BR>home="`pwd`"<BR>infile="$home/`basename 
$0`.exceptions"<BR>fsystems=`df -k | egrep '^/dev|^swap' | awk '{print 
$6}'`</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial 
size=2>#########################</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2>pageadmins()<BR>{<BR> # send 
email documentation and annoying page<BR> df -k | mailx -s 
"`hostname`:${fs} ${cap}% (limit=${limit}%)" unixsa<BR> mailx -s 
"`hostname`:${fs} ${cap}%" beeper_unixsa < /dev/null<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial 
size=2>#########################</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2># check for command line value<BR>if 
[ ! "${limit}" ]<BR>then<BR> echo "Usage: `basename $0` {capacity 
limit}"<BR> exit<BR>fi</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2># go thru local file systems & 
/tmp<BR>for fs in $fsystems<BR>do<BR> # check current capacities against 
limit<BR> cap=`df -k $fs | tail -1 | awk '{print $5}' | sed 
's/%//g'`<BR> if [ $cap -ge $limit ]<BR> then<BR>  
sendpage="yes"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2>  # if current capacity too 
much, check exceptions file<BR>  # if no file exists, newlimit will be 
null<BR>  newlimit=`grep -s $fs $infile | awk '{print $2}'`<BR>  if [ 
"${newlimit}" -a $cap -lt $newlimit ]<BR>  then<BR>    
sendpage="no"<BR>  fi</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2>  # file system still too full? 
page admins<BR>  if [ $sendpage = "yes" ]<BR>  then<BR>   
limit=$newlimit<BR>   pageadmins<BR>   exit<BR>  
fi<BR> fi<BR>done</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=611563319-20082001>I hope 
this helps</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN 
class=611563319-20082001>Thanks</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN 
class=611563319-20082001>Ashraf</SPAN></FONT></DIV>
<BLOCKQUOTE>
  <DIV align=left class=OutlookMessageHeader dir=ltr><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Wally A. Alubankudi 
  [mailto:walubank at hotmail.com]<BR><B>Sent:</B> Monday, August 20, 2001 1:26 
  PM<BR><B>To:</B> sunhelp at sunhelp.org<BR><B>Subject:</B> [SunHELP] DiskUsage 
  Monitorind Script<BR><BR></DIV></FONT>
  <DIV>
  <DIV><BR>Hi All,</DIV>
  <DIV>           Does anyone 
  has a simple kornshell diskusage monitoring script???</DIV>
  <DIV>Wally<BR><BR></DIV></DIV><BR clear=all>
  <HR>
  Get your FREE download of MSN Explorer at <A 
  href="http://go.msn.com/bql/hmtag_itl_EN.asp">http://explorer.msn.com</A><BR>_______________________________________________ 
  SunHELP maillist - SunHELP at sunhelp.org 
  http://www.sunhelp.org/mailman/listinfo/sunhelp</BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C129AF.21999154--



More information about the SunHELP mailing list