Solved

Low hard drive space email notification?

Posted on 2006-07-09
4
443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

630 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