LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2013, 05:17 PM   #1
theondr
LQ Newbie
 
Registered: Mar 2011
Posts: 14

Rep: Reputation: 0
Scripting for disk usage of filesystems.


Scripting
Could somebody kind of walk me through the following? What areas would one study to get a handle on what the below requirements are?

This is for disk usage.

I have had one course in Linux/Unix. I have had C programming.
Is Bash ok to use?





Create a script that sends an email message to the user specified on the command line if any of the filesystems are at more than 70% of capacity. The script should not process special filesystems as /proc . It should only process filesystems which are either locally mounted or are mounted via NFS.
An individual email should be sent for each filesystem which is at the warning level. There should be a subject on the email with a message "Warning: Filesystem <put filesystem the>here is at <X>% of capacity" If the filesystem is at greater than 90% of capacity, the "Warning" should be changed to "Critical Warning".
 
Old 02-14-2013, 05:24 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Bash would be fine. "df" will already report the disk usage for all mounted filesystems, along with % usage. So it should just be a matter of calling df, and then parsing the output and checking for any filesystems that are >xx% usage.

Then you just need to look into how to send emails from the command line.
 
Old 02-14-2013, 06:20 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
What he said

If you bookmark/read these and take it slowly, it shouldn't be too hard.
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

If you need to automate it, you can use the cron scheduler
http://www.adminschoice.com/crontab-quick-reference
 
Old 02-14-2013, 09:24 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You can create a script with help of below commands (just for your rederence), and schedule the same in your system's crontab.
Code:
df -h | awk -F" " '{gsub(/\%/,"",$4); if($4>=70) print $0}' > /tmp/fs_status.txt
mailx -s "File system status" abc@example.com < /tmp/fs_status.txt
 
Old 02-16-2013, 11:02 AM   #5
theondr
LQ Newbie
 
Registered: Mar 2011
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks all

Thanks to everyone for the reply. Now I have an idea how to approach the problem. I will respond with the result.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk Usage Analyzer reports too much disk space? ler0nldb2 Linux - Newbie 1 09-12-2009 11:27 AM
An extensive discussion of if-then usage for shell scripting? Cyberman Programming 6 03-22-2009 02:33 PM
LXer: Save disk space - use compFUSEd to transparently compress filesystems LXer Syndicated Linux News 0 06-10-2008 04:40 PM
ext2 and ext3 use way more disk space then the other filesystems Necronomicom Linux - General 0 08-15-2004 11:06 PM
101% disk usage on an empty disk tsiuser Linux - Software 3 01-28-2004 07:24 PM


All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration