Alert Notification script to warn you about low disk server space left on Linux / (Low Disk Space Notification via SMS and E-mail)

Thursday, 10th June 2010

Once again I’ve encountered a problem with a non operational website on a CentOS Linux caused by a depleted disk space on the server.
The disk has been full with data to it’s maximum capacity because the last website SQL and file data backup.
To prevent future unexpected server outages caused by a filled up disk I’ve decided to implement a quick script to warn me when there is a low disk space left on the server system. I was lazy to write a disk monitoring script from scratch so I used the one present on Send an Email Alert When Your Disk Space Gets Low nice article.
I’ve done minor modifications to the script present on the article shown above to make it report on an email the exact system hostname from where it originates (helpful if you intend to run the script on more than one linux servers).
The script is also accustomed to send an SMS message to your mobile phone warning about the possible emerging disk full issues.

If you want to use my monitor_disk_space.sh script after the minor modifiations done to it to report server host and send sms to your mobile check here

Actually it seems too many old backups were just hanging there so I installed a tiny script on a crontab to periodically clear up the old backups.
Here is the script itself:

You can download the clear_old_log_backups.sh script here

Both the monitor_disk_space.sh and clear_old_backups scripts should be prepared to run on a crontab.
In case if you intend to run the aforementioned two scripts you would have to prepare a crontab records similar to the following:

# clear old data backups
30 2 2,20 * * /usr/sbin/clear_old_log_backups.sh
# monitor and report if disk space is low
05,30,59 4 * * * /usr/sbin/monitor_disk_space.sh

That two works fine for me hopefully they would be of use to somebody out there. Feel free to contact me here if you experience some problems in setting up the scripts.

Share this on:

Download PDFDownload PDF

Tags:

8 Responses to “Alert Notification script to warn you about low disk server space left on Linux / (Low Disk Space Notification via SMS and E-mail)”

  1. Gilda Keppers says:
    Internet Explorer 7.0 Internet Explorer 7.0 Windows XP Windows XP
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)

    Before the commercial ventures, Linux tended to be rather hard to set up, because most of the developers were motivated mainly by their own interests.

    View CommentView Comment
  2. Loan Kwiecinski says:
    Google Chrome 4.0.221.7 Google Chrome 4.0.221.7 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.7 Safari/532.2

    Thanks a lot for reveal quite great informations. Your net is great.I am impressed by the details that you’ve on this blog. It shows how very well you comprehend this subject. Bookmarked this amazing page, will come back again for additional. You, my friend, amazing! I discovered just the specifics I already looked everywhere and just could not find. What a perfect internet site. Similar to this site your web-site is one of my new much-loved.I like this knowledge proven and it has offered me some kind of creativity to possess good results for some cause, so keep up the decent work!

    View CommentView Comment
  3. Gabriela Centore says:
    Opera 9.64 Opera 9.64 Windows XP Windows XP
    Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1

    Great. Thanks for typing this. Its always awesome to see someone give back to the public.

    View CommentView Comment
  4. pozycjonowanie says:
    Google Chrome 4.0.221.7 Google Chrome 4.0.221.7 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.7 Safari/532.2

    Great Blog ! Regards.

    View CommentView Comment
  5. Wendy Lohry says:
    Firefox 3.5.3 Firefox 3.5.3 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3

    thank you for this post, I am a big big fan of this website would like to keep updated.

    View CommentView Comment
    • admin says:
      Epiphany 2.30.6 Epiphany 2.30.6 Debian GNU/Linux x64 Debian GNU/Linux x64
      Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+ Debian/squeeze (2.30.6-1) Epiphany/2.30.6

      I’m happy to heart Wendy, hope to see you around 😉

      View CommentView Comment
  6. beats by dr dre Ibeats says:
    Internet Explorer 7.0 Internet Explorer 7.0 Windows XP Windows XP
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)

    you are really a good webmaster. The website loading speed is incredible. It seems that you’re doing any unique trick. Also, The contents are masterwork. you have done a excellent job on this topic!

    View CommentView Comment
  7. Robert Dahnke says:
    Firefox 3.5.3 Firefox 3.5.3 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3

    Sam dawniej mÄ™czyÅ‚em siÄ™ z katalogowaniem rÄ™cznym, do czasu… aż natknÄ…Å‚em siÄ™ na SeoAddera. Teraz automat robi wszystko za? mnie, czy to nie Å›wietne?

    View CommentView Comment

Leave a Reply

CommentLuv badge