Linux mail alarm, monitor memory Cup

Source: Internet
Author: User

Feature Description:

1, the memory above the set value and sends the mail to the system administrator

2, cup load is too high and send mail to the system administrator

3, never quit monitoring. has been monitoring the background, if there is no processing after a minute to continue to send an email notification

The code is as follows:

memory= ' Free-h | awk ' Nr==3{print $4} ' |cut-c 1-3 '
#取内存现在有值
cup= ' Uptime | awk ' {print $8} ' |sed-n ' s#[^0-9. # #gp ' |cut-c 1 '
#取cup一分钟现有值, go to the integer section.
Caojiaoyue () {
If [$Memory-lt 860];then
echo "Memory alarm, Memory left $memory" | Mail-s "Monitoring Script" [email protected] &>/dev/null
#报警后等待100秒继续 to prevent Full mailbox
Sleep 100
Fi
If [$cup-ge 1];then
echo "Cup load: ${cup} is too high" | Mail-s "Monitoring Script" [email protected] &>/dev/null
Sleep 100
Fi

}
While [1]
Do
Caojiaoyue
Done

#执行方式sh file & can be placed in the background to see the process number through jobs

This article is from "No Lover" blog, please make sure to keep this source http://caojiaoyue.blog.51cto.com/11798573/1922836

Linux mail alarm, monitor memory Cup

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.