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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating a filesystem free-space check? 3

Status
Not open for further replies.

krawz187

MIS
Mar 19, 2002
27
US
Hello,

I'm pretty new to AIX. My company sent me out for training just a few weeks ago, after our senior AIX administrator left the company. In taking over his environment, I've run across quite a few maintenance related tasks that seem better suited for automation.

Case in point, I am asked to maintain the free-space of a certain filesystem, so that 1gig of free-space is always available. Manually checking filesystems every day is something that gets a little repetitive and feels like a waste of time. However, this is a mission-critical filesystem, that is running in a production environment, so I need to stay on top of it.

I'm wondering if any of you AIX veterans out there, know a way to create a script and/or job to monitor the free-space of a filesystem, and report back to me when it is approaching a "danger" level of free-space, if you will. My first thought was some kind of solution incorporating a similar logic to something like.. : df -k /filesystemX |grep filesystemX .... and here is where I get lost. Perhaps sending the output to something like "awk" to find the number before the % sign showing free-space remaining, and then sending those results via sendmail at intervals of the day...but anyway, I don't have the technical know-how yet to set this up myself.

Any opinions or ideas would be greatly appreciated!

Kind regards,
Justin

 
Code:
#!/bin/ksh

FILESYSTEM="/mountpoint/of/filesystem"
FREESPACE=$(df -Pk ${FILESYSTEM} | awk '$4 ~ /[0-9]+/{print $4}')

if [ ${FREESPACE} -lt 1048576 ]
then
echo "Filesystem free space: ${FREESPACE}"       | mail -c root -s "Low space warning: ${FILESYSTEM}" krawz187
fi

cron as desired. (man cron;man crontab)

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Nice script Rod! (As always!)

You could also add a couple of lines for this script to look at all of your filesystems:


Code:
#!/bin/ksh


FILESYSTEMS="/ /usr /var /export"
for FILESYSTEM in $FILESYSTEMS
do
  FREESPACE=$(df -Pk ${FILESYSTEM} | awk '$4 ~ /[0-9]+/{print $4}')
  if [ ${FREESPACE} -lt 1048576 ]
  then
  echo "Filesystem free space: ${FREESPACE}"         | mail -c root -s "Low space warning: ${FILESYSTEM}" krawz187
  fi
done
 
Excellent! Looking forward to trying this in the morning :) Thanks a bunch for the quick response.
 
You could have a look at Big Brother monitoring software(from It monitors things like disk space & network connections and be configured to email & send page alerts.

Perhaps overkill for monitoring one filesystem on one server, but if you look after multiple machines its well worth a look.
 
hello,

more simply (?), you have a graphical and free tool shipped with AIX, called RSCT. You define triggers (related to CPU usage, free space on filesystem, or whatever you want - there are hundred of parameters to monitor), and you then define a response (send snmp trap, send a mail, launch a program, etc etc). This tool is accessible from WebSM, a graphical administration tool installed automatically with any system having a graphical screen.

Just type
wsm
from a graphical screen, and play a bit with it. The interface is rather nice (looks like Tivoli IT Director).

regards,
 
FYI, to save a futile search on an older system:

RSCT was added to the base operating system with AIX 5L 5.0.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top