Solved

Low hard drive space email notification?

Posted on 2006-07-09
4
439 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

777 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