Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a similar question. I tried iWatch but ATM it doesnt seem to email me. but also i dont believe it will watch disk space. That isnt advertise on their homepage.

What app can i use to email me when the disk is getting low? Can i use the same app to watch folders for filechanges? (and exclude a subfolder such as lucene which is expected to change)

share|improve this question

3 Answers 3

up vote 3 down vote accepted

In a former life without monitoring systems and automatic warnings I had use for this snippet:

#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while
read output;
do
  echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge 90 ]; then
      echo "Running out of space \"$partition ($usep%)\" on $(hostname)
      as on $(date)" |
      mail -s "Alert: Almost out of disk space $usep%" your@email.tld
   fi
done

If you are monitoring more than just this server, make yourself and your company a big favour and use a proper monitoring server like nagios. We use opsview community edition because it is free like nagios and has a great web interface so you do not need to be a linux admin to add/remove hosts/services.

share|improve this answer
    
I am using nagios. It looks good. I tried opsview as well. It doesnt seem to play well with debian lenny (i followed the instructions) and had unresolved lib problems. Also it looked like it requires java. I dont want to use java on my server only for one app (which will be the case ATM since i have no others). –  acidzombie24 Sep 30 '10 at 0:49
    
I have had absolutely no problems using the opsview repository downloads.opsera.com/opsview/apt/community and installing opsview in debian lenny. It does install the java runtime environment, but I do not find that disturbing. I have used nagios since version 2, and I love the product, but being the only admin that is able/willing to administer the monitoring system will finally have your nagios server cancelled. Having a nice web ui gives your colleagues no excuse not to use it. –  natxo asenjo Sep 30 '10 at 9:19

You can probably script something together using cron and incron

share|improve this answer
    
I dont want to code yet another solution. –  acidzombie24 Sep 29 '10 at 8:57

One-liner for cron:

MAXUSE=`df |sed 's/^.* \([0-9][0-9]*\)%.*$/\1/g' \
  |sort -nr \
  |head -1` \
  sh -c 'if [[ ${MAXUSE} > 95 ]]; then echo "Usage at ${MAXUSE}%"; fi'

Note that cron only e-mails when there is output. So a cron script that runs but prints nothing will trigger no e-mails.

share|improve this answer
    
i didnt know linux hacking can be that easy! unfortunately theres an error in that script and i dont know how to fix it. I tried for 5mins now so i'll instead try to write it in a normal bash file. –  acidzombie24 Sep 29 '10 at 9:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.