Solved

Low hard drive space email notification?

Posted on 2006-07-09
4
440 Views
Last Modified: 2010-04-20
Hey guys.  I have a members website where ppl upload photos.  And sometimes the hard drive fills up real quickly and by the time I find out... many hours have passed withtout ppl being able to upload.  I was wondering if anyone know of a good way on linux where I could have some kind of system send my personal email addy a notice about the hd space status when its low?
0
Comment
Question by:tyleradam
  • 2
4 Comments
 
LVL 34

Expert Comment

by:PsiCop
ID: 17070649
0
 
LVL 14

Assisted Solution

by:ppfoong
ppfoong earned 250 total points
ID: 17071108

Yes, nagios can do it. It need quite some configuration before can start working too.

Another way is to have the server email the disk usage status to you using crontab, and you monitor the status yourself. The script below will do the job when you put it in cron, lets say, daily.


#!/bin/sh
umask 0066
RPT_FILE=/tmp/diskusage.rpt
echo "Disk space usage report as at `date +%x` for MyServer." > $RPT_FILE
echo " " >> $RPT_FILE
/usr/bin/df -h >> $RPT_FILE
echo " " >> $RPT_FILE
/bin/mail -s "Disk space usage report as at `date +%x`" youremail@address.com < $RPT_FILE
/bin/rm $RPT_FILE

0
 
LVL 22

Accepted Solution

by:
pjedmond earned 250 total points
ID: 17071121
There are a number of other processes such as mon:

http://freshmeat.net/projects/linux-mon/

Monit:

http://www.tildeslash.com/monit/doc/manual.php

is also quite good for alert messages.

..or you could write your own script:)

df | grep hda2 | awk {'print $5'}

can be tweaked toprint the % diskspace remaining for a specific hard drive, and then send you and email:

-----------8X------------------
#!/bin/bash

SPACE=`df | grep hda2 | sed -e s/%// | awk {'print $5'}`

if [ $SPACE -gt 90 ]; then
#       echo "Low on space"
sendmail -t -oi  <<EOF
From: bigserver@myserver.com
To: me@myemail.com
Subject: [LOW DISC SPACE]

Disc space usage is $SPACE %
Please check!
EOF

fi
-----------8X------------------

Now 'crontab -e'

and set the script to run every 10 minutes:

0,10,20,30,40,50 * * * * /root/scripts/checkdisc.sh

(   (()
(`-' _\
 ''  ''
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 17071130
Obviously, an email is only sent when disc usage gets above 90%. - Just change as required.

(   (()
(`-' _\
 ''  ''

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question