- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- File System Alert Script
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
тАО07-10-2003 10:59 AM
тАО07-10-2003 10:59 AM
Write a small script to send out a email notification to myself when a filesystem reaches a certain percent (say 96 %). I'm pretty sure i'd have to use the df command to go with the "awk" command to pull the % field. Can somebody give me a little help? The awk command is kicking my a$$.... Thanks alot to all!
Kyle Harris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 11:10 AM
тАО07-10-2003 11:10 AM
Re: File System Alert Script
#!/usr/bin/awk -f
BEGIN {
#Skip the initial header output of bdf
getline
#set flag to do one time echoing stuff
flag=0
#The argument passed to this script is a path whose last few characters
#contain the hostname. Find the exact hostname
a = index(FILENAME,"tmp\/")
b=substr(FILENAME,a+4)
}
{
#Ignore some stuff like /net etc...
if (NF > 5) {
print substr($5,1,length($5)-1)
#Remove the % symbol and check if usage is more than 90%
if ( int(substr($5,1,length($5)-1)) >= 90 ) {
#Check for flag to print header in mail
if ( flag == 0 ) {
print "The following file system(s) are more than 90% full for " b
flag=1
}
#Print mountpoint, usage,....
print $1 "\t\t" $5 "\t\t" $6
}
}
}
END {
#Formatting stuff
if ( flag == 1) {
print "================="
}
}
++++++++++++end cut++++++++++++++
Pipe the output of bdf to this script and watch the output.
cheerio
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 11:24 AM
тАО07-10-2003 11:24 AM
Re: File System Alert Script
Linux doesn't have a BDF command. It's "df" in linux. Anyway, that looked pretty complex, but if it works it works. I imagined it would only be about 5 or 6 lines for the whole script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 11:35 AM
тАО07-10-2003 11:35 AM
Solutionsorry. this was a script which i used to use in the HP unix environment.
do this.
run df -h and save it a file.
save this snippet as some script.awk.
and run script.awk
if the filesystem size is greater than 90% it fill fill them.
i have a script which actually does an remsh into a list of hosts and calls this script for every host.
and sends a consolidated mail from it.
am leaving home in the next ten minutes. so if u need any more info, reply quickly.
cheerio
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 11:38 AM
тАО07-10-2003 11:38 AM
Re: File System Alert Script
Kyle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 11:39 AM
тАО07-10-2003 11:39 AM
Re: File System Alert Script
df -k | awk '{if (int(substr($5,1,length($5)-1)) >= 90) { print $1 " is " $5 " full"}}'
cheers
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 11:40 AM
тАО07-10-2003 11:40 AM
Re: File System Alert Script
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2003 12:17 PM
тАО07-10-2003 12:17 PM
Re: File System Alert Script
mark=1
while [ $mark = 1 ]
do
df |
while read a b c d e f
do
MTP=$(echo $f | grep -v "Mounted on")
USE=$(echo $e | grep -v Use | sed 's/.$//g')
if [ "$USE" >= "96" ]
then
echo "$MTP $USE " | mailx -s "FS alert" sendto@work.com
sleep 100 #or whatever time
else
sleep 100 #or whatever time
fi
done
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2003 04:39 AM
тАО07-11-2003 04:39 AM
Re: File System Alert Script
Kyle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2003 04:54 AM
тАО07-11-2003 04:54 AM
Re: File System Alert Script
int(substr($5,1,length($5)-1))
-balaji