Home » Send an Email Alert When Your Disk Space Gets Low

Send an Email Alert When Your Disk Space Gets Low

Hasil “jalan-jalan” di linuxjournal.com, ketemu tutorial ya bisa dibilang penting.
Berikut hasil copas dari thread di linuxjournal.com

If you don’t want to step up to a full monitoring solution such as Nagios you can create your own scripts for monitoring the things that you want to monitor, such as disk space. The following script alerts you when your root partition is almost full:

Berikut scriptnya

1
2
3
4
5
6
7
8
9
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -s 'Disk Space Alert' mailid@domainname.com << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF

fi

The script sends an email when the disk usage rises above the percentage specified by the THRESHOLD varialbe (90% here).

To run it daily, for example, save the script to the file sample.sh in your home directory, change the email to your email, and add the following line at the end of /etc/crontab file:

@daily ~/sample.sh

2 Responses to “Send an Email Alert When Your Disk Space Gets Low”

  1. cid says:

    gak mudeng gan????

  2. cidtux says:

    absen keduax gan… :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>