- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- write a script to check the usage of a file system
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО06-14-2006 10:20 PM
тАО06-14-2006 10:20 PM
write a script to check the usage of a file system
I need to write a script to check the usage of a file system and send out a mail if the filesystem is more than 95%.
Could you please help me to write this script?
Bishooo
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 10:36 PM
тАО06-14-2006 10:36 PM
Re: write a script to check the usage of a file system
check the following thread where I attached a script to do what you are looking for:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1035028
You can manage the variable SYSMAX, in your example you can change to
SYSMAX=95
So if there a filesystem taking over 95% then you will receive a mail (to
HTH.
Best regards,
Fabio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 10:40 PM
тАО06-14-2006 10:40 PM
Re: write a script to check the usage of a file system
-------------------------------------------
This is another file system size checking script using bdf.
File system is >= 90% - email root.
File system is > 95% - page somebody.
It will work when lvol names are large and running bdf drops the "kbytes used" etc data to the next line.
-------------------------------------------
u need to check the format and do some modifications and assign points to ur 8 responses (from ur profile:I have assigned points to 0 of 8 responses to my questions.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 10:45 PM
тАО06-14-2006 10:45 PM
Re: write a script to check the usage of a file system
I'm new to HP-UX so please explain to me...
I didn't know what should I write in the script!
Sorrt :$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 10:49 PM
тАО06-14-2006 10:49 PM
Re: write a script to check the usage of a file system
I'm new to hpux specialy the scripting so please I didn't know what should I write in the script?
Sorry :$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 10:54 PM
тАО06-14-2006 10:54 PM
Re: write a script to check the usage of a file system
I will answer about my post to explain better what you have to do:
- go in thread indicated by me;
- save the attachment of the my post under /tmp on HP-UX system;
- rename it to something familiar and give execute permission:
mv
chmod 755 FSUSAGE.sh
./FSUSAGE.sh
For each filesystem taking over 85% the script will send a mail to
Of course you have to change
I hope that clarifies better for you.
Best regards,
Fabio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 11:09 PM
тАО06-14-2006 11:09 PM
Re: write a script to check the usage of a file system
then
I create fs.sh and I add:
SYSMAX=85
for MNTPT in `cat /etc/mnttab | awk '{print $2}'|grep -v net | grep -v home`
do
FILESYS=`bdf $MNTPT | grep -v avail | awk '{print $5}'| tr -d "%"`
if [ $FILESYS -gt $SYSMAX ]
then
echo "WARNING: $MNTPT File System is using $FILESYS% of diskspace allocated " | elm -s "WARNING! There is a filesystem near full!"
fi
done
Then
#mv fs.sh FSUSAGE.sh
# chmod 755 FSUSAGE.sh
#./FSUSAGE.sh
./FSUSAGE.sh[2]: Syntax error at line 8 : `newline or ;' is not expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2006 11:32 PM
тАО06-14-2006 11:32 PM
Re: write a script to check the usage of a file system
The script is missing several things. This variation will work (at least syntactically):
#!/usr/bin/sh
SYSMAX=85
for MNTPT in `cat /etc/mnttab | awk '{print $2}'|grep -v net | grep -v home`
do
FILESYS=`bdf $MNTPT | grep -v avail | awk '{print $5}'| tr -d "%"`
if [ $FILESYS -gt $SYSMAX ]
then
echo "WARNING: $MNTPT File System is using $FILESYS% of diskspace allocated " |
elm -s "WARNING! There is a filesystem near full!" root
fi
done
...Note that I added an interpreter line at the very beginning that tells exactly what (shell) interpreter we want to use. We will use the standard HP-UX Posix shell.
You missed customizing your mail account. I've substituted 'root' for "
Replace your current version with this one or make the changes yourself. Be sure to grant execute permissions if necessary, again.
If you are new to shell scripting, have a look at the "Shells: User's Guide". I suggest that you use the POSIX shell since this is the default for HP-UX. I would urge you not to use 'csh'. It is very feature-poor.
http://docs.hp.com/en/B2355-90046/B2355-90046.pdf
Regards!
...JRF..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2006 01:13 AM
тАО06-15-2006 01:13 AM
Re: write a script to check the usage of a file system
echo "WARNING: $MNTPT File System is using $FILESYS% of diskspace allocated " | elm -s "WARNING! There is a filesystem near full!"
has to be on a unique line (even if you see two lines in my post).
Best regards,
Fabio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2006 01:30 PM
тАО06-15-2006 01:30 PM
Re: write a script to check the usage of a file system
Please find attached a script.
You have to create a mailing list for email and pager. Hopefully this will help you.
Regards.
Harrry.