- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- File System Alert Script
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP