Shell implementation checks for memory alarms

Source: Internet
Author: User
Tags auth mail account

Use the shell implementation to check the memory size, if it is displayed within the set value, send an email alert


    1. Configure Outgoing Mail first

      Vi/etc/mail.rc

      Add the following information

    2. # for Linux and BSD, this should is Set.set bsdcompatset [email protected] Smtp=smtp.163.comset Smtp-auth-user=alvin smtp- auth-password=123456 Smtp-auth=login

#注意: [email protected] is your e-mail account, Alvin is your mailbox user name, 123456 is your email password

The following is a memory exceeded mailbox Alert script:

[email protected] script]# cat check_memory.sh #!/bin/bashfreemem= ' Free-m|awk ' nr==3 {print $NF} ' chars= ' current Memor Y is $FreeMem. " chars1= "Memory Alert" if [$FreeMem-lt 1800] then echo $CHARS >/tmp/messages.txt mail-s "' Date +%f-% T ' $CHARS 1 "[email protected] </tmp/messages.txtelse echo $CHARSfi

In order to be able to send an email to the police, I set the larger here (1800) The actual production environment settings are not set so large.

To demonstrate this script, you can delete the Echo $CHARS and join the timed task, which executes every 3 minutes.

*/3 * * * */bin/sh/server/script/check_memory.sh &>/dev/null

This article is from the "Knowledge Change Destiny" blog, please be sure to keep this source http://ahtornado.blog.51cto.com/4826737/1930320

Shell implementation checks for memory alarms

Related Article

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.