- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: 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
Forums
Discussions
Discussions
Discussions
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 04:57 AM
07-11-2003 04:57 AM
Re: File System Alert Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 05:28 AM
07-11-2003 05:28 AM
Re: File System Alert Script
I am using this attached perl script to do the job
Some one in this forums did post a script very much like this one but for HP-UX os I did modify it to run on my linux.
I did quite a bite of modification, but I am afraid I do not remember who the original writer
is ...
I am just posting this modified version because it did teach me a fews tricks in perl, and I thing it could be usefull to you
modify reportfull and email_users in the script to your needs,
Jean-Pierre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 06:23 AM
07-11-2003 06:23 AM
Re: File System Alert Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 06:54 AM
07-11-2003 06:54 AM
Re: File System Alert Script
Kyle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 07:17 AM
07-11-2003 07:17 AM
Re: File System Alert Script
john's script is a simple shell script.
so u need to add the line #!/usr/bin/sh on top.
cheerio
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 09:42 AM
07-11-2003 09:42 AM
Re: File System Alert Script
#! /usr/bin/ksh
I just like the korn shell...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2003 10:04 AM
07-11-2003 10:04 AM
Re: File System Alert Script
#!/usr/bin/ksh
mark=1
while [ $mark = 1 ]
do
df | grep -v Filesystem |
while read line
do
MTP=$(echo "$line" | awk '{print $6}')
USE=$(echo "$line" | awk '{print $5}' | sed 's/.$//g')
if [ "$USE" > "60" ]
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