Linux Listening disk usage

Source: Internet
Author: User
Tags disk usage

The former server disk is full, causing the project a lot of strange problems, such as file upload is not (this very good understanding), and the login code can not be loaded (now still do not know why, the project's CAPTCHA image is only in memory generated BufferedImage object, do not know why and disk-related )

So while today is free, you add the server to listen to the disk usage of the script, after reaching a certain usage rate, will send an email alert, inform the development or operation to deal with the real-time, to avoid unnecessary trouble.

Find a very detailed blog to do a reference:

Http://www.heminjie.com/system/linux/1923.html

The main points are the following points:

1. View the usage of the system disk.

2. Send an email warning if you find that you have exceeded the set threshold.

3. Add Scheduled Tasks to view disk usage on a timed basis.

First, for the 1th, check the disk usage command Everyone may be familiar: Df-h.

The commands here add some options to the command to fetch the information we want directly.

df-h | awk ' Nf>3&&nr>1{sub (/%/, "", $ (NF-1));p rint $NF, $ (NF-1)} '

For the use of awk, refer to the Linux awk command

Then what we need to consider is how to alert us by email, with the SendEmail command in the data.

The detailed usage of the SendEmail command can be consulted in the following: The shell sends the Mail tool sendemail the usage explanation

Finally we add a scheduled task to our script, and the ability to listen for disk usage is implemented.

Linux Listening disk usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.