LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-16-2004, 05:59 PM   #1
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
Hard Drive Monitor Guide (Fun and Easy)


Watching/Maintaining harddrives can be a pain (or your best friend) depends on the situation. Maintaining alot of server's with multiple harddrives; one needs to know how to manage and watch their harddrives, so one know if its getting full or when you need to clean it up, before it gets completely full. Nothing is worse then frankly deletely files because you need to free up space. Hopefully after this guide, you can safely manange your harddrive with the help of scripts and automation

Anywho here goes:

firstly to check the usage of your harddrive you can use the command:
Code:
 
$>df -h
Filesystem	Size   Used  Avail  Use% Mounted on

/dev/hda3       4.4G  3.4G  764M  82%  /
/dev/hda1       14G  4.5G  9.3G  33%    /mnt/win32
the -h switch is to change from kilobytes to Gigabyte or megabytes depending on the situation.

As you can see my hda3 is at 83% (haha). With the help of scripts you can have this task done at particular times and email you if its over a certian limit.

First we will make a basic bash script that will report if any paritions are over 80%.

Code:
 #!/bin/bash
df -h | grep [89][0123456789]%
The grep [89][0123456789] will grep if any partion is between 80 and 99 exclusively. I didn't include 100% because I don't know how to do it. If anyone knows please let me know

Now you are probably think, wouldn't it be great to have this run at a specifc time everyday? Well...with crontab it is possible.

type crontab -e to start an empty file where you can add all your cron jobs. (for more info type man 5 corntab)

Now to make a basic cron job that will run everyday at 10p.m..
Code:
22 0 * * *        df -h | grep -e "[89][0123456789]\%"
The first 22 is the hour the job will accur,
The second 0 is the minute,
The next three *'s are day of month, the month, and day of week respectively

Also we need to use the -e switch, after grep, to tell cron that we want it to intrepet just like the bash shell. Also \ slash tell cron to not intrepret the % sign into anything else.

Finally to have this cron job email you if anyone of your partition's are 80% or more full you need to add the mail command, like so:
Code:
22 0 * * *        df -h | grep -e "[89][0123456789]\%" | mail -s "Warning..." you@emailaddr.com
The -s is for subject and you@emailaddr.com will be replaced by your email address.

Lets me know about this guide. If you like it, or if it wasn't useful. Any feedback is greatly encouraged. Thanks
 
Old 08-16-2004, 06:09 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
This sort of thing is far better as a Linux Tutorial. Putting it there would mean that it doesn't get pushed further and further down the list and eventually lost. Would you consider submitting it there?
 
Old 08-16-2004, 08:23 PM   #3
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
ya, i want to pass on what i have learned to other linux fans out there
 
  


Reply



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
DISCUSSION: A Short Guide to Partitioning a Hard Drive for a Linux System moses LinuxAnswers Discussion 33 07-06-2014 12:36 PM
EASY guide to installing 3D driver? little_penguin Linux - Software 4 04-05-2005 11:19 AM
Fun newbie guide. tripmix General 2 01-30-2005 10:45 AM
Easy way to install Slackware 10 on SATA hard drive Swift&Smart Slackware 7 12-20-2004 12:46 PM
Easy way to clone linux installed hard drive mobassir Linux - Software 6 01-12-2004 05:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 06:27 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
Open Source Consulting | Domain Registration