Solved

Low hard drive space email notification?

Posted on 2006-07-09
4
438 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
Comment Utility
0
 
LVL 14

Assisted Solution

by:ppfoong
ppfoong earned 250 total points
Comment Utility

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
Comment Utility
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
Comment Utility
Obviously, an email is only sent when disc usage gets above 90%. - Just change as required.

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

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
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 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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now