HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Monitoring the size of a file system
Operating System - HP-UX
1827066
Members
4023
Online
109713
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2002 04:23 AM
09-10-2002 04:23 AM
I am looking for a unix script to monitor the size of a file system and notify when it reaches a pre determind size.
Green
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2002 04:29 AM
09-10-2002 04:29 AM
Re: Monitoring the size of a file system
Hi
#!/sbin/sh
# Check server diskspace
# check with bdf filesystems on multiple servers
# Ensure server is in /etc/hosts file
# (c) hpux@voss2000.de 2000-10-11
# for remote shell there has to be set permission in /.rhosts
# at the remote system(s)
# the script uses /tmp/bdfcheck directory to store percentage of
# each filesystem for history to avoid multiple message generation
MAILUSER="paula@avro.co.uk" # <-- put here the email address for sending
HOSTLIST="N-0 k1 k2" # HIGHWATERMARK=95 # max percentage of filesystem usage
[ ! -d /tmp/bdfcheck ] && mkdir /tmp/bdfcheck
for host in $HOSTLIST
do
{
if [ $host = $(hostname) ]
then
bdf -t hfs -t vxfs -l
else
remsh $host bdf -t hfs -t vxfs -l
fi
}|tail +2 |awk -vhost=$host '{
if(length(fs)>1)
fs=fs $0;
else
{
if(NF == 1)
{
fs=$1;
continue;
}
else
fs=$0
}
printf("%-10s: %s\n",host,fs);
fs="";
}'
done |
awk -vmax=$HIGHWATERMARK -vdate="`date`" 'BEGIN{first=1}
{
percent=$7;
hostname=$1;
filesystem=$NF;
gsub("/","_",filesystem);
sub("%","",percent);
percent=sprintf( "%d",percent);
histfile="/tmp/bdfcheck/" hostname filesystem;
getline oldpercent close(histfile);
print percent >histfile;
line=$0;
if(percent > oldpercent && percent > max)
{
if(first==1)
{
printf("%s\n\nFilesystems with more than %d%% usage:\n \n",date,max);
printf("%-10s Filesystem kbytes used avail %%used Mounted on\n","Hostname");
first=0;
}
printf("%s\n",line);
}
}' >/tmp/bdf_$$
if [ -s /tmp/bdf_$$ ]
then
cat /tmp/bdf_$$ | mailx -s 'FILESYSTEMS WARNING' $MAILUSER
fi
rm -f /tmp/bdf_$$
cd /tmp/bdfcheck
rm *
Not my script but very good.
HTH
Paula
#!/sbin/sh
# Check server diskspace
# check with bdf filesystems on multiple servers
# Ensure server is in /etc/hosts file
# (c) hpux@voss2000.de 2000-10-11
# for remote shell there has to be set permission in /.rhosts
# at the remote system(s)
# the script uses /tmp/bdfcheck directory to store percentage of
# each filesystem for history to avoid multiple message generation
MAILUSER="paula@avro.co.uk" # <-- put here the email address for sending
HOSTLIST="N-0 k1 k2" #
[ ! -d /tmp/bdfcheck ] && mkdir /tmp/bdfcheck
for host in $HOSTLIST
do
{
if [ $host = $(hostname) ]
then
bdf -t hfs -t vxfs -l
else
remsh $host bdf -t hfs -t vxfs -l
fi
}|tail +2 |awk -vhost=$host '{
if(length(fs)>1)
fs=fs $0;
else
{
if(NF == 1)
{
fs=$1;
continue;
}
else
fs=$0
}
printf("%-10s: %s\n",host,fs);
fs="";
}'
done |
awk -vmax=$HIGHWATERMARK -vdate="`date`" 'BEGIN{first=1}
{
percent=$7;
hostname=$1;
filesystem=$NF;
gsub("/","_",filesystem);
sub("%","",percent);
percent=sprintf( "%d",percent);
histfile="/tmp/bdfcheck/" hostname filesystem;
getline oldpercent
print percent >histfile;
line=$0;
if(percent > oldpercent && percent > max)
{
if(first==1)
{
printf("%s\n\nFilesystems with more than %d%% usage:\n \n",date,max);
printf("%-10s Filesystem kbytes used avail %%used Mounted on\n","Hostname");
first=0;
}
printf("%s\n",line);
}
}' >/tmp/bdf_$$
if [ -s /tmp/bdf_$$ ]
then
cat /tmp/bdf_$$ | mailx -s 'FILESYSTEMS WARNING' $MAILUSER
fi
rm -f /tmp/bdf_$$
cd /tmp/bdfcheck
rm *
Not my script but very good.
HTH
Paula
If you can spell SysAdmin then you is one - anon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2002 04:31 AM
09-10-2002 04:31 AM
Solution
Hi Raymond:
I usually put this in my crontab and it runs every morning:
#!/bin/sh
TH1="9[0-9]%"
TH2="100%"
HOSTNAME=`hostname`
for FILESYSTEM in `bdf -l | grep -e $TH1 -e $TH2| awk -v HOSTNAME=\`hostname\` '{print $6":"HOSTNAME":"$5}'`
do
MESSAGE=`echo $FILESYSTEM | awk -F: '{print "The " $1 " file system on " $2 " is at " $3 " utilization"}'`
mailx -s "$MESSAGE" xxx.yyy@zzz.com < /dev/null
done
Shiju
I usually put this in my crontab and it runs every morning:
#!/bin/sh
TH1="9[0-9]%"
TH2="100%"
HOSTNAME=`hostname`
for FILESYSTEM in `bdf -l | grep -e $TH1 -e $TH2| awk -v HOSTNAME=\`hostname\` '{print $6":"HOSTNAME":"$5}'`
do
MESSAGE=`echo $FILESYSTEM | awk -F: '{print "The " $1 " file system on " $2 " is at " $3 " utilization"}'`
mailx -s "$MESSAGE" xxx.yyy@zzz.com < /dev/null
done
Shiju
Life is a promise, fulfill it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2002 04:34 AM
09-10-2002 04:34 AM
Re: Monitoring the size of a file system
There have to be a billion scripts out there that do this. Have you done ANY searches for such?
http://www.bb4.com ??
live free or die
harry
Live Free or Die
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP