Solved

Low hard drive space email notification?

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

752 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