03-12-2005
2 files below...
You will need to comment out those line related to SNMP Trap... cos you ain't got one.
> more mon_fs.ksh
####################################
#!/bin/ksh
#
# Author: Steven Koh
# UNIX Monitor File Systems Script
# Purpose: Monitors the size of file systems.
# Notifies via e-mail, SNMP
# Usage: Execute from crontab every 15 minutes.
# Dependencies: mon_fs.dat - Contains which file
# systems to monitor and how large they can be
# before a warning is issued.
# Outputs: Email, SNMP
#*********************************************************
CONF_FILE=/usr/local/scripts/monitor.conf
SCRIPTDIR=`grep "SCRIPTDIR" $CONF_FILE | awk -F= '{print $NF}'`
# The directory this script resides in
ADMINDIR=$SCRIPTDIR/monitorFS
IGNORE_LIST=$ADMINDIR/ignore.List
MAILADD=$LOGNAME@localhost
# Define the hostname of the server
SRVNM=`uname -n`
# Define the hostname of the SNMP server
SNMP_SRV=`grep "SNMP_SRV" $CONF_FILE | awk -F= '{print $NF}'`
SEND_TRAP=`grep "SEND_TRAP" $CONF_FILE | awk -F= '{print $NF}'`
OS=`uname -s`
if [ $OS == SunOS ]
then
DU="du -ksd"
elif [ $OS == Linux ]
then
DU="du -hx"
else
echo "DU not supported on $OS."
exit
fi
grep -v "#" $ADMINDIR/mon_fs.dat |
while read -r FS WARNINGCAP MAXCAP
do
if test `df -k ${FS} | grep -c "${FS}"` -eq 0; then
continue;
fi
echo " ... $FS"
CAPACITY=`df -k ${FS} | grep "${FS}" | awk '{print $5}' | awk -F% '{print $1}'`
if test $CAPACITY -gt $WARNINGCAP; then
mail $MAILADD <<EOF
From: $0
To: $MAILADD
Subject: File System on $SRVNM:$FS is at $CAPACITY%
$FS is at $CAPACITY% capacity on $SRVNM. (Warning is issued at $WARNINGCAP%)
Files that are not accessed for more than 30 days and > 100MB in size
==========================================================
find $FS -mount -atime +30 -size +104857600c | grep -v "\dev"
`find $FS -mount -atime +30 -size +104857600c | grep -v "\dev"`
Files that are modified less than 1 day and > 100MB in size
==========================================================
find $FS -mount -mtime -1 -size +104857600c | grep -v "\dev"
`find $FS -mount -mtime -1 -size +104857600c | grep -v "\dev"`
Sub-Directories ordered by space consumption
==============================================
$DU $FS/* | sort -rn
`$DU $FS/* | sort -rn`
EOF
fi
if test $CAPACITY -gt $MAXCAP; then
# Sending Traps
$SEND_TRAP -e FS001_$SRVNM -d $FS exceeds $MAXCAP% capacity -a Cleanup $FS -r $SNMP_SRV
touch $FS/FS001_$SRVNM.bad
elif test -f $FS/FS001_$SRVNM.bad; then
rm $FS/FS001_$SRVNM.bad
$SEND_TRAP -e FS001_$SRVNM -d $FS exceeds $MAXCAP% capacity -a Problem solved -r $SNMP_SRV
fi
#####################################
> more mon_fs.dat
# Mnt_Point Threshold_before_email Threshold_before_SNMP
/ 90 99
/proc 90 99
/dev/fd 90 99
/etc/mnttab 90 99
/var 90 99
/var/run 90 99
/tmp 90 99
/usr/openv 90 99
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
HI.
i installed solaris on a x86 machine and i only partition for 4 gig when it suppose to be 8. i only using 4 gig right now how can i start using the other four. please help, thanks in advance
Meeh (2 Replies)
Discussion started by: souldier
2 Replies
2. Shell Programming and Scripting
I have a partition that sometimes grows to 100% before the weekly backup and perge can happen. Can someone leade me to a script that will monitor the size of a partition and send me an email when it is over a certain percent? Unix Solarus 8.
Thanks (1 Reply)
Discussion started by: PrimeRibAndADew
1 Replies
3. UNIX for Dummies Questions & Answers
how to access/sliceing different partions using divvy (1 Reply)
Discussion started by: sobin
1 Replies
4. AIX
I'm trying to find out how many logical partitions our AIX box has. I'm running the command: topas -C
and nothing is showing up. Is it safe to say that there is only one LPAR, which is what AIX is installed on?
Move to AIX - jim mc (2 Replies)
Discussion started by: NycUnxer
2 Replies
5. Solaris
Hi. I newbie in solaris.
I have server T2000 with 2 disk on raid.
I have partitions:
Part Tag Flag Cylinders Size Blocks
0 root wm 825 - 3916 15.00GB (3092/0/0) 31464192
1 swap wu 0 - 824 4.00GB ... (6 Replies)
Discussion started by: burdock
6 Replies
6. UNIX for Advanced & Expert Users
Hello masters,
Actually, i am user of Ubuntu, but I want to use Debian too.
I have a computer with a product key for w7 so i will use too, only for games...
The structure I have thought is the next with 1TiB of capacity.
Primary: 50 GB NTFS for W7
Extended:
Logical: 20 GB FAT32... (3 Replies)
Discussion started by: albertogarcia
3 Replies
7. UNIX for Dummies Questions & Answers
Hi All,
My colleague says . On some boxes we have /var/,/opt are inside root and on some they are not on root they are separately. So please any one explain me what actually the difference is.
Thanks is Advance. (3 Replies)
Discussion started by: rama krishna
3 Replies
8. Solaris
Hello,
Can someone tell me why should i do to resolve this problem?
I cant creat the news partitions!!
# /etc/init.d/volmgt start
volume management starting.
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 1955 alt 2 hd 255 sec 63>
... (5 Replies)
Discussion started by: herbich1985
5 Replies
9. Red Hat
I had a query as to what are the partitions that should be necessary in RHEL 6. My knowledge says that
1) /
2) /home
3) Swap
4) /boot
should be sufficient. But, I am seeing in my production environment which is RHEL 5 that there are partitions also for
1) /var
2) /tmp... (8 Replies)
Discussion started by: RHCE
8 Replies
10. Red Hat
(Don't you hate being on holiday and being the only IT person in the family?)
Got a wonderful thanksgiving surprise .. dead windows-8 laptop with "important" unbacked-up data. No worries, I have my my fedora labtop and a magical SATA to USB converter. Plugged in the drive, and ... can't mount... (4 Replies)
Discussion started by: derekludwig
4 Replies
ZGREP(1) General Commands Manual ZGREP(1)
NAME
zgrep - search possibly compressed files for a regular expression
SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename...
DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code:
(-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the
standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep.
If the GREP environment variable is set, zgrep uses it as the grep program to be invoked.
EXIT CODE
2 - An option that is not supported was specified.
AUTHOR
Charles Levert (charles@comm.polymtl.ca)
SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1)
ZGREP(1)