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

Disk Space monitoring 4

Status
Not open for further replies.

sendhilk

IS-IT--Management
Mar 29, 2001
109
0
0
US

Hi,

Does anyone know of any tool that would monitor my filesystems and send a mail when it is getting full.I want to get some kinda network and system monitoring tool too. Is anyone aware of any freeware ??

Thanks,
Sendhil
 
I had the same problem, but had no money to throw at it - so I scripted it.

Using a central server, I used the rsh command to get information using df (amongst other things). The relevant information was stripped out and held in a logfile. An hour or so later the same is done, but this time the current values are compared against the previously held values. The output from this compare is then mailed to user on the [central] server.

If you're interested I could forward you some code that you could amend to suit your own setup?

Cheers.
Dave V.
 
i dunno product that will do the thing but a temporary solution that might help you.

* try using "df -k" from prompt command, it'll give you the much-needed actual reading of the system space usage.

* check which filesystem/s (FS) belongs to a particular physical volume by using "lspv -l hdisk#", hdisk# refers to disk number.

* check physical volume for available space by "lspv hdisk#", you can increase the size of FS; "chfs /usr -size=#"

* try to check maximum PPs and LPs before increasing FS.

'hope it'll give you something to start with.
 
Dave v:

I would be interested in the code. Can you post it here or in the Unix scripting forum?
 

yeah could u please post it here .

thanks,
sendhil
 
This is what I use, running at set times from the cron:

#!/bin/ksh
# ========================================================
#
# Check file system for disk full and sends messages
#
# Parameters : $1 = Message Header (Node identification)
# $2 = level 1 message (in %)
# $3 = level 2 message (in %)
# $4 = reset level (in %)
# $5 = file system (tmp, var etc.)
#
# ========================================================

df | grep $5 > $5.z
sed '/tmp/q' $5.z > $5.x
sed -e 's/%//' $5.x > $5.y
XXX=`awk '{print $4}' $5.y`
LAST=`awk '{print $1}' tmp/$5.last`
################################################
# send message level 1 #
################################################
if [ "$XXX" -ge "$2" ] && [ "$LAST" -lt "$2" ]
then
MSG="$1: /$5 File System $2% Full!"
echo $MSG > tmp/msg.txt
mail -s HOSTNAME me@domain.com < tmp/msg.txt
echo $MSG
echo $2 > tmp/$5.last
fi
#################################################
# send message level 2 #
#################################################
if [ &quot;$XXX&quot; -ge &quot;$3&quot; ] && [ &quot;$LAST&quot; -eq &quot;$2&quot; ]
then
MSG=&quot;$1: /$5 File System $3% Full!!&quot;
echo $MSG > tmp/msg1.txt
mail -s HOSTNAME me@domain.com < tmp/msg1.txt
echo $MSG
echo $3 > tmp/$5.last
fi
#################################################
# reset last #
#################################################
if [ &quot;$XXX&quot; -lt &quot;$4&quot; ]
then
echo $XXX > tmp/$5.last
fi

This is what my cron entries looks like to monitor the usr.var and tmp file systems:
# Check file systems and send email when 80% & 90% full
10,40 * * * * diskchk.sh HOSTNAME 80 90 79 usr
11,41 * * * * diskchk.sh HOSTNAME 80 90 79 var
12,42 * * * * diskchk.sh HOSTNAME 80 90 79 tmp

HOSTNAME = your machine host name
me@domain.com = your email address

Hope this will help you.

 
This is the script that I mentioned - it runs from a central server so that there is only ever one copy of the files irrespective of how many hosts are being checked.

Also this script only mails changes to filesystem size, and only filesystems over 80% full are monitored.

Amend the values of the HOSTS and OUTPUT_FILE variables to suit your setup. Include the pathname in OUTPUT_FILE.


#!/usr/bin/ksh

############################################################
# FILE: df_check.sh
# VERSION: 2.1
# WRITTEN BY: D Vickers
############################################################
# REQUIRES: rsh access to remote nodes
############################################################
# OTHER FILES:
# creates config file to keep date of previous check.
# creates file ddmmyy.df to maintain df information.
############################################################
# MODIFICATIONS:
# DATE AUTHOR CHANGE
# ===== ====== ======
# 11/06 DV Amended script to mail root user.
# 11/06 DV Added better mail message when no change.
############################################################
## BUG-TRAQ:
## DATE REPORTED BY DESCRIPTION
## ===== =========== ===========
## 11/06 DV Does not mail relevant hostname
## with filesystem, which is a hassle
## if filesystem is /home or something.
## 11/06 DV COMPLETED. (amended awk statement).
##
## 12/06 DV Under certain scenarios the old
## dfout.PID file does not get removed.
############################################################

############################################################
# Set variables.
############################################################
# You may change these values to reflect hosts checked.
############################################################

HOSTS=&quot;hostname1 hostname2 hostname3 hostname4&quot;

############################################################
# Do not change anything below this line.
############################################################
DFCHK_CFG=&quot;dfchk.cfg&quot;
OUTPUT_FILE=&quot;/tmp/dfout.$$&quot;
MAIL_FILE=&quot;df.mail&quot;
SUBJECT=&quot;Usage checks: &quot;`date`

############################################################
# Loop through hosts to get df values.
############################################################
for host in `echo ${HOSTS}`
do
echo &quot;HOSTNAME: ${host}&quot;
rsh ${host} df -k|tr -d &quot;%&quot;| awk 'BEGIN{getline} $4 > 80 {print $4,hostnm,$7}' hostnm=${host} | sort +0 -r -n 2> /dev/null
echo &quot;\n&quot;
done > ${OUTPUT_FILE}

############################################################
# Check against previous findings.
############################################################

############################################################
# Ensure that previous findings are available...
# ...get value from $DFCHK_CFG file.
############################################################
if [ ! -f ${DFCHK_CFG} ]
then
touch ${DFCHK_CFG}
fi

PREVIOUS_OUTPUT=`head -1 $DFCHK_CFG`
if [ -z &quot;${PREVIOUS_OUTPUT}&quot; ]
then
echo &quot;ERROR: previous value does not exist&quot;
echo ${OUTPUT_FILE} > ${DFCHK_CFG}
exit 1
fi
############################################################
# Check for differences in current log against previous log.
############################################################
diff -ct ${PREVIOUS_OUTPUT} ${OUTPUT_FILE} | grep -v &quot;\---&quot; | egrep &quot;^\-|^\+|^!&quot;
> ${MAIL_FILE}

############################################################
# If mail file is empty then no filesystem usage has changed.
############################################################
NUM_LINES=`wc -l ${MAIL_FILE}|awk '{print $1}'`
if [ ${NUM_LINES} -eq 0 ]
then
# File is empty
echo &quot;There has been no change to %used&quot; > ${MAIL_FILE}
fi
mail -s &quot;${SUBJECT}&quot; root < ${MAIL_FILE}
rm ${MAIL_FILE}


############################################################
# Put current information in the config file.
# delete old information.
############################################################
echo ${OUTPUT_FILE} > ${DFCHK_CFG}
rm $PREVIOUS_OUTPUT

############################################################
# END OF SCRIPT
############################################################


:)
Dave V.
 
Try setting up PDT, is an installable option on AIX and can do the monitoring for you.
I hope it works...
Unix was made by and for smart people.
 
Get Big Brother from
Its free and highly customisable

I use it to monitor Oracle databases on 5 AIX systems, check if or AS/400s are up and you can get it to do NT as well

If you have an internet connection there are even pre written scripts on which will let you check stock prices or the local weather !!

Alex
 
If you want to go for some high end tools there is BMC Patrol which will do most of the things for you. I dunno if a downloadable version for that is available. Thief................
(In a confrontation between a rock and stream, the stream always wins, not because of strength but persistence.)
 
Try cricket.sourceforge.net for a tool that might just help.

Cheers,
Dave Vickers.
 
Dears:

We have a big file into / FS part, and this partition are in 100%, i´d like to know, how can I remove this uname file?
Please see the following FS list

-rw-r--r-- 1 root system 24395776 Nov 22 16:10
drwxr-xr-x 19 bin bin 1024 Nov 23 11:42 .
drwxr-xr-x 19 bin bin 1024 Nov 23 11:42 ..
-rw------- 1 root system 0 Nov 09 18:42 .Xauthority
-rw------- 1 root system 11054 Nov 23 12:12 .sh_history
-rw-r--r-- 1 root system 105 Nov 09 18:38 .xerrors
-rw------- 1 root system 65 Nov 09 18:38 .xsession-errors
-rw-r--r-- 1 root system 0 Dec 21 1999 0
-rw-r--r-- 1 root system 0 Nov 23 11:40 1
drwxr-xr-x 2 root system 512 Jul 11 2000 Patch_H
drwxr-xr-x 2 root system 512 Jul 12 2000 Patch_Hold
drwxr-xr-x 2 root system 512 Jun 29 1999 SMSRUN
drwxr-xr-x 2 root system 512 Aug 18 1999 TT_DB
lrwxrwxrwx 1 bin bin 8 Jun 29 1999 bin -> /usr/bin
-rw-rw-r-- 1 root system 0 Jun 21 01:16 bootrec
-rw-r--r-- 1 root system 4626 Aug 20 1999 bosinst.data
drwxr-xr-x 2 root system 512 Jun 29 1999 cdrom
drwxrwxr-x 4 root system 2560 Nov 23 10:12 dev
-rw-r--r-- 1 root system 0 Nov 23 11:24 esto
drwxr-xr-x 13 root system 3584 Aug 10 16:11 etc
drwxr-xr-x 27 bin bin 512 Sep 19 19:29 home
-rw-r--r-- 1 root system 7203 Jun 21 01:16 image.data
lrwxrwxrwx 1 bin bin 8 Jun 29 1999 lib -> /usr/lib
drwx------ 2 root system 512 Jun 29 1999 lost+found
drwxr-xr-x 26 bin bin 1024 Jun 29 1999 lpp
-rw------- 1 root system 401408 Nov 23 10:30 mbox
-rw-r--r-- 1 root system 655 Jun 29 1999 mex_cnf
-rwxrwxrwx 1 root system 2384 Jun 29 1999 mex_lic
drwxr-xr-x 2 bin bin 512 Jun 29 1999 mnt
drwxr-xr-x 2 root system 512 Jun 29 1999 opt
-rw-r--r-- 1 root system 0 Oct 12 2000 pepe.txt
drwxr-xr-x 3 bin bin 512 Jun 29 1999 sbin
-rw-rw-rw- 1 root system 2245405 Nov 09 18:42 smit.log
-rw-rw-rw- 1 root system 161249 Nov 09 18:42 smit.script
lrwxrwxrwx 1 root system 18 Jun 29 1999 tftpboot -> /usr/ncd/termi
nals
drwxr-xr-x 2 root system 512 Jun 29 1999 tftpboot_O
drwxrwxrwt 6 bin bin 2560 Nov 23 12:12 tmp
lrwxrwxrwx 1 bin bin 5 Jun 29 1999 u -> /home
lrwxrwxrwx 1 root system 21 Jun 29 1999 unix -> /usr/lib/boot/unix
_up
drwxrwxrwx 23 bin bin 512 Dec 15 2000 usr
drwxr-xr-x 16 bin bin 512 May 31 2000 var
#
# df -k
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/hd4 32768 24 100% 1003 7% /
/dev/hd2 1015808 400664 61% 15619 7% /usr
/dev/hd9var 114688 22284 81% 207 1% /var
/dev/hd3 114688 53568 54% 139 1% /tmp
/dev/hd1 16384 15024 9% 149 4% /home
/dev/SMSRUN 6389760 3135484 51% 14251 1% /usr/EBS/SMS/3.3.0/RUN
#

Thanks

Francisco A. Altamirano
SWITCHING NETWORK
NEXTEL Argentina
Palestina 977 - Tel. +54 11 49982620

 
Why don't you simply try PDT. Is a standard software package... It can monitor your volumes, filesystems, paging spaces, directories, ram usage, etc...
I hope it works...
Unix was made by and for smart people.
 
You could try typing

rm -i *

This should do an interactive remove of everything in the directory, and it will start with the 'no-name' file. Once you have said 'y' to delete the first file, type CTRL-C to cancel the command. It won't delete anything else.

HTH, LHLTech

IBM Certified Specialist - AIX System Support
Halfway through CATE exams!
 
Do you really need the smit.log & smit.script file to be kept? If not, just zero it out by using the > symbol as follows...

> /smit.log
> /smit.script

Also, PDT is OK, but it is meant more for trend analysis over a (period) 30 day period rather than a live monitoring tool.

Cheers,
Dave V.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top