Thursday, May 04, 2006

Monitor Hard Drive usage

Monitoring Harddrive usage automatically

If you're maintaining a lot of server's with multiple hard-drives you'll need to know how to manage and watch your harddrives. You know it's getting full or needs cleaning before it's too late and your users can't complete their work because they're out of disk-space. Nothing is worse than franticly trying to reclaim disk-space because you ran out of it. This guide will hopefully aide you in a time-savinf manner.

First of all: check the usage of your hard-drive(s)!


$>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


As you can see my hda3 is at 82%. With the help of scripts you can have this task done at given times, and get an e-mail notification if the percentage of used disk-space reaches a certain threshold.

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


#!/bin/bash
df | egrep "(100%|[89][0-9]%)"


The egrep statement will match any usage between 80% and 100%.

Now let's do this as a timed event:
Type crontab -e to start an empty file where you can add all your cron jobs. (for more info type man 5 crontab)

Now to make a basic cron job that will run everyday at 10p.m..


0 22 * * * df | egrep "(100%|[89][0-9]%)"


The first number, 0, indicates the minute, the second, 22, is the hour that your job is supposed to run at. The next three *'s are day of month, the month, and day of week respectively.

Finally to have this cron job email you if any of your partition's are filled 80% or more you just add the mail command, like so:


0 22 * * * df | egrep "(100%|[89][0-9]%)" | mail -s "Warning..." you@emailaddr.com


The -s is for subject and you@emailaddr.com will be replaced by your email address.

6 comments:

Anonymous said...

Can anyone recommend the best Managed Service tool for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central malware detection
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

kimberly said...

buy viagra
viagra online
generic viagra

generic viagra said...

Please one more post about that.I wonder how you got so good. This is really a fascinating blog, lots of stuff that I can get into. One thing I just want to say is that your Blog is so perfect

Anonymous said...

It was very interesting to read about this in your article. blood pressure Read a useful article about tramadol tramadol

Anonymous said...

&&& Viagra Online Without Prescription %%% [url=http://www.viagra-online-without-prescription.biz]Viagra Online Without Prescription[/url] 778856 http://www.viagra-online-without-prescription.biz ((()0
Cialis &&&& [url=http://www.cialis.gd]Cialis[/url] %%% http://www.cialis.gd (()) Viagra **&& [url=http://www.viagra-no-prescription.com]Viagra[/url] %%% http://www.viagra-no-prescription.com
(()) Viagra **** [url=http://www.viagra.gd]viagra online without prescription[/url] %%% http://www.viagra.gd
$$%% Cialis Online (()) [url=http://www.cialisonline-usa.com]Cialis Online[/url] +++ http://www.cialisonline-usa.com

Anonymous said...

Trying to find somewhere that does reliable caravan repairs, too, can be an undertaking beset
with difficulty. Whichever option you choose, make sure the company
that gives you with caravan insurance or motorhome insurance is aware of its location.

Selling of stolen caravans is a top these days even at renowned website.



Here is my homepage; hobby caravan insurance quotes